How to add varaiables to my script ?
-
How to chceck value of this varaiable ?
-
Is there a way to use ‘if’ for expamle:
if (variable_a == 1)
{
tank go_to_position_4 :P
}
else
{
tank go_to_position_4b
}
How to add varaiables to my script ?
How to chceck value of this varaiable ?
Is there a way to use ‘if’ for expamle:
if (variable_a == 1)
{
tank go_to_position_4 :P
}
else
{
tank go_to_position_4b
}
To my knowledge you can’t use variables like that. You have to use accum’s
So, you can do something like: (where you set accum 0 somewhere else in the script
accum 0 trigger_if_equal 1 tank position_a
accum 0 trigger_if_equal 2 tank position_b
For variables, you have to use the ‘accum’ commands. You cannot name the variables, they are called ‘accum 1’, ‘accum 2’ and so on.
You would also use the accum commands for that script. There are abort_if_equal and abort_if_notequal accum commands. For example:
tank_script
{
trigger choose_path
{
trigger tank_script if
trigger tank go_to_position_4b
}
triggger if
{
accum 1 abort_if_not_equal 1
resetscript
trigger tank go_to_position_4
}
}
An explanation of how this works:[ul][li]It starts at the ‘trigger choose_path’ line. You would tell it to do this with a target_script_trigger object or with a trigger script command.
[/li][li]It then goes to the next line, and sees that this is a trigger line.
[/li][li]This (‘trigger tank_script if’) tells it to look in the ‘tank_script’ block (the one shown here) for a ‘trigger if’ line.
[/li][li]It then jumps to the ‘trigger if’ line.
[/li][li]Continuing from there, the next line is ‘accum 1 abort_if_not_equal 4’. This tells it that if accum 1 (our variable, you called it ‘variable_a’) is not equal to 1 it should return to where the ‘trigger tank_script if’ line was, and continue where it left off.[/ul]At this point, the script can go two ways.
[/li]First, if accum 1 is 1, the script continues from the line after the ‘abort_if_not_equal’ line:[ul][li]The next line is ‘resetscript’. This tells it that once the script reader reaches the end of this ‘block’ (the next closing brace, ‘}’), it should not return to after the ‘trigger tank_script if’ line. If we did not do this, your tank would try to go in two directions at once. 
[/li][li]Finally, ‘trigger tank go_to_position_4’ tells it to jump to whatever you have to move the tank to ‘position 4’. This is an entire tutorial on its own, so I won’t go in to it here.
[/li][li]The closing brace ‘}’ immediately following this tells the script reader that that is the end of the script, and that it should stop reading.[/ul]Alternitively, if accum 1 is not 1, this happens:[ul][*]The script reader returns to the ‘trigger tank_script if’ line, and continues from there.
[/li][li]It is then told, in ‘trigger tank go_to_position_4b’, to do whatever necessary to move the tank to ‘position 4b’. Once again, very complicated, and I won’t go into the details.
[/li][li]And then the closing brace. As I said above, this tells it to stop.[/ul]
[/li]Hope this helps. 
ok thanks
and how to change this ‘accum’ value to 1 or 0 from other block ?
fo expamle:
// ============================================================================
// Barrier #1
// ============================================================================
barrier_script
{
spawn
{
wait 200
constructible_class 2
accum 1 set 0 // ?????
trigger self startup
}
buildstart final
{
accum 1 set 0 // ????
}
built final
{
setstate barrier_target default
setstate barrier_materials invisible
accum 1 set 1 // :/ ???
wm_announce "TEXT"
}
decayed final
{
accum 1 set 1 // ?????????
trigger self startup
}
death
{
accum 1 set 0 // ??????? :|
trigger self startup
wm_announce "TEXT_death"
setstate barrier_materials default
}
trigger startup
{
setstate barrier_target invisible
setstate barrier_materials default
}
}
tank_script
{
trigger choose_path
{
trigger tank_script if
trigger tank go_to_position_4b
}
triggger if
{
accum 1 abort_if_not_equal 1
resetscript
trigger tank go_to_position_4
}
}
must I add block which will be checking accum value ?
Accums are local to each block, so you must do all of your abort_if_whatevers in the one main block.
Alternatively, replace ‘accum’ with ‘globalaccum’. It’s the same, but it works across all the blocks in your script.