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!")