From c875381d40e2094b90e409a4c44b5ff259161e96 Mon Sep 17 00:00:00 2001 From: payonel Date: Wed, 26 Oct 2016 23:07:07 -0700 Subject: [PATCH 1/3] wget and pastebin are now core to openos install --- .../li/cil/oc/integration/opencomputers/ModOpenComputers.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala index 097e93f5d..164d977bc 100644 --- a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala +++ b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala @@ -80,8 +80,6 @@ object ModOpenComputers extends ModProxy { api.IMC.registerProgramDiskLabel("md5sum", "data", "Lua 5.2", "Lua 5.3", "LuaJ") api.IMC.registerProgramDiskLabel("sha256sum", "data", "Lua 5.2", "Lua 5.3", "LuaJ") api.IMC.registerProgramDiskLabel("refuel", "generator", "Lua 5.2", "Lua 5.3", "LuaJ") - api.IMC.registerProgramDiskLabel("pastebin", "internet", "Lua 5.2", "Lua 5.3", "LuaJ") - api.IMC.registerProgramDiskLabel("wget", "internet", "Lua 5.2", "Lua 5.3", "LuaJ") api.IMC.registerProgramDiskLabel("irc", "irc", "Lua 5.2", "Lua 5.3", "LuaJ") api.IMC.registerProgramDiskLabel("maze", "maze", "Lua 5.2", "Lua 5.3", "LuaJ") api.IMC.registerProgramDiskLabel("arp", "network", "Lua 5.2", "Lua 5.3", "LuaJ") From e5d2b0051fd2210acc82688735d03146241b6dfb Mon Sep 17 00:00:00 2001 From: payonel Date: Wed, 26 Oct 2016 23:37:34 -0700 Subject: [PATCH 2/3] simple error reporting and message to craft install disk if user tries to use program known to computer.getProgramLocations() --- .../opencomputers/loot/openos/lib/process.lua | 3 ++- .../openos/lib/tools/programLocations.lua | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/opencomputers/loot/openos/lib/tools/programLocations.lua diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/process.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/process.lua index 15f362d26..1cca5e445 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/process.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/process.lua @@ -52,7 +52,8 @@ function process.load(path, env, init, name) io.stderr:write(path .. ": is a directory\n") return 126 end - io.stderr:write(path .. ": " .. reason .. "\n") + local handler = require("tools/programLocations") + handler.reportNotFound(path, reason) return 127 end os.setenv("_", program) diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/tools/programLocations.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/tools/programLocations.lua new file mode 100644 index 000000000..1f165d60c --- /dev/null +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/tools/programLocations.lua @@ -0,0 +1,23 @@ +local computer = require("computer") +local lib = {} + +function lib.locate(path) + for _,lookup in ipairs(computer.getProgramLocations()) do + if lookup[1] == path then + return lookup[2] + end + end +end + +function lib.reportNotFound(path, reason) + local loot = lib.locate(path) + if loot then + io.stderr:write("The program '" .. path .. "' is currently not installed. To install it:\n" .. + "1. Craft the '" .. loot .. "' floppy disk and insert it into this computer.\n" .. + "2. Run `install " .. loot .. "`") + else + io.stderr:write(path .. ": " .. reason .. "\n") + end +end + +return lib From 83129f21ac72c5cc025235cb7a4824a5b2c757fc Mon Sep 17 00:00:00 2001 From: payonel Date: Tue, 1 Nov 2016 22:44:52 -0700 Subject: [PATCH 3/3] check args --- .../opencomputers/loot/openos/lib/tools/programLocations.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/tools/programLocations.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/tools/programLocations.lua index 1f165d60c..9772e00ea 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/tools/programLocations.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/tools/programLocations.lua @@ -10,12 +10,13 @@ function lib.locate(path) end function lib.reportNotFound(path, reason) + checkArg(1, path, "string") local loot = lib.locate(path) if loot then io.stderr:write("The program '" .. path .. "' is currently not installed. To install it:\n" .. "1. Craft the '" .. loot .. "' floppy disk and insert it into this computer.\n" .. "2. Run `install " .. loot .. "`") - else + elseif type(reason) == "string" then io.stderr:write(path .. ": " .. reason .. "\n") end end