From 5cb4dc5537c886c95f414fa02d62b2c299ad1126 Mon Sep 17 00:00:00 2001 From: payonel Date: Thu, 14 May 2020 20:18:38 -0700 Subject: [PATCH 1/5] tiny cleanup in shell for crashed scripts remove unknown error message --- .../resources/assets/opencomputers/loot/openos/bin/sh.lua | 7 +++++-- .../resources/assets/opencomputers/loot/openos/lib/sh.lua | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua b/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua index 8a724be71..a095d0de3 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua @@ -5,6 +5,8 @@ local sh = require("sh") local args = shell.parse(...) +local t = type + shell.prime() if #args == 0 then @@ -19,6 +21,7 @@ if #args == 0 then if tty.getCursor() > 1 then io.write("\n") end + io.write("type:", t(type), '\n') io.write(sh.expand(os.getenv("PS1") or "$ ")) end tty.window.cursor = input_handler @@ -31,8 +34,8 @@ if #args == 0 then elseif command ~= "" then --luacheck: globals _ENV local result, reason = sh.execute(_ENV, command) - if not result then - io.stderr:write((reason and tostring(reason) or "unknown error") .. "\n") + if not result and reason then + io.stderr:write(tostring(reason), "\n") end end elseif command == nil then -- false only means the input was interrupted diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/sh.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/sh.lua index f483aee22..877e9b4a3 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/sh.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/sh.lua @@ -198,7 +198,7 @@ function sh.execute(env, command, ...) if type(words) ~= "table" then return words, reason elseif #words == 0 then - return true, 0 + return true end -- MUST be table.pack for non contiguous ... From f9e84b3fd9ae4f07d1e32b055e3106e94b6986a0 Mon Sep 17 00:00:00 2001 From: payonel Date: Thu, 14 May 2020 20:58:35 -0700 Subject: [PATCH 2/5] woops, left debug text in code --- src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua b/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua index a095d0de3..d4e4dd9db 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua @@ -5,8 +5,6 @@ local sh = require("sh") local args = shell.parse(...) -local t = type - shell.prime() if #args == 0 then @@ -21,7 +19,6 @@ if #args == 0 then if tty.getCursor() > 1 then io.write("\n") end - io.write("type:", t(type), '\n') io.write(sh.expand(os.getenv("PS1") or "$ ")) end tty.window.cursor = input_handler From 7bd148367c041cec91947bf2706df95576664163 Mon Sep 17 00:00:00 2001 From: payonel Date: Thu, 14 May 2020 21:32:21 -0700 Subject: [PATCH 3/5] put 5.3 above 5.2 so it is the first selected architecture --- src/main/scala/li/cil/oc/common/Proxy.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/Proxy.scala b/src/main/scala/li/cil/oc/common/Proxy.scala index ce7c6d1ac..8433ccdb8 100644 --- a/src/main/scala/li/cil/oc/common/Proxy.scala +++ b/src/main/scala/li/cil/oc/common/Proxy.scala @@ -73,12 +73,12 @@ class Proxy { api.API.config = Settings.get.config - if (LuaStateFactory.include52) { - api.Machine.add(classOf[NativeLua52Architecture]) - } if (LuaStateFactory.include53) { api.Machine.add(classOf[NativeLua53Architecture]) } + if (LuaStateFactory.include52) { + api.Machine.add(classOf[NativeLua52Architecture]) + } if (LuaStateFactory.includeLuaJ) { api.Machine.add(classOf[LuaJLuaArchitecture]) } From 66bcd3f46a1b9a9bc6d488ab83a712bb4488c147 Mon Sep 17 00:00:00 2001 From: payonel Date: Thu, 14 May 2020 22:56:47 -0700 Subject: [PATCH 4/5] fix cpu to use default lua arch (5.3) --- src/main/scala/li/cil/oc/common/Proxy.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/scala/li/cil/oc/common/Proxy.scala b/src/main/scala/li/cil/oc/common/Proxy.scala index 8433ccdb8..7c79bf7d1 100644 --- a/src/main/scala/li/cil/oc/common/Proxy.scala +++ b/src/main/scala/li/cil/oc/common/Proxy.scala @@ -73,10 +73,19 @@ class Proxy { api.API.config = Settings.get.config + // Weird JNLua bug identified + // When loading JNLua (for either 5.2 or 5.3 lua state) there is a static section that the library loads + // being static, it loads once regardless of which lua state is loaded first + // static { REGISTRYINDEX = lua_registryindex(); } + // The problem is that lua_registryindex was removed in 5.3 + // Thus, if we load JNLua from a lua5.3 state first, this static section fails + // We must load 5.2 first, AND we know 5.3 will likely fail to load if 5.2 failed + val include52: Boolean = LuaStateFactory.include52 + // now that JNLua has been initialized from a lua52 state, we are safe to check 5.3 if (LuaStateFactory.include53) { api.Machine.add(classOf[NativeLua53Architecture]) } - if (LuaStateFactory.include52) { + if (include52) { api.Machine.add(classOf[NativeLua52Architecture]) } if (LuaStateFactory.includeLuaJ) { From 21c67ce31dda657eb42ba5bd0ce6e66cc2dced01 Mon Sep 17 00:00:00 2001 From: payonel Date: Thu, 14 May 2020 23:53:00 -0700 Subject: [PATCH 5/5] the y value passed to render methods changed in 1.10 to ref feet instead of eyes this breaks our screen render check when the player is standing just below the y value of text on the screen, but should still be able to see the text. closes #3252 --- .../cil/oc/client/renderer/tileentity/ScreenRenderer.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala index c86b2084f..1d5fce359 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala @@ -51,10 +51,14 @@ object ScreenRenderer extends TileEntitySpecialRenderer[Screen] { return } + // y = block.bottom - player.feet + // eye is higher, so the y delta should be more negative + val eye_delta: Double = y - Minecraft.getMinecraft.thePlayer.getEyeHeight + // Crude check whether screen text can be seen by the local player based // on the player's position -> angle relative to screen. val screenFacing = screen.facing.getOpposite - if (screenFacing.getFrontOffsetX * (x + 0.5) + screenFacing.getFrontOffsetY * (y + 0.5) + screenFacing.getFrontOffsetZ * (z + 0.5) < 0) { + if (screenFacing.getFrontOffsetX * (x + 0.5) + screenFacing.getFrontOffsetY * (eye_delta + 0.5) + screenFacing.getFrontOffsetZ * (z + 0.5) < 0) { return }