bridge_trigger1
{
spawn
{
accum 1 set 1
}
trigger lever1up
{
accum 1 abort_if_not_equal 1
trigger lever1 down
trigger lever2 down
accum 1 set 0
wait 9000
trigger bridge_trigger2 setaccum0
}
trigger setaccum1
{
accum 1 set 1
}
}
bridge_trigger2
{
spawn
{
accum 2 set 1
}
trigger lever1down
{
accum 2 abort_if_not_equal 0
trigger lever1 up
trigger lever2 up
accum 2 set 1
wait 9000
trigger bridge_trigger1 setaccum1
}
trigger setaccum0
{
accum 2 set 0
}
}
lever1
{
spawn
{
}
trigger down
{
gotomarker bridge_lever1_downpos 16 //speed of movement
trigger bridge1 open
trigger bridge2 open
}
trigger up
{
gotomarker bridge_lever1_uppos 16
trigger bridge1 close
trigger bridge2 close
}
}
lever2
{
spawn
{
}
trigger down
{
gotomarker bridge_lever2_downpos 16
}
trigger up
{
gotomarker bridge_lever2_uppos 16
}
}
bridge1
{
spawn
{
}
trigger open
{
wait 500
faceangles -50 0 0 8000
}
trigger close
{
wait 500
faceangles 0 0 0 8000
}
}
bridge2
{
spawn
{
}
trigger open
{
wait 500
faceangles 50 0 0 8000
}
trigger close
{
wait 500
faceangles 0 0 0 8000
}
}
Refer to the above code as I go over the steps of what is happening.
From your map you will have activated the func_invisible_user. This then targets
the two target_script_triggers. These entities will trigger two seperate parts
of the script code, these being bridge_trigger1 lever1up and bridge_trigger2 lever1down.
Find them in the code above.
What is happening here is that both of these will have matching accum values of
either 1 or 0. But one of the scripts will abort as they both have an
abort_if_not_equal command with different settings. In the first instance the bridge_trigger1
lever1up code will continue to run but that other will fail.
Depending on which code is still running the lever1 up & lever2 up or lever1
down & lever2 down sections of code will run. From the code you will see that
they will move the levers to new path_corner positions. The lever1 code will then
continue to activate the bridge1 and bridge2 sections of code to make the bridge
sections either rotate up or down.
The bridges have been set to take 8 seconds to move in to position. Hence looking
back in bridge_trigger1 lever1up you will see that the final section of code
says wait 9000, ie wait 9 seconds, then trigger bridge_trigger2 setaccum0. We have
to wait until the bridges have finished moving before activating this code or else the
user could disrupt the brige's motion. You could try moving this command before the
wait 9000 then keep clicking on the lever and watch what happens. This final step is
to run a small portion of code that changes the value of the accum that is stored in
bridge_trigger2. So now the accum values for both bridge_triggers have been swapped -
ie next time the levers are activated the bridge_trigger1 code will continue to run
and bridge_trigger2 code will abort. If you follow the code through for this process
you will see that now the bridges will shut.
And that is it. You may not understand it too well but I hope at least I have
given enough information to understand script_movers and scripting in general a
little more than you did to start with. If you read this again and play with
the different settings in the script file you should be able to get it all working hunkydory.
BOltyBOy
|