elevator with rotating hatches
Posted: September 16th, 2009, 5:24 am
ok heres my problem, i have a elevator with a seperate script_brushmodel for the hatch, i can get it to rotate with script, i can get it to move in line with the elevator giving the illusion it is a part of the elevator, problem is i cant get the trigger that rotates the hatch to stay with the hatch, i have tried linkto() script and the best i can get it to do is, it all works fine ele, hatch and hatchswitch all move down together on 1st trigger press to move ele..press the move ele trigger again, it all move up no worries...but then i try trigger it a 3rd time to move down again and i get a runtime error saying, enablelinkto() already linked to entity or something...been agonising for days over this script please help...
that is my script so far, i havent included the rotate part cause it seems pointless, please dont say to use the diff ele script ie movez, because if the ele is down and someone hits the down trggier it just moves down again ie through the floor =p please help
main()
{
level.elevatormoving = false; // Elevator is not moving yet
level.elevatorfloor = 1; // Elevator starts at ground (Remember to change this if you move the elevator model to start at a different floor)
level.elevatormovespeed = 3; // Time to take, to move from ground to floor1 (floor1 to floor2 will be half of this)
level.elevatorfloor1 = -352; // Distance from ground to floor1
thread elevator1_start(); // Start thread which gets everything going
}
elevator1_start()
{
elevatormodel1 = getent ("elv1", "targetname");
hatch = getent ("elv1hatch","targetname");
elevator1up = getent ("elv1call1","targetname");
elevator1down = getent ("elv1call2","targetname");
elevator1hatchswitch = getent ("elv1hatchswitch","targetname");
elevator1up thread elevator_thinkup(); // Start thread for up trigger
elevator1down thread elevator_thinkdown(); // Start thread for down trigger
}
elevator_thinkup()
{
while (1) // Loop forever
{
self waittill ("trigger"); // Wait for someone to press use on the trigger
if (!level.elevatorMoving) // Check to see if elevator is already moving
{
thread elevator_move("up"); // Start thread to move elevator up
}
}
}
elevator_thinkdown()
{
while (1) // Loop forever
{
self waittill ("trigger"); // Wait for someone to press use on the trigger
if (!level.elevatorMoving) // Check to see if elevator is already moving
{
thread elevator_move("down"); // Start thread to move elevator down
}
}
}
elevator_move(direction)
{
elevatormodel1 = getent ("elv1", "targetname");
hatch = getent ("elv1hatch","targetname");
elevator1hatchswitch = getent ("elv1hatchswitch","targetname");
level.elevatormoving = true;
wait(1);
if (direction=="up")
{
if (level.elevatorfloor==1)
{
elevatormodel1 movez (level.elevatorfloor1,level.elevatormovespeed);
hatch movez (level.elevatorfloor1,level.elevatormovespeed);
elevator1hatchswitch enablelinkto();
elevator1hatchswitch linkto(hatch);
elevatormodel1 waittill("movedone");
level.elevatorfloor=2;
}
}
else
{
if (level.elevatorfloor==2)
{
elevatormodel1 movez (0-level.elevatorfloor1,level.elevatormovespeed);
hatch movez (0-level.elevatorfloor1,level.elevatormovespeed);
elevatormodel1 waittill("movedone");
level.elevatorfloor=1;
}
}
level.elevatormoving=false;
}
that is my script so far, i havent included the rotate part cause it seems pointless, please dont say to use the diff ele script ie movez, because if the ele is down and someone hits the down trggier it just moves down again ie through the floor =p please help