]> git.somenet.org - factorio/some-luaconsole.git/commitdiff
RELEASE 2.0.3 - Overall better error handling master
authorSomeone <someone@somenet.org>
Sat, 30 Nov 2024 02:49:19 +0000 (03:49 +0100)
committerSomeone <someone@somenet.org>
Sat, 30 Nov 2024 02:49:19 +0000 (03:49 +0100)
changelog.txt
control.lua
info.json

index da3c886b48ad545d5c20a5207c8f3cc21009d44a..c609fc19bff34e8d43246d77777dcc28c3374a7f 100644 (file)
@@ -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
index cf2f43f1f67a7ab1700b069faf8d7f13d4c5edc0..de61d5a9d60f3b9a85cdf167e68ba97a312c6a21 100644 (file)
@@ -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
 
index 8775d79f6357d0cf8914acc2dea7e9b8128e9de6..801e1dd5cf166ad2ba53e2bf2f3d8934925ec0c3 100644 (file)
--- 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",