Minetest mod which transforms chat window into REPL.
For convenience, these variables are available in the scope of the REPL:
_
- last result_e
- last errorme
- player's object (userdata)name
- player's name
Additionally, these tables are imported:
string
table
io
math
minetest
Thus instead of string.rep
, table.insert
or minetest.set_node
, one can simply type rep
, insert
or set_node
.
There are helper functions available:
hint(table, pattern)
- Returns a table with all keys oftable
matchingpattern
(same format as instring.find
). Iftable
is omitted, it searches within all imported tables.clear()
- Clears the chat window (by spamming a lot of empty lines).echo(message)
- Sends message to the player who called it. Useful when called from delayed code (e.g. attached to event or viaminetest.after
).load(name)
- Loads a script from thescripts
directory into function. Extension.lua
is added automatically. The arguments passed to the returned function are obtained via...
(e.g.local x, y, z = ...
) within a script. Convenience variables and imported tables apply to scripts as well.run(name, arg1, arg2, ...)
- Equivalent toload(name)(arg1, arg2, ...)
. Arguments are of course optional.count(table)
- Returns the number of elements intable
. The function was added since neither#
nortable.getn
work properly with associative tables.keys(table)
- Returns all keys oftable
. Resulting table is numerically indexed.values(table)
- Returns all values oftable
. Resulting table is numerically indexed.extend(table, other, ...)
- Merges one or more tables intotable
and returnstable
. To return new table instead of modifying, use it likeextend({}, table, other, ...)
.filter(table, callback)
- For every element oftable
callscallback(value, key)
and returns only elements for whichcallback
returnstrue
or true-like value.pack(...)
- Packs provided arguments into table. Resulting table contains keyn
which is the number of provided arguments. Supposed to be equivalent oftable.pack
in Lua >= 5.2.
These variables can be set to adjust display of tables:
indent_size
- Indent size in spaces. When not set, defaults to4
.max_depth
- Maximum depth of nested tables. When this limit is hit, REPL displaystable
instead of table contents. When not set, defaults to1
.
Multiplayer mode is disabled by default. To enable it, console_multiplayer
setting must be set to true
and the players that are supposed to use REPL need debug
privilege. REPL is toggled using /console
command.