Page 1 of 1

Switch Operated Door

Posted: Sat Sep 13, 2003 12:14 pm
by CommandoKiller
I know how to open doors using a switch, and all that works fine. But I want to know how to make the door continually move the direction i say until i tell it to stop by using another switch. like what would i put in the script? i know the stuff like

movenorth 60

and so on. but what do i put instead of 60 to make the door never stop going north?

Posted: Sat Sep 13, 2003 2:04 pm
by bdbodger
well I can't think why you want to do that but you can do this .

I assume your switch is a trigger_use and sets say it has the key: setthread and value: door_move

level.doormover=0


door_move:
if(level.doormover==0)
{
level.doormover=1
thread do_doormove
}
else
level.doormover=0
end

do_doormove:
while(level.doormover==1)
{
$door movenorth 10 // 10 units per second
$door move
wait 1
}
end

now if you want to rotate it that is different . If you do this what do you think is going to happen if you don't stop it I guess it will stop when it hits a solid object .

Posted: Sat Sep 13, 2003 2:55 pm
by jv_map
If you issued the physics_on command before it will stop (or even bounce) when it hits a solid wall. Otherwise it will simply move through anything until you use the stop command.

Posted: Sun Sep 14, 2003 5:27 pm
by CommandoKiller
ok that works good. now, i want the door to be able to move in any direction by the pressing of a switch. So how would i stop the door from moving one direction and make it move another?

Posted: Mon Sep 15, 2003 5:50 am
by bdbodger
Well in the above post if you use the same switch again it stops the door
you could do the same for all the directions or if a change in direction stops the previous direction move you can do that too . There is lots of ways to do it one way might be this .

Trigger use // north switch
key: setthread value: door_move
key: #set value: 1

Trigger use // south switch
key: setthread value:door_move
key: #set value: 2

Trigger use // east switch
key: setthread value:door_move
key: #set value: 3

Trigger use // west switch
key: setthread value:door_move
key: #set value: 4


for(local.i=1;local.i<=4;local.i++)
{
level.doormover[local.i] = 0
}
end


door_move:
if(level.doormover[self.set]==0)
{
level.doormover[self.set]=1
self thread do_doormove
}
else
level.doormover[self.set]=0
end

do_doormove:
while(level.doormover[self.set]==1)
{
switch (self.set)
{
case 1:
$door movenorth 10 // 10 units per second
$door move
wait 1
break
case 2:
$door movesouth 10 // 10 units per second
$door move
wait 1
break
case 3:
$door moveeast 10 // 10 units per second
$door move
wait 1
break
case 4:
$door movewest 10 // 10 units per second
$door move
wait 1
break
}
}

end
if you want the door to stop when you change directions make the case statements like this
case 1:
level.doormover[2] = 0
level.doormover[3] = 0
level.doormover[4] = 0
$door movenorth 10 // 10 units per second
$door move
wait 1
break