Page 1 of 1

lever triggered ONLY by allies and once

Posted: Mon Aug 09, 2004 5:19 pm
by Dani
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)

Posted: Mon Aug 09, 2004 6:14 pm
by Angex
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


Posted: Mon Aug 09, 2004 7:02 pm
by Splaetos
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.

Posted: Tue Aug 10, 2004 12:58 pm
by Angex
Splaetos wrote:I wouldnt bother with global variables in this case
Good job I made them local :)

It all depends on whether you like using goto, personally I always try to avoid it. Although for MoH scrippting it's not too bad since there are certain limitations to using it.

Posted: Tue Aug 10, 2004 2:42 pm
by Splaetos
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)

Posted: Tue Aug 10, 2004 3:06 pm
by jv_map
I don't see anything wrong with variables :? or while loops :roll:

goto is evil though :evil: :wink:

Posted: Thu Aug 12, 2004 5:22 pm
by Dani
So if i do the one Splaetos says then i will have a trigger that only works once and can only be triggered by allies? I have chosen this one for 2 resons, 1 cos it has less script, 2 cos i know a bit bout programing and this looks better.
Thanks

Posted: Sat Aug 14, 2004 11:20 am
by Angex
Yes Splaetos' script will do what you want.

I guess that means you're in the goto camp :D

Posted: Sat Aug 14, 2004 4:42 pm
by Splaetos
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.

shorter

Posted: Sat Aug 14, 2004 11:11 pm
by tltrude
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!

Posted: Mon Aug 16, 2004 5:58 pm
by Dani
so do i just do this?:

allied_lever:
local.player = parm.other
if (local.player.dmteam != "allies")
end
$trigger remove
//The bit were the sound comes in, and the gate moves ect
end

Posted: Mon Aug 16, 2004 11:39 pm
by Bjarne BZR
jv_map wrote:goto is evil though :evil: :wink:
Word!

You should have proof that you have a very high education and lots of years of programming/scripting practice before you are allowed to use goto.

I see one use for it: Getting out of very deeply nested for statements when break would be unpractical...

goto = :evil:

:)

Posted: Thu Aug 26, 2004 11:58 pm
by HDL_CinC_Dragon
lol, a competition over goto's and loops and shorter scripts lol.