Trigger Scripts
What's a trigger script, you might be wondering? By a "trigger script", I mean those little green "S" tiles visible in AdvanceMap's Events tab. When your player steps on these, the script it contains will run. I'll show you how to set these up step by step!
First of all, you'll have to choose a
variable to use. For example purposes, we'll be using
var 0x4050. I'll draw your attention to the "Var value" box, outlined in red below:
Currently, the value is set to
0. This means that the script will only run while var 4050 has a value of 0. Let's say we want the script to run only once:
Code:
#dynamic 0x800000
#org @main
lock
msgbox @msg 0x6
setvar 0x4050 0x1
release
end
#org @msg
= This is a trigger.
In this script, we've set var 0x4050's value to
1. Since the variable's value is no longer
0, the script will not run again.
If you want your trigger script to repeat itself until the variable is set somewhere else in another script, you can do this too. Maybe you want it to act as a roadblock until your player has completed a certain event.
Code:
#dynamic 0x800000
#org @main
lock
msgbox @msg 0x6
applymovement 0xff @stepdown
waitmovement 0x0
setvar 0x4050 0x0
release
end
#org @msg
= This is a trigger.
#org @stepdown
#raw 0x08
#raw 0xfe
Since this time we're keeping the variable as
0, that means this script will run
every time the player steps on the "S" tile until the variable has a new value other than 0.