Page 1 of 1
small scripting issue
Posted: Wed Mar 24, 2004 2:45 pm
by M&M
i posted this b4 in the few quick and easy questions in the mapping forum ,but i feel it should be better answered here
i have this code so far
Code: Select all
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?
Posted: Wed Mar 24, 2004 4:29 pm
by bdbodger
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
key:setthread
value:Alliesweaponsroomthread
when someone uses the trigger the thread is run
Code: Select all
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
Posted: Wed Mar 24, 2004 4:37 pm
by M&M
darn ,u posted a few seconds just after i clicked the upload button on my beta map .i guess ill fix it in the next version

.
1st of all i added the else part after in the if statement after it failed without it .b4 it was
Code: Select all
wait 1
level.countdown--
if (level.countdown == 0)
{
goto alliesclosedoor
}
but the door doesnt close after 5 seconds.
however the switch works on and off.
ill try that and c what comes up ,although i have a sneaking sensation that it wont work

.
Posted: Wed Mar 24, 2004 4:53 pm
by bdbodger
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 .
Posted: Wed Mar 24, 2004 5:02 pm
by M&M
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

Posted: Thu Mar 25, 2004 4:42 am
by bdbodger
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
the .map is in the pak
Posted: Thu Mar 25, 2004 3:23 pm
by M&M
oh ,i forgot 2 use a func_door

.i was using this on the script object .
tnx alot 4 ur persistence

Posted: Fri Mar 26, 2004 1:05 pm
by bdbodger
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 .