support for //lua =... added

This commit is contained in:
Imre Péntek 2024-03-28 17:02:13 +01:00
parent a6f68ed4e7
commit d4ca3db924
1 changed files with 3 additions and 0 deletions

View File

@ -4,6 +4,9 @@
--- Executes `code` as a Lua chunk in the global namespace.
-- @return An error message if the code fails, or nil on success.
function worldedit.lua(code, name)
if string.sub(code,1,1)=="=" then
code="return "..string.sub(code,2)
end
local factory, err = loadstring("return function(p) " .. code .. " end")
if not factory then -- Syntax error
return false, err