Skip to content

Authoring conventions

These rules apply to the sample world, the examples in this documentation, and the built-in classes. Where a rule can be checked by a tool, the compiler or the editor warns about it. Follow them in your own scripts too.

  1. Prefer events to polling. Use onPlayerTouchsMe, onPlayerEnters, and similar events instead of checking a condition in a timer loop.
  2. Use the slowest timer that works. Use 1 second for status updates, and 0.05 seconds only for animation and movement. Stop a loop by not calling setTimer again.
  3. Use temp. for locals and this. for object state. A name without a prefix that is not a temp. variable or a built-in field is a script-global variable, which is easy to leak between events by accident. Checked by W-SCRIPT-GLOBAL.
  4. Keep the server in charge. Do game rules, inventory, and stats on the server side. Write player data that the client may not change to clientr.. Validate every triggerserver argument.
  5. Keep the client for presentation. Do pictures, windows, sound, and input after //#CLIENTSIDE.
  6. Mark only the outside interface public. Leave helpers as plain functions, or mark them private for readability. Other objects cannot call them either way.
  7. Avoid names that collide with the engine. Do not call a custom method insert, delete, or remove, and do not use level, head, or dir as a field or parameter name. Checked by W-ARRAY-METHOD-NAME and W-RESERVED-NAME.
  8. Test arrays and objects explicitly. Write if (temp.headers != NULL), not if (temp.headers). Checked by W-ARRAY-TRUTHINESS.
  9. Pass SQL values as parameters. Put ? in the statement and the values in the last argument of requestsql. Do not build SQL text from player input. Checked by W-SQL-ESCAPE.
  10. Do not log secrets. Never echo authorization headers or private response data.
  11. Check lookups. Test the result of findnpc, findplayer, and similar functions for null before you use it. Checked by W-UNCHECKED-LOOKUP.
// Weapon: the server decides, the client shows. (Rules 4 and 5.)
function onActionServerSide(cmd, target, amount) {
if (cmd != "give") {
return;
}
temp.to = findplayer(target);
if (temp.to == NULL || !(amount in |1, 3|)) {
return;
}
// ...game rules here, on the server.
}
//#CLIENTSIDE
function onActionClientSide(cmd) {
if (cmd == "gave") {
player.chat = "Done";
}
}

Engine version 0.1.0. Built 2026-11-18.