Learn: Eventing
Contents
Constants
Constants can be used to specify certain values in code without having to remember the number associated to it. They can be used with the OR bitwise "|" character to achieve other end values.
There are 3 levels of constants that JuraviS uses when compiling events. It will try to match a string that is used as an event instruction parameter with the following lists:
- The constants defined inside the event file;
- The constants defined in the current project directory's constants.json;
- The constants defined in the default project directory' constants.json.
There are also @constants, which are specifically used for the Message IDs used inside {10} DisplayMessage/{51} ChangeDialog instructions.
Constants in the Event file
#Const Start Enemy_Knight_A: 0x80, Enemy_Wizard: 0x81, Excalibur: 0x23 #Const End
- The constant block must start with "#Const Start" and end with "#Const End" (both on their own line).
- Any constant must use ":" as the association character and commas to separate each entry
- Values must be either in hexadecimal (i.e. preceded by "0x") or in decimal format
Constants in constants.json
{ [...] UnitID: { UID_Temp_A: 0x80, UID_Temp_B: 0x81, UID_Temp_C: 0x82, UID_Temp_D: 0x83, UID_Temp_E: 0x84 }, [...] }
Each constant is stored inside of another named object. This object represents a class of data used exclusively by the decompiler to determine which flags to convert a number to. Constants themselves can be accessed globally without restrictions. The format used here is JSON5.
Message ID @Constants
DisplayMessage(x10,x61,@NGPlus_Explanation,x01,x00,x09,+00000,+00000,+00000,x00) DisplayMessage(x10,x62,@Main_Options,x01,x00,x09,+00000,+00000,+00000,x00) WaitForInstruction(x01,x00) [...] EventEnd() @NGPlus_Explanation: {font:00} You may spend your completion points{br} in various ways to enhance your{br} characters or even recruit new ones!{br} {br} Whenever you are ready, you may start{br} the game over with {font:08}NG+{font:00} or return to{br} the world map with {font:08}Continue+{font:00}.{end} @Main_Options: {FB}Spend my points{br} New Game+{br} Continue+{br} (Ignore) Regular Ending{FC}{close}
At the bottom of the event file where the text of the event is located, you can place a @Constant to automatically generate a callable Message ID for you to use inside of your event instructions, particularly {10} DisplayMessage and {51} ChangeDialog. This allows you to reorder your messages without worry.
- The Message ID constant must start with, and be defined with an "@";
- When defined, the constant name must be on its own line, optionally followed by ":".