lever triggered ONLY by allies and once
Moderator: Moderators
lever triggered ONLY by allies and once
Wat scripting do i need to do, so that a lever with a trigger_use can ONLY be triggered once and ONLE by allies??? Thanks for your help (probs obvious)
How about this to get you started, but keep in mind there is more than one way of doing it:
Code: Select all
thread alliesLever:
// Controls the checking loop.
local.triggered = 0
// While the trigger hasn't been used by allies, keep checking.
while (!local.triggered) {
// Wait till it's used.
$trigger waittill trigger
// Find out who used it.
local.player = param.other
// Check what team they're on.
if (local.player.dmteam == "allies") {
// Allied player used the trigger, end the check loop.
local.triggered = 1
// Make the lever do something.
}
}
end
thread alliesLever:
$trigger waittill trigger
// Find out who used it.
local.player = parm.other
// Check what team they're on.
if (local.player.dmteam == "allies")
{
do whatever
// Make the lever do something.
}
else
{
goto thread alliesLever
}
end
I wouldnt bother with global variables in this case, if an axis triggers it, nothing happens and it resets, if an ally triggers it, the thread is done. Either would work tho.
$trigger waittill trigger
// Find out who used it.
local.player = parm.other
// Check what team they're on.
if (local.player.dmteam == "allies")
{
do whatever
// Make the lever do something.
}
else
{
goto thread alliesLever
}
end
I wouldnt bother with global variables in this case, if an axis triggers it, nothing happens and it resets, if an ally triggers it, the thread is done. Either would work tho.
When I am king, you will be first against the wall~


eh? so I cant read ~
anyway, id prefer not using any variables~~~ Cause moh scripting is stupid --
but either way works
I dont particularly favor while loops either, in any language. (not that i dont use them, ive just had more bugs from them then anything else)
anyway, id prefer not using any variables~~~ Cause moh scripting is stupid --
but either way works
I dont particularly favor while loops either, in any language. (not that i dont use them, ive just had more bugs from them then anything else)
When I am king, you will be first against the wall~


If i had been awake and seen that they were local variables I probably wouldnt have bothered to post an alternative =) I dont hate while loops that much. I do think they are a common culprit or inneffieceny and occasionaly problems, but that doesnt really matter in this context(and in this game much at all - who cares if a loop doesnt terminate, no one is going ot notice a few computations while playing moh). I do use alot of while loops with checks inside them, but I try and stay away from some of the other neverending while loops(although sometimes it proves impossible)
I dont see any problem with goto tho =p In this case it does the same thing as the while loop, and ive never seen problems with threads when you run them over and over, thats the point of them, the while loop saves effort if there is alot to repeat outside the loop... but not much else.
I dont see any problem with goto tho =p In this case it does the same thing as the while loop, and ive never seen problems with threads when you run them over and over, thats the point of them, the while loop saves effort if there is alot to repeat outside the loop... but not much else.
When I am king, you will be first against the wall~


shorter
I bet I can make it even shorter.
Give the trigger a setthread for "allied_lever"--using that, you don't need waittill.
allied_lever:
local.player = parm.other
if (local.player.dmteam != "allies")
end
$trigger remove
//do whatever
end
Ha ha!
Give the trigger a setthread for "allied_lever"--using that, you don't need waittill.
allied_lever:
local.player = parm.other
if (local.player.dmteam != "allies")
end
$trigger remove
//do whatever
end
Ha ha!
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
- HDL_CinC_Dragon
- Brigadier General
- Posts: 574
- Joined: Mon Dec 22, 2003 8:32 pm



