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.
- Prefer events to polling. Use
onPlayerTouchsMe,onPlayerEnters, and similar events instead of checking a condition in a timer loop. - 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
setTimeragain. - Use
temp.for locals andthis.for object state. A name without a prefix that is not atemp.variable or a built-in field is a script-global variable, which is easy to leak between events by accident. Checked byW-SCRIPT-GLOBAL. - 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 everytriggerserverargument. - Keep the client for presentation. Do pictures, windows, sound, and input after
//#CLIENTSIDE. - Mark only the outside interface
public. Leave helpers as plain functions, or mark themprivatefor readability. Other objects cannot call them either way. - Avoid names that collide with the engine. Do not call a custom method
insert,delete, orremove, and do not uselevel,head, ordiras a field or parameter name. Checked byW-ARRAY-METHOD-NAMEandW-RESERVED-NAME. - Test arrays and objects explicitly. Write
if (temp.headers != NULL), notif (temp.headers). Checked byW-ARRAY-TRUTHINESS. - Pass SQL values as parameters. Put
?in the statement and the values in the last argument ofrequestsql. Do not build SQL text from player input. Checked byW-SQL-ESCAPE. - Do not log secrets. Never
echoauthorization headers or private response data. - Check lookups. Test the result of
findnpc,findplayer, and similar functions fornullbefore you use it. Checked byW-UNCHECKED-LOOKUP.
An example that follows them
Section titled “An example that follows them”// 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.}
//#CLIENTSIDEfunction onActionClientSide(cmd) { if (cmd == "gave") { player.chat = "Done"; }}Engine version 0.1.0. Built 2026-11-18.