From: Someone Date: Sat, 30 Nov 2024 02:49:19 +0000 (+0100) Subject: RELEASE 2.0.3 - Overall better error handling X-Git-Url: https://git.somenet.org/factorio/some-luaconsole.git/commitdiff_plain RELEASE 2.0.3 - Overall better error handling --- diff --git a/changelog.txt b/changelog.txt index da3c886..c609fc1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +--------------------------------------------------------------------------------------------------- +Version: 2.0.3 +Date: 2024-11-30 + + Changed: + - Overall better error handling. + --------------------------------------------------------------------------------------------------- Version: 2.0.2 Date: 2024-11-30 diff --git a/control.lua b/control.lua index cf2f43f..de61d5a 100644 --- a/control.lua +++ b/control.lua @@ -4,7 +4,7 @@ function exec_command(player) 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 @@ -13,16 +13,21 @@ function exec_command(player) 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 diff --git a/info.json b/info.json index 8775d79..801e1dd 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "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",