Browse Source

Bugfixes

master
luk3yx 4 months ago
parent
commit
fde3650cc3
2 changed files with 7 additions and 4 deletions
  1. +0
    -2
      console.lua
  2. +7
    -2
      core.lua

+ 0
- 2
console.lua View File

@@ -197,8 +197,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
console_text[name] = {}
snippets.show_console(name)
if not code or code == '' then return end
local good, msg = loadstring('return ' .. code)
if good then code = 'return ' .. code end
local res = snippets.exec_as_player(name, code)
if res ~= nil then
snippets.push_console_msg(name, res)

+ 7
- 2
core.lua View File

@@ -15,7 +15,7 @@ local safe_funcs = {}
local orig_funcs, running_snippet

function snippets.get_current_snippet()
if running_snippet then return copy(running_snippet) end
return running_snippet
end

-- Apply "safe functions": These wrap normal registration functions so that
@@ -188,8 +188,13 @@ function snippets.register_snippet(name, def)
def.name = name

if def.code then
-- Automatically add "return"
local msg
def.func, msg = loadstring(def.code, name)
def.func = loadstring('return ' .. def.code, name)
if not def.func then
def.func, msg = loadstring(def.code, name)
end

if def.func then
if name ~= 'snippets:anonymous' then
local old_def = snippets.registered_snippets[name]

Loading…
Cancel
Save