+---------------------------------------------------------------------------------------------------
+Version: 2.0.3
+Date: 2024-11-30
+
+ Changed:
+ - Overall better error handling.
+
---------------------------------------------------------------------------------------------------
Version: 2.0.2
Date: 2024-11-30
return
end
- local f, err, cmd
+ local f, lserr, pcs, pcerr, cmd
if player.gui.screen.some_luaconsole then
storage.cmd = player.gui.screen.some_luaconsole.input.text
cmd = storage.cmd or ""
cmd = cmd:gsub('game%.player([^s])', 'game.players['..player.index..']%1')
- f, err = loadstring('pcall(function () '..cmd..' end)')
+ f, lserr = loadstring('local ipcs,ipcr ipcs,ipcr=pcall(function() '..cmd..' end) if not ipcs then game.players['..player.index..'].print(ipcr) end')
if not f then
- cmd = 'game.players['..player.index..'].print('..cmd..')'
- f, err = loadstring(cmd)
+-- player.print("loadstring1 failed (this may be ok)")
+ f, lserr = loadstring('game.players['..player.index..'].print('..cmd..')')
end
- _, err = pcall(f)
- if err then
- player.print(cmd)
- player.print(err:sub(1, err:find('\n')))
+ if f then
+ pcs, pcerr = pcall(f)
+ if not pcs then
+-- player.print("pcall failed")
+ player.print(pcerr:sub(1, pcerr:find('\n')))
+ end
+ else
+-- player.print("syntax error2")
+ player.print(lserr:sub(1, lserr:find('\n')))
end
end
{
"name": "some-luaconsole",
- "version": "2.0.2",
+ "version": "2.0.3",
"title": "Someone's LUA-Console",
"author": "someone1337",
"homepage": "https://git.somenet.org/factorio/some-luaconsole.git",