Give a common event inputs it reads like variables, and keep text and lists in variables, not just numbers.
Common Event Parameters, Text and List Variables
A common event is a reusable list of commands. Until now it ran the same way every time. With parameters you hand it values each time you call it — "greet this person", "give this many coins", "show these three choices" — so one common event does the work of many. Variables can also hold text and lists, not only numbers.
Where you'll find it#
| What | Where |
|---|---|
| Declare a common event's parameters | Database → Common Events (or Events → Common Events in the map editor) → pick the event → Parameters above the command list → Add parameter |
| Pass values when you call it | In any event's command list: Call Common Event → pick the event → one row per parameter |
| Make a text or list variable | Database → Variables → Text or List button, or pick the type on a variable |
| Change a text or list variable | Control Variables → Holds → Text or List |
| Test a text or list variable | Conditional Branch → tab 4 → Text Var or List Var |
Setting it up#
- Open Common Events and pick (or add) the common event.
- Under Parameters, press Add parameter. Give it a Name (letters, digits and underscores, starting with a letter, for example reward_gold), a Type and a Default.
- Use the parameter in the commands below: type param.reward_gold in a Script expression, or \A[who] inside message text. A Control Variables with Holds → Text can read it through Parameter.
- Press Save in the Common Events window.
- In an event, add Call Common Event, pick the common event. A row appears for each parameter. Choose Use default, Value, Variable, Script or (inside another common event) Parameter for each.
- Publish your changes, then run the event with Dry Run or in game. Dry Run lists the values each call was given.
Parameter types#
| Type | Holds | How to read it |
|---|---|---|
| Number | A number | param.name in an expression |
| Text | A line of text | param.name in an expression, \A[name] in message text |
| Switch (on/off) | ON or OFF | param.name in an expression (true or false) |
| List | A list of numbers and text | listLength("name"), listGet("name", 0), listHas("name", "x") in an expression, or the Parameter choices in Control Variables and Conditional Branch |
What a call passes#
| Choice | Meaning |
|---|---|
| Use default | The default you declared |
| Value | A number, text, ON/OFF or a list typed right there (for a list, type items separated by commas) |
| Variable | The current value of a variable (a switch for a Switch parameter) |
| Script | The result of an expression |
| Parameter | One of the parameters of the common event that makes the call, to pass it along |
Text and list variables#
| Command | What you can do |
|---|---|
| Control Variables → Holds → Text | Set a variable to text, Append to it, or Clear it. The text may use \V[n] and \A[name] |
| Control Variables → Holds → List | Set (items separated by commas), Add item, Change item at a position, Remove item at a position, Clear. Positions start at 0 |
| Control Variables → Holds → Number → Length of list | Store how many items a list has into a number variable |
| Conditional Branch → Text Var | is exactly, is not, contains, starts with, ends with, is empty, is not empty |
| Conditional Branch → List Var | holds, does not hold, is empty, is not empty, has a number of items |
| Message text | \V[n] shows a text variable; a list shows as its items separated by commas |
| Expressions | textVar(n) reads a text variable; listLength(n), listGet(n, i) and listHas(n, x) read a list variable |
Text and list variables are saved and shared exactly where number variables are (per player, global, self, party, guild or alliance, following the variable's scope). Variables you made before stay numbers.
Fields#
| Field | What it does |
|---|---|
| Name | What the parameter is called inside the common event. Must be unique in that event and cannot be a built-in word such as gold, level or hp |
| Type | Number, Text, Switch or List |
| Default | The value used when a call passes nothing |
| Holds (Control Variables) | Whether the variables you change hold a number, text or a list |
| Position | Which list item a Change or Remove acts on, written as a number or a small expression. 0 is the first item |
Gotchas#
- A common event only sees its own parameters. If it calls another common event, that one gets its own values, and nothing you change in it affects the first. A common event that declares no parameters cannot read the caller's.
- A parameter lasts only while the common event runs. To keep a value, copy it into a variable with Control Variables.
- Renaming or deleting a parameter does not rewrite the calls that use it: open the Call Common Event and the row shows a warning with a Remove button for values the event no longer declares.
- Text is limited to 1000 characters and a list to 200 items; more is cut off.
- A text variable used where a number is expected counts as the number it spells (or 0). A list counts as how many items it has.
- A Conditional Branch on a text or list always runs on the server, so an event that uses one cannot be set to run on the player's device.
- Calls nest up to the same depth limit as before. A call that goes too deep stops the event.
- Needs no feature flag: it is part of the event system.