From bab6ca719b62ff38e3aa6b3c31931ff9f0b5b509 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Sun, 24 Jun 2018 09:43:34 +0200 Subject: [PATCH] Bugfix for tool durability detection. --- scripts/cobble_generator/cobble_generator.lua | 5 +++-- scripts/cobble_generator/cobble_generator_min.lua | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/cobble_generator/cobble_generator.lua b/scripts/cobble_generator/cobble_generator.lua index 463a30d..8597235 100644 --- a/scripts/cobble_generator/cobble_generator.lua +++ b/scripts/cobble_generator/cobble_generator.lua @@ -26,10 +26,11 @@ local cyclesPerformed = 0 Mines one block of cobble, checking for a proper tool first. --]] local function mineCobble() - local success, msg = robot.durability() - while not success do + local dur = robot.durability() + while not dur do print("No valid tool. Please place one in the tool slot and press enter.") io.read() + dur = robot.durability() end robot.swing() end diff --git a/scripts/cobble_generator/cobble_generator_min.lua b/scripts/cobble_generator/cobble_generator_min.lua index 7588f74..b4a7caa 100644 --- a/scripts/cobble_generator/cobble_generator_min.lua +++ b/scripts/cobble_generator/cobble_generator_min.lua @@ -1 +1 @@ -local a=require("robot")local b=0 local function c()local f,g=a.durability()while not f do print("No valid tool. Please place one in the tool slot and press enter.")io.read()end a.swing()end local function d()for f=1,4 do c()a.turnRight()end a.dropDown()print("Cycles done: "..b)b=b+1 end local function e()print("# Andrew's Cobblestone Generator #")print("# Copyright 2018 Andrew Lalis #")print("#--------------------------------#")print("Please enter the number of cycles to perform, or -1 to continue forever.")local f=tonumber(io.read())if(f==nil or f==-1)then print("Beginning infinite cycles.")while true do d()end else print("Beginning "..f.." cycles.")for g=1,f do d()end end print("#------Program completed.--------#")end e() \ No newline at end of file +local a=require("robot")local b=0 local function c()local f=a.durability()while not f do print("No valid tool. Please place one in the tool slot and press enter.")io.read()f=a.durability()end a.swing()end local function d()for f=1,4 do c()a.turnRight()end a.dropDown()print("Cycles done: "..b)b=b+1 end local function e()print("# Andrew's Cobblestone Generator #")print("# Copyright 2018 Andrew Lalis #")print("#--------------------------------#")print("Please enter the number of cycles to perform, or -1 to continue forever.")local f=tonumber(io.read())if(f==nil or f==-1)then print("Beginning infinite cycles.")while true do d()end else print("Beginning "..f.." cycles.")for g=1,f do d()end end print("#------Program completed.--------#")end e() \ No newline at end of file