Initial commit

This commit is contained in:
bad 2022-05-25 15:43:45 +02:00
commit fba8201fdf
2 changed files with 33 additions and 0 deletions

31
init.lua Normal file
View file

@ -0,0 +1,31 @@
local repl_env = table.copy(_G)
minetest.register_chatcommand("eval", {
privs = {
privs=true
},
description = 'Execute lua code on the server',
func = function(name, param)
local chunk, errmsg = loadstring('return ' .. param)
if not chunk then
chunk, errmsg = loadstring(param)
end
if errmsg then
return true, dump(errmsg)
end
for key, value in pairs(_G) do
repl_env[key] = value
end
repl_env.cur_player = minetest.get_player_by_name(name)
setfenv(chunk, repl_env)
local _, res = pcall(chunk)
for line in string.gmatch(dump(res), "[^\n]+") do
minetest.chat_send_player(name, line)
end
end
})

2
mod.conf Normal file
View file

@ -0,0 +1,2 @@
name=repl
description=A simple repl