DocsMegalithGame modes

Limits and safety

Limits and safety

The language's limits are in the Megalith guide. In short: a source file holds 1 MiB and a script 2 MiB with its source, an event takes at most 65,536 steps in a game of up to 16 players and more in bigger games, and a mode has 32 HUD widgets and 2,048 objects of its own at once.

If a script fails while a game runs, such as a division by zero or a call out of range, the game goes on without it for the rest of the game: its sizes, HUD and rules go, and the host's log says why and at which line and column of the script. Fix the file and start a new game.

What a script can't do

A script can only change gameplay. The language has no way to reach files, the network or other programs, and it runs inside the game's own interpreter, never as code on your PC. So a mode from someone you don't know can change how your game plays, and nothing more:

  • Only the host runs it. Players receive what it does through the game, never the script. A click or a key press sends the host only which one it was.
  • Every event has a step limit, so no script can run forever or hold up the game.
  • A script names only what the game offers: its own calls, and the map's own objects and sounds by path. No addresses, no other game data.
  • Text a script shows is plain text.
  • The Megalith console, which runs lines of Megalith in a running game, is off by default and works only while the host plays on their own PC alone: never in a game other players can join.
  • The game checks each file when it lists it, the parts that never run included, and leaves out one that asks for anything it can't play.

A mode can still be unfair within those limits: try one before you host it for others.

Older JSON modes

Modes used to be written in JSON. Older JSON modes keep working: the game lists and plays them as before, on the host's own interpreter, and mode-check reads them. New modes are written in Megalith, which does all they did and much more.