More sandbox docs

master
Ciaran Gultnieks 2014-04-05 09:13:36 +01:00
parent b34dcea746
commit 48172675db
1 changed files with 18 additions and 3 deletions

View File

@ -65,11 +65,26 @@ the player who pressed the button and keep doing that until they log off. Becaus
the code does nothing in response to an "act" event, at that point they will go
into a permanent wait (sleep) state.
### Sandbox
The code runs in a sandboxed Lua environment. Only a limited range of
functionality is available, and in particular things like loops and functions
are prohibited.
A range of standard string, table and math library functions are made
available, as well as the built in minetest vector helpers.
In addition:
* `log(msg)` - logs a v1 debug message
* `mem` - the person's memory - see under Persistence
### Persistence
The code runs in a sandboxed Lua environment which persists for as long as the
person is active. Therefore, 'local' (actually global to the sandboxed
environment) persist between calls for different events.
The sandboxed Lua environment persists for as long as the person is active.
In addition to saving setup time on each call, this allows 'local' (actually
global to the sandboxed environment) variables persist between calls for
different events.
Information that needs to persist longer than this (i.e. across deactivations
or server restarts) can be stored in the person's "memory". The 'mem' table