-
Notifications
You must be signed in to change notification settings - Fork 56
Overworld Scripting ‐ Flags
Click to return to the main scripting page
A Flag
is a value in your save file that answers a single yes-or-no question about your current progress.
- Have you picked up the item?
- Have you collected the badge?
- Have you answered the riddle?
Another such question is "have you beat this trainer?" but since there are so many trainers, they get their own set of flags.
You can see the list of all flags and what they're used for in the vanilla games within the Help menu.
In this example, you want an NPC to give you an item, but only once. So the outline for the script might look like:
if the flag is set, goto bottom
"Here you go!"
add item
set flag
bottom:
"Enjoy!"
Here's what that might look like as an actual script:
Things to note:
- The flag is checked at the beginning of the script so you can skip to the end if the script has run before.
- The flag is set as you get the item, since that's what we want to track.
- The script still needs all the standard
lock
/faceplayer
/release
/end
commands that you'd expect.
Each object event can be hidden or shown using a flag.
When the flag is 'set', the NPC will be hidden. When the flag is 'clear', the NPC will be shown. This is how items in the overworld work: whenever you pick them up, their flag gets changed to 'set'. If you later clear the flag in another script, it'll make the item show again.
While writing a command that uses flags, a button will appear next to your cursor that lets you choose an unused flag.
While the button is showing, you can also press Ctrl+U ("U" for "Unused").
Flags 0x0001 through 0x001F get reset when you switch maps. This makes the flags good for events that you want to repeat, like a trainer that you can re-battle every time you re-enter the map, or a breakable rock that you want to come back.
Any time you see a flag used in a script, you can right-click the flag to get an option to find where that flag is used in the game.
The results will include:
- Any command that uses that flag, such as
setflag
,clearflag
, orif.flag.set.goto
. - Any object that uses that flag to show/hide itself.