Blockland Forums > Modification Help
Syntax Error in Script
<< < (4/4)
Pew446:

--- Quote from: Kalphiter on June 12, 2010, 10:03:32 PM ---1. Pew is stupid, ignore him
2. there are two checks to see if the z velocity is less than -20
3. Player::getVelocity should be Player::onCollision, and should be parented
     Player::getVelocity makes no sense, it's not an event and is only called when other add-ons need to get the velocity.
4. tumble isn't closed? That might just be the snip of the whole code.

--- End quote ---

 :cookieMonster:
Audax:
Thank you Kalphiter. There are no more syntax errors. The script executes, and is enabled. There is one problem though. While I am falling, and my velocity probally has reached less than or equal to -20, I do not tumble. Here is the code, any idea what is not making me tumble?


--- Code: ---package TumbleOnFall
{
function Player::onCollision(%this,%obj,%col,%pos,%speed)
{
if(getWord(%obj.onCollision(),2) <= -20)
   tumble(%obj,2500);
Parent::onCollision(%this,%obj,%col,%pos,%speed);
}
};
function tumble(%obj, %time)
{
   //do not tumble non-players
   if(!(%obj.getType() & $TypeMasks::PlayerObjectType))
      return;

   //do not tumble dead people
   if(%obj.getDamageLevel() >= 1.0)
      return;

//mount the object on a new deathvehicle for %time milliseconds
%currentVehicle = %obj.getObjectMount();
%client = %obj.client;

%newcar = new WheeledVehicle()
{
dataBlock = deathVehicle;
client = %client;
initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
};
MissionCleanup.add(%newcar);
//%newcar = %client.tumbleVehicle;
%newcar.setVelocity("0 0 0");

if(!%newcar)
return;

//neutralize current velocity
%newcar.applyImpulse( %newcar.getPosition(), vectorScale(%newcar.getVelocity() * -1, %newcar.getDataBlock().mass) );

//error("player tumbling!");
%obj.canDismount = false;

if(%currentVehicle && (%currentVehicle.getDataBlock().getName() $= "skiVehicle") )
{
//%obj.client.setControlObject(%obj);
//match ski vehicle
//neutralize velocity first

%newcar.setTransform(%currentVehicle.getTransform());
%newcar.applyImpulse( %newcar.getPosition(), vectorScale(%currentVehicle.getVelocity(), %newcar.getDataBlock().mass) );
%newcar.mountObject(%obj, 0);

%currentVehicle.setTransform("0 0 -1000");
%currentVehicle.schedule(500, delete);
}
else
{
//match player
//error("transform = ",%obj.getTransform());
%newcar.setTransform(%obj.getTransform());
%newcar.applyImpulse( %newcar.getPosition(), vectorScale(%obj.getVelocity(), %newcar.getDataBlock().mass) );
//%newcar.setTransform(%obj.getTransform());

//%obj.setTransform("0 0 0 0 0 1 0");

%newcar.mountObject(%obj, 0);

//error("not skiing");
//error("transform = ",%obj.getTransform());
}

//definitely delete after 45 seconds
%newcar.schedule(45 * 1000, delete);

%newcar.schedule(2000, tumbleCheck);

%client.camera.setMode("Corpse",%obj);
%client.setControlObject(%client.camera);

//remove %player.istumbling after a we stop
//schedule(%time, %obj, stopTumble, %obj);


//%nextTumbleVehicle = new WheeledVehicle()
//{
// dataBlock = deathVehicle;
// client = %client;
// initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
//};
//%obj.client.tumbleVehicle = %nextTumbleVehicle;
//%nextTumbleVehicle.setTransform("0 0 -90");



//%newcar.schedule(%time, unmountobject, %obj);
//%obj.schedule(%time, setcontrolobject, 0);
//%newcar.schedule(%time + 250, setTransform, "0 0 -90");
}
activatePackage(TumbleOnFall);
--- End code ---
Headcrab Zombie:
1. onCollision is only called when you hit something, so you'll tumble when you hit something if your falling faster than 20, not when you get to 20
2. I don't remember exactly what %obj is in this function, but I know %this would definitely be the player object, so try changing all %obj to %this
3. Did you change anything with the tumble function? If not, you don't need it there.
Audax:

--- Code: ---package TumbleOnFall
{
function Player::onCollision(%this,%obj,%col,%pos,%speed)
{
if(getWord(%this.onCollision(),2) <= -20)
   tumble(%this,2500);
Parent::onCollision(%this,%obj,%col,%pos,%speed);
}
};
activatePackage(TumbleOnFall);
--- End code ---

Even when I hit the ground falling faster than -20 I did not tumble. There are no more syntax errors, I'm just not tumbling.


--- Quote from: Headcrab Zombie on June 13, 2010, 11:02:57 AM ---1. onCollision is only called when you hit something, so you'll tumble when you hit something if your falling faster than 20, not when you get to 20

--- End quote ---

That's another problem, I need to find something that would work like 'isFalling'. So when the player is falling, once their velocity is less than or equal to -20, they tumble.
Headcrab Zombie:
You could try packaging ShapeBase::PlayThread, and then checking if the animation played is 'fall'.
But I don't know if you can adjust the speed at which that animation automatically plays.

That's the only other thing I could think of, if that won't work you'd need to do a repeating function that checks all clients like I suggested earlier.
Navigation
Message Index
Previous page

Go to full version