Scripting help
Families
One script that many characters share, and words for game and level scripts to reach them all at once.
A family is a script that many characters share. Every character in the family runs the family's script as well as its own. Write how ghosts float and fade once, put ten ghosts in the Ghosts family, and they all do it.
A family works like a pattern the characters are made from. A family is never put on the map by itself: only characters are, and each one takes what the family has. Anything a character writes for itself takes the place of the family's version of the same thing.
A family's name works like an ID too. The game script and level scripts can use it to reach every character in the family at once, like all {Ghosts} attack.
Making a family
A family is one script that many characters share, like every ghost floating the same way. To write one, open Game settings and press Families in the Scripts card. The family's script opens in the script window, with its name and buttons at the top. A game with no family yet gets one called Family 1 to start with.
| Button | What it does |
|---|---|
| The Family list | Opens another family's script, or makes a new one with New family…. |
| Rename | Gives the family a new name. |
| Delete | Deletes the family and its script. Characters in it keep their own scripts. |
| Share as addon | Makes it a Family addon, so your other games can use it too. |
A family's name follows the same rules as an ID (see The rules for an ID). It can't be a name that a family, a thing, a level or a world already has.
Putting characters in a family
Open a character's script. The Family list at the top says which family it's in. Pick one, and the character joins it straight away. Edit family opens the family's own script.
The family's lines show above the character's own, greyed out, in a box that folds away. They run first. The character's script can use the family's functions and @variables as if they were its own.
Doors, springs and other things with an ID can be in a family too. Their Family list is under the ID box in Object settings, and you can pick several things at once. The game script and level scripts reach them by the family's name. In a Platformer, they can also run a script of their own, and the family's script with it: see Objects.
What a character keeps of its own
The family's script and the character's own run together. When both say something about the same thing, the character's own wins.
| Both have | What happens |
|---|---|
A my @speed is … line | The character's value is used, in the family's lines too. One ghost can be faster than the rest. |
| A function with the same name | The character's own is used, even where the family's script uses it. |
A rule for the same thing, like two when I start | The character's rule is used, and the family's isn't. Add trigger my family to run both. |
| Other rules | Each one works as it would in one script. |
A secret learn to … function in the family | Only the family's script can use it. |
A step the character can't do, like patrol for a villager | That step is skipped for that character. |
Doing the family's steps too
When a character has its own rule for the same thing as its family, only the character's rule runs. To run the family's steps as well, put trigger my family in the character's rule. The family's steps run right there, and then the rest of the character's rule carries on.
This ghost says "Boo!" when it starts, then does whatever the family does when it starts.
when I start
say "Boo!"
trigger my familyPut trigger my family first to run the family's steps before your own, or last to run them after. It only goes inside a when rule. When the family has no rule for the same thing, it does nothing, and a tip says so.
An example
This is the Floating ghost family's script. Every ghost in it starts half see-through, patrols, and can use roll.
my @speed is 0.5
my @opacity is 50
my opacity is @opacity
when I start
patrol
learn to roll
@dice is a random number from 1 to 100
give back @dice
endThis is one ghost's own script. Its my @opacity is 80 line makes it more solid than the others, and it fades in and out every 3 seconds.
my @opacity is 80
every 3 seconds
if roll is greater than 50
my opacity is 0 slowly
patrol for 2 seconds
my opacity is @opacity slowlyFamilies in game and level scripts
The game script and level scripts reach a whole family by its name. A family's name never goes on its own in front of a step: {Ghosts} attack gets a red note that offers all {Ghosts} attack instead.
{Heroes} is a family that every game has: every hero. all {Heroes} freeze tells them all, and when any {Heroes} jumps happens for each one. Unlike other families, it reaches heroes wherever they are, not just in the hero's level. See The hero script.
{Enemies} is a family every game has too: every enemy in the hero's level, with a boss counted once, however many parts it has. when all {Enemies} are beaten happens when the last one goes, when any {Enemies} is beaten for each one, the remaining {Enemies} counts the ones still standing, and all {Enemies} attack tells them all.
| Write | What it means |
|---|---|
when any {Ghosts} is beaten | Each time one of them is beaten. It works with every when line that takes an ID. |
when all {Ghosts} are beaten | When the last one in the hero's level is beaten. |
all {Ghosts} attack | Tells every one of them in the hero's level. The script waits until they're all done. |
all {Ghosts} attack and go | Tells them all, and the script carries on straight away. |
hide all {Ghosts} | Does the step to every one of them in the hero's level. It works with every step that takes an ID. |
if {Boo} is in {Ghosts} | The thing is in the family. |
@ghosts is {Ghosts} | Remembers them all as a list. See Remembering things. |
if the remaining {Ghosts} is under 3 | Counts the ones still standing in the hero's level. Also is 0, is over 2, is at least 4 and more. |
This level script opens the castle gate once every ghost is gone:
Using a family in other games
Share as addon in the family's bar makes it a Family addon. A character in a family that you share as an addon brings its family along. When you change the family in one game and press Update addon, your other games that have it show Update ready, and change only when you press Take update. See Families in the Addons help.

