level.countdown = 5
Alliesweaponsroomthread:
$alliesweaponsroom_trigger waittill trigger //waits for someone to hit the use key
$alliesweaponsroom_switch anim turnon
$alliesweaponsroom_switch playsound alarm_switch
$alliesweaponsroom_door movenorth 84
$alliesweaponsroom_door waitmove
wait 1
level.countdown--
if (level.countdown == 0)
{
goto alliesclosedoor
}
else
{
$alliesweaponsroom_trigger waittill trigger
}
$alliesweaponsroom_trigger waittill trigger //<-- waits for someone to hit the use key again.
goto alliesclosedoor
alliesclosedoor:
$alliesweaponsroom_switch anim turnoff
$alliesweaponsroom_switch playsound alarm_switch
$alliesweaponsroom_door movesouth 84
$alliesweaponsroom_door waitmove
goto Alliesweaponsroomthread
obviously something is wrong with it ,my aim is 2 make a certain script object (door) open by a switch and close by the same switch ,but if unclosed 4 a certain period of time (5 is an example) it closes automatically and sets back 2 the original thread 4 reusing .
so can any1 help me with it?
I think useing a targeted func_door is better
for one thing the trigger waiting like that won't work
the else statement stops the countdown and the countdown part
needs to be in a loop . Try useing the key:setthead on the trigger
like this
level.dooropen = 0
Alliesweaponsroomthread:
if(level.dooropen ==1) // thread is already running so set level.dooropen to 0 to stop the thread and close door
{
level.dooropen = 0
end
}
else
{
level.dooropen = 1
local.countdown = 5
while(level.doormoveing == 1)// makes thread wait if door is not fully open or closed yet
waitframe
level.doormoveing = 1
$alliesweaponsroom_switch anim turnon
$alliesweaponsroom_switch playsound alarm_switch
$alliesweaponsroom_door movenorth 84
$alliesweaponsroom_door waitmove
level.doormoveing = 0
while(level.dooropen ==1) // counter or second press of use key exits loop and door closes
{
wait 1
local.countdown--
if (local.countdown == 0)
level.dooropen = 0
}
while(level.doormoveing == 1)// makes thread wait if door is not fully open or closed yet
waitframe
level.doormoveing = 1
$alliesweaponsroom_switch anim turnoff
$alliesweaponsroom_switch playsound alarm_switch
$alliesweaponsroom_door movesouth 84
$alliesweaponsroom_door waitmove
level.doormoveing = 0
end
Well give the stuff in my post a try like I said in your script the countdown needs to be in a loop for it to countdown and the else statement stopped the thread and waited for a second keypress then the thread waits for a third key press and then closes the door . With my post you need only 1 thread .
hmm!!!
i have 2 doors ,one is the allied version u saw and fixed,and the other is an axis door .when i replaced my script 4 the allies door with urs neither doors opened although i didnt touch the axis thread .
note i would like 2 do the same thing 2 the axis,but i figured i could do it myself once i go tthe allied working.
edit:found out what the problem was.the script wasnt being activated ,apparently u missed a } in the script and u put a lowercase letter instead of an uppercase one in my script .ive corrected that and now the script works .but the door is always open and closes 4 like a second then opens again .the switch is untriggerable and it keeps flipping on and off everytime the door moves .so in short it doesnt work .
hope u can see what i can do 2 make it work .tnx 4 ur effort so far
did you use setthread on the trigger ? you don't call this thread in your script it is called by the trigger when you use setthread as a key on the trigger .
key:setthread
value:Alliesweaponsroomthread
also you can add a wait key to the trigger to keep it from fireing too fast .
I made a test map for you to look at to see that it works download it an have a look weapon_room.pk3
I you download the test map you will see that it it a script object because that is what you wanted . If you make a func_door and set the targeted check box it will open ok if you target it from the trigger_use . It will also close after a short time with no scripting unless you set some of the other options .