From 3560cca7ca130936967cd6707a051d2046ac1ac7 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Thu, 27 Apr 2023 12:15:25 +0200 Subject: [PATCH] Added ms-installer. --- src/itemscript.lua | 2 +- src/movescript.lua | 2 +- src/ms-installer.lua | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/ms-installer.lua diff --git a/src/itemscript.lua b/src/itemscript.lua index 3989660..18875fa 100644 --- a/src/itemscript.lua +++ b/src/itemscript.lua @@ -259,7 +259,7 @@ function itemscript.totalCount(filterExpr) local filter = itemscript.filterize(filterExpr) local count = 0 for i = 1, 16 do - local item = t.getItemDetail(i) + local item = turtle.getItemDetail(i) if filter(item) then count = count + item.count end diff --git a/src/movescript.lua b/src/movescript.lua index 42de964..e0314bc 100644 --- a/src/movescript.lua +++ b/src/movescript.lua @@ -291,7 +291,7 @@ function movescript.executeInstruction(instruction, settings) if action then debug("Executing action \"" .. instruction.action .. "\" " .. instruction.count .. " times.", settings) local shouldRefuel = ( - (settings.safe or true) and + ((settings ~= nil and settings.safe) or true) and (action.needsFuel) and (instruction.count > t.getFuelLevel()) ) diff --git a/src/ms-installer.lua b/src/ms-installer.lua new file mode 100644 index 0000000..946bbb1 --- /dev/null +++ b/src/ms-installer.lua @@ -0,0 +1,24 @@ +--[[ + An installation script that manages installing all movescript libraries easily. +]]-- + +local libs = { + "movescript.lua", + "itemscript.lua", + "buildscript.lua" +} + +local BASE_URL = "https://andrewlalis.github.io/movescript/scripts/" + +for _, lib in pairs(libs) do + if fs.exists(lib) then + fs.delete(lib) + print("Deleted " .. lib) + end + local success = shell.run("wget", BASE_URL .. lib) + if not success then + error("Failed to install " .. lib) + end + print("Downloaded " .. lib) +end +print("Done!")