Little script help
by Andrei Georgescu · in Torque Game Builder · 07/29/2010 (11:02 am) · 1 replies
Hello! I have the script below and the bottom 2 functions (next and prev weapon) doesn't work (the application gets stuck). Can someone give me a hand please?
function initWeapons()
{
$wWaterBall = new ScriptObject()
{
Name = "Water Ball";
Order = 1;
Next = $wPlasmaBall;
Prev = $wPlasmaBall;
BlendColor = "1 1 0 1";
Size = "6, 6";
ImageMap = particles1ImageMap;
Amo = -1;
Damage = 8;
Recul = 250;
Speed = 100;
};
$wPlasmaBall = new ScriptObject()
{
Name = "Plasma Ball";
Order = 2;
Next = $wWaterBall;
Prev = $wWaterBall;
BlendColor = "0.2 1 0.1 1";
Size = "8, 8";
ImageMap = particles1ImageMap;
Amo = 10;
Damage = 15;
Recul = 400;
Speed = 80;
};
$tWeapons = 2;
}
function PlayerFish::setWeapon(%this, %weapon)
{
$stopShoot = 1;
$mainWeapon = %weapon;
$FishPlayer.damage = $mainWeapon.Damage;
pWeapon.text = "Weapon: " @ $mainWeapon.Name @ " (" @ $mainWeapon.Order @ "/" @ $tWeapons @ ")";
pDamage.text = "Damage: " @ $mainWeapon.Damage;
$stopShoot = 0;
schedule($mainWeapon.Recul, 0, "doShoot");
}
function PlayerFish::NextWeapon(%this)
{
%this.setWeapon($mainWeapon.Next);
}
function PlayerFish::PrevWeapon(%this)
{
%this.setWeapon($mainWeapon.Prev);
}About the author
Andrei Georgescu
function initWeapons() { $wWaterBall = new ScriptObject() { Name = "Water Ball"; Order = 1; BlendColor = "1 1 0 1"; Size = "6, 6"; ImageMap = particles1ImageMap; Amo = -1; Damage = 8; Recul = 250; Speed = 100; }; $wPlasmaBall = new ScriptObject() { Name = "Plasma Ball"; Order = 2; BlendColor = "0.2 1 0.1 1"; Size = "8, 8"; ImageMap = particles1ImageMap; Amo = 10; Damage = 15; Recul = 400; Speed = 80; }; $tWeapons = 2; $weps[1] = $wWaterBall; $weps[2] = $wPlasmaBall; } function PlayerFish::setWeapon(%this, %weapon) { $stopShoot = 1; $mainWeapon = %weapon; $FishPlayer.damage = $mainWeapon.Damage; pWeapon.text = "Weapon: " @ $mainWeapon.Name @ " (" @ $mainWeapon.Order @ "/" @ $tWeapons @ ")"; pDamage.text = "Damage: " @ $mainWeapon.Damage; $stopShoot = 0; schedule($mainWeapon.Recul, 0, "doShoot"); } function PlayerFish::NextWeapon(%this) { if($mainWeapon.Order+1 > $tWeapons) { %this.setWeapon($weps[1]); } else { %this.setWeapon($weps[$mainWeapon.Order+1]); } } function PlayerFish::PrevWeapon(%this) { if($mainWeapon.Order-1 < 1) { %this.setWeapon($weps[$tWeapons]); } else { %this.setWeapon($weps[$mainWeapon.Order-1]); } }