vector origin, pos,velocity;
float weight,mass,weight_max,move_fac;
void lower(entity E)
{
if (E.getFloatKey("weighted")==1)
{
E.setKey("weighted","0");
mass=E.getFloatKey("mass");
weight-=mass;
pos=origin;
if (weight<weight_max)
{
pos_z-=move_fac*weight;
}
else
{
pos_z-=move_fac*weight_max;
}
$platform.moveToPos(pos);
}
}
void raise(entity E)
{
if ($player1.heldEntity()!=E)
{
velocity=E.getLinearVelocity(); //get the velocity of the entity that caused the trigger
}
else
{
velocity_z=0;
}
if (($player1.heldEntity()!=E || $player1.getFloatKey("weighted")==1) && velocity_z==0) // enhanced condition
{
if (E.getFloatKey("weighted")==0)
{
E.setKey("weighted","1");
mass=E.getFloatKey("mass");
weight+=mass;
pos=origin;
if (weight<weight_max)
{
pos_z-=move_fac*weight;
}
else
{
pos_z-=move_fac*weight_max;
}
$platform.moveToPos(pos);
}
}
else {
lower(E);
}
}
void main()
{
origin=$platform.getOrigin();
move_fac=0.25;
weight_max=48/move_fac;
}
changed method raise(): - added nev vector-variable velocity - see comments for functionality enhanced condition the method checks, wether the entity moves vertically, if it does not it is weighted, else the method lower is called if it was weighted before, the mass will be subtracted and the platform moves up e.g. if the player stands on the platform it goes down, if he jumps it goes up