Below is my Lua execution alias for Mudlet with both compile and runtime error echoing. Feel free to use and distribute as needed, just give credit where credit is due. Also, note that this will error on something like "luar 5". It's script execution, not evaluation. You'll need to use "luar return 5" if that's what you want.
SYNTAX:
LUA <code> - Runs the code given
LUAR <code> - Runs the code given and displays all return values, if any
Alias pattern:
Script:
local f,e,eh,r
f,e = loadstring(matches[2])
eh = function(err) echo("\nError in code execution:\n"..err) end
r = {xpcall(f,eh)}
if not r[1] and e then
echo("\nLua code compile error:\n"..e)
else
if matches[1]:sub(4,4) == "r" then
table.remove(r,1)
if #r>0 then
display(setmetatable(r, {__index={__customtype="Return Values"}}))
else
echo("\nNo return values for given code.")
end
end
end
EDIT: Forgot to include the xml for ease of import. Here you go:
- luaexe.xml
- Lua Execution alias
- (876 Bytes) Downloaded 474 times