· 5 years ago · Nov 09, 2020, 10:52 PM
1--Civilwargeeky's Quarry Program--
2 VERSION = "3.6.4.5"
3--[[
4Recent Changes:
5 Parameter Files! Create a file of parameters, and use -file to load it!
6 Works will with -forcePrompt
7 Quarry no longer goes to start at end of row!
8 Turtle can go left!
9 QuadCopters! Check Lyqyd's thread
10New Parameters:
11 -overfuel/fuelMultiplier [number]: This number is is what neededFuel is multiplied by when fuel is low.
12 -version: This will display the current version number and end the program
13 -file [fileName]: This will load a custom configuration file (basically a list of parameters). "##" starts comment lines. In the future "#" will start programs to run (but only through shell)
14 -preciseTotals [t/f]: If true, turtle will write exactly what it mined to the logs. It may also transmit it over rednet.
15 -forcePrompt [param]: This will add to a list of parameters to force prompt for. So if you say "-forcePrompt doRefuel" it will prompt you "Length","Width","Height","Invert","Do Refuel" etc.
16]]
17--Defining things
18civilTable = nil; _G.civilTable = {}; setmetatable(civilTable, {__index = getfenv()}); setfenv(1,civilTable)
19originalDay = os.day() --Used in logging
20numResumed = 0 --Number of times turtle has been resumed
21-------Defaults for Arguments----------
22--Arguments assignable by text
23x,y,z = 3,3,3 --These are just in case tonumber fails
24inverted = false --False goes from top down, true goes from bottom up [Default false]
25rednetEnabled = false --Default rednet on or off [Default false]
26--Arguments assignable by tArgs
27dropSide = "front" --Side it will eject to when full or done [Default "front"]
28careAboutResources = true --Will not stop mining once inventory full if false [Default true]
29doCheckFuel = true --Perform fuel check [Default true]
30doRefuel = false --Whenever it comes to start location will attempt to refuel from inventory [Default false]
31keepOpen = 1 --How many inventory slots it will attempt to keep open at all times [Default 1]
32fuelSafety = "moderate" --How much fuel it will ask for: safe, moderate, and loose [Default moderate]
33excessFuelAmount = math.huge --How much fuel the turtle will get maximum. Limited by turtle.getFuelLimit in recent CC [Default math.huge]
34fuelMultiplier = 1 --How much extra fuel turtle will ask for when it does need fuel [Default 1]
35saveFile = "Civil_Quarry_Restore" --Where it saves restore data [Default "Civil_Quarry_Restore"]
36autoResume = true --If true, turtle will auto-restart when loaded. [Default true]
37startupRename = "oldStartup.quarry" --What the startup is temporarily renamed to [Default "oldStartup.quarry"]
38startupName = "startup" --What the turtle auto-resumes with [Default "startup"]
39doBackup = true --If it will keep backups for session persistence [Default true]
40uniqueExtras = 8 --How many different items (besides cobble) the turtle expects. [Default 8]
41maxTries = 200 --How many times turtle will try to dig a block before it "counts" bedrock [Default 200]
42gpsEnabled = false -- If option is enabled, will attempt to find position via GPS api [Default false]
43gpsTimeout = 3 --The number of seconds the program will wait to get GPS coords. Not in arguments [Default 3]
44legacyRednet = false --Use this if playing 1.4.7
45logging = true --Whether or not the turtle will log mining runs. [Default ...still deciding]
46logFolder = "Quarry_Logs" --What folder the turtle will store logs in [Default "Quarry_Logs"]
47logExtension = "" --The extension of the file (e.g. ".txt") [Default ""]
48flatBedrock = false --If true, will go down to bedrock to set startDown [Default false]
49startDown = 0 --How many blocks to start down from the top of the mine [Default 0]
50preciseTotals = false --If true, will record exact totals and names for all materials [Default false]
51goLeftNotRight = false --Quarry to left, not right (parameter is "left") [Default false]
52oreQuarry = false --Enables ore quarry functionality [Default false]
53oreQuarryBlacklistName = "oreQuarryBlacklist.txt" --This is the file that will be parsed for item names [Default "oreQuarryBlacklist"]
54dumpCompareItems = true --If ore quarry, the turtle will dump items compared to (like cobblestone) [Default true]
55frontChest = false --If oreQuarry and chest checking, you can turn this on to make turtle check in front of itself for chests as well [Default false]
56lavaBuffer = 500 --If using a lava bucket, this is the buffer it will wait for before checking for lava [Default 500]
57inventoryMax = 16 --The max number of slots in the turtle inventory [Default 16] (Not assignable by parameter)
58quadEnabled = false --Whether or not to request a quadRotor when out of fuel [Default false]
59quadTimeout = 60 * 5 --How long the turtle will wait for a quadRotor [Default 5 minutes]
60--Standard number slots for fuel (you shouldn't care)
61fuelTable = { --Will add in this amount of fuel to requirement.
62safe = 1000,
63moderate = 200,
64loose = 0 } --Default 1000, 200, 0
65--Standard rednet channels
66channels = {
67send = os.getComputerID() + 1 ,
68receive = os.getComputerID() + 101 ,
69confirm = "Turtle Quarry Receiver",
70message = "Civil's Quarry",
71fingerprint = "quarry"
72}
73
74--AVERAGE USER: YOU DON'T CARE BELOW THIS POINT
75
76local help_paragraph = [[
77Welcome!: Welcome to quarry help. Below are help entries for all parameters. Examples and tips are at the bottom.
78-default: This will force no prompts. If you use this and nothing else, only defaults will be used.
79-dim: [length] [width] [height] This sets the dimensions for the quarry
80-invert: [t/f] If true, quarry will be inverted (go up instead of down)
81-rednet: [t/f] If true and you have a wireless modem on the turtle, will attempt to make a rednet connection for sending important information to a screen
82-restore / -resume: If your quarry stopped in the middle of its run, use this to resume at the point where the turtle was. Not guarenteed to work properly. For more accurate location finding, check out the -GPS parameter
83-autoResume / autoRestore: Turtle will automatically resume if stopped. Replaces startup
84-oreQuarry: [t/f] If true, the turtle will use ore quarry mode. It will not mine the blocks that are placed in the turtle initially. So if you put in stone, it will ignore stone blocks and only mine ores.
85-oreQuarry: [t/f] If you are using a newer version of CC, you won't have to put in any compare blocks. (CC 1.64+)
86-blacklist: [file name] If using oreQuarry, this is the blacklist file it will read. Example --
87 minecraft:stone
88 minecraft:sand
89 ThermalExpansion:Sponge
90 ThermalFoundation:Storage
91
92 Note: If you have bspkrsCore, look
93 for "UniqueNames.txt" in your config
94-file: [file name] Will load a file of parameters. One parameter per line. # is a comment line (See the forum thread for more detailed directions)
95-atChest: [force] This is for use with "-restore," this will tell the restarting turtle that it is at its home chest, so that if it had gotten lost, it now knows where it is.
96-doRefuel: [t/f] If true, the turtle will refuel itself with coal and planks it finds on its mining run
97-doCheckFuel: [t/f] If you for some reason don't want the program to check fuel usage, set to false. This is honestly a hold-over from when the refueling algorithm was awful...
98-overfuel: [number] When fuel is below required, fuel usage is multiplied by this. Large numbers permit more quarries without refueling
99-fuelMultiplier: [number] See overfuel
100-uniqueExtras: [number] The expected number of slots filled with low-stacking items like ore. Higher numbers request more fuel.
101-maxFuel: [number] How much the turtle will fuel to max (limited by turtle in most cases)
102-chest: [side] This specifies what side the chest at the end will be on. You can say "top", "bottom", "front", "left", or "right"
103-enderChest: [slot] This one is special. If you use "-enderChest true" then it will use an enderChest in the default slot. However, you can also do "-enderChest [slot]" then it will take the ender chest from whatever slot you tell it to. Like 7... or 14... or whatever.
104-fuelChest: [slot] See the above, but for a fueling chest. Reccommend use with -maxFuel and -doCheckFuel false
105-lava: [slot] If using an oreQuarry, will fill itself with lava it finds to maxFuel
106-lavaBuffer: [number] The amount of fuel below maxFuel the turtle will wait for before using lava again
107-GPS: [force] If you use "-GPS" and there is a GPS network, then the turtle will record its first two positions to precisly calculate its position if it has to restart. This will only take two GPS readings
108-quad: [t/f] This forces the use of GPS. Make sure you have a network set up. This will request to be refueled by a quadrotor from Lyqyd's mod if the turtle is out of fuel
109-quadTimeout: [number] The amount of time the turtle will wait for a quadRotor
110-sendChannel: [number] This is what channel your turtle will send rednet messages on
111-receiveChannel: [number] This is what channel your turtle will receive rednet messages on
112-legacyRednet: [t/f] Check true if using 1.4.7
113-startY: [current Y coord] Randomly encountering bedrock? This is the parameter for you! Just give it what y coordinate you are at right now. If it is not within bedrock range, it will never say it found bedrock
114-startupRename: [file name] What to rename any existing startup to.
115-startupName: [file name] What the turtle will save its startup file to.
116-extraDropItems: [force] If oreQuarry then this will prompt the user for extra items to drop, but not compare to (like cobblestone)
117-dumpCompareItems: [t/f] If oreQuarry and this is true, the turtle will dump off compare blocks instead of storing them in a chest
118-oldOreQuarry: [t/f] If you are using new CC versions, you can use this to use the old oreQuarry.
119-compareChest: [slot] If using oldOreQuarry, this will allow you to check for dungeon chests and suck from them.
120-frontChest: [t/f] If using oreQuarry/oldOreQuarry, this will check in front of itself for chests as well.
121-left: [t/f] If true, turtle will quarry to the left instead of the right
122-maxTries: [number] This is the number of times the turtle will try to dig before deciding its run into bedrock.
123-forcePrompt: [parameter] Whatever parameter you specify, it will always prompt you, like it does now for invert and dim.
124-logging: [t/f] If true, will record information about its mining run in a folder at the end of the mining run
125-preciseTotals: [t/f] If true (and turtle.inspect exists), it will log a detailed record of every block the turtle mines and send it over rednet
126-doBackup: [t/f] If false, will not back up important information and cannot restore, but will not make an annoying file (Actually I don't really know why anyone would use this...)
127-saveFile: [word] This is what the backup file will be called
128-logFolder: [word] The folder that quarry logs will be stored in
129-logExtension: [word] The extension given to each quarry log (e.g. ".txt" or ".notepad" or whatever)
130-keepOpen: [number] This is the number of the slots the turtle will make sure are open. It will check every time it mines
131-careAboutResources: [t/f] Who cares about the materials! If set to false, it will just keep mining when its inventory is full
132-startDown: [number] If you set this, the turtle will go down this many blocks from the start before starting its quarry
133 =
134 C _ |
135 |
136 |
137 |
138 |_ _ _ _ >
139-flatBedrock: [t/f] If true, turtle will find bedrock and "zero" itself so it ends on bedrock level
140-promptAll: This is the opposite of -Default, it prompts for everything
141-listParams: This will list out all your selected parameters and end quarry. Good for testing
142-manualPos: [xPos] [zPos] [yPos] [facing] This is for advanced use. If the server reset when the turtle was in the middle of a 100x100x100 quarry, fear not, you can now manually set the position of the turtle. yPos is always positive. The turtle's starting position is 0, 1, 1, 0. Facing is measured 0 - 3. 0 is forward, and it progresses clockwise. Example- "-manualPos 65 30 30 2"
143-version: Displays the current quarry version and stops the program
144-help: Thats what this is :D
145Examples: Everything below is examples and tips for use
146Important Note:
147 None of the above parameters are necessary. They all have default values, and the above are just if you want to change them.
148Examples [1]:
149 Want to just start a quarry from the interface, without going through menus? It's easy! Just use some parameters. Assume you called the program "quarry." To start a 10x6x3 quarry, you just type in "quarry -dim 10 6 3 -default".
150 You just told it to start a quarry with dimensions 10x6x3, and "-default" means it won't prompt you about invert or rednet. Wasn't that easy?
151Examples [2]:
152 Okay, so you've got the basics of this now, so if you want, you can type in really long strings of stuff to make the quarry do exactly what you want. Now, say you want a 40x20x9, but you want it to go down to diamond level, and you're on the surface (at y = 64). You also want it to send rednet messages to your computer so you can see how its doing.
153Examples [2] [cont.]:
154 Oh yeah! You also want it to use an ender chest in slot 12 and restart if the server crashes. Yeah, you can do that. You would type
155 "quarry -dim 40x20x9 -invert false -startDown 45 -rednet true -enderChest 12 -restore"
156 BAM. Now you can just let that turtle do it's thing
157Tips:
158 The order of the parameters doesn't matter. "quarry -invert false -rednet true" is the same as "quarry -rednet true -invert false"
159
160 Capitalization doesn't matter. "quarry -iNVErt FALSe" does the same thing as "quarry -invert false"
161Tips [cont.]:
162 For [t/f] parameters, you can also use "yes" and "no" so "quarry -invert yes"
163
164 For [t/f] parameters, it only cares about the first letter. So you can use "quarry -invert t" or "quarry -invert y"
165Tips [cont.]:
166 If you are playing with fuel turned off, the program will automatically change settings for you so you don't have to :D
167
168 If you want, you can load this program onto a computer, and use "quarry -help" so you can have help with the parameters whenever you want.
169Internal Config:
170 At the top of this program is an internal configuration file. If there is some setup that you use all the time, you can just change the config value at the top and run "quarry -default" for a quick setup.
171
172 You can also use this if there are settings that you don't like the default value of.
173]]
174--NOTE: BIOS 114 MEANS YOU FORGOT A COLON
175--NOTE: THIS ALSO BREAKS IF YOU REMOVE "REDUNDANT" WHITESPACE
176--Parsing help for display
177--[[The way the help table works:
178All help indexes are numbered. There is a help[i].title that contains the title,
179and the other lines are in help[i][1] - help[i][#help[i] ]
180Different lines (e.g. other than first) start with a space.
181As of now, the words are not wrapped, fix that later]]
182local help = {}
183local i = 0
184local titlePattern = ".-%:" --Find the beginning of the line, then characters, then a ":"
185local textPattern = "%:.+" --Find a ":", then characters until the end of the line
186for a in help_paragraph:gmatch("\n?.-\n") do --Matches in between newlines
187 local current = string.sub(a,1,-2).."" --Concatenate Trick
188 if string.sub(current,1,1) ~= " " then
189 i = i + 1
190 help[i] = {}
191 help[i].title = string.sub(string.match(current, titlePattern),1,-2)..""
192 help[i][1] = string.sub(string.match(current,textPattern) or " ",3,-1)
193 elseif string.sub(current,1,1) == " " then
194 table.insert(help[i], string.sub(current,2, -1).."")
195 end
196end
197
198local supportsRednet
199if peripheral.find then
200 supportsRednet = peripheral.find("modem") or false
201else
202 supportsRednet = (peripheral.getType("right") == "modem") or false
203end
204
205--Pre-defining variables that need to be saved
206 xPos,yPos,zPos,facing,percent,mined,moved,relxPos, rowCheck, connected, isInPath, layersDone, attacked, startY, chestFull, gotoDest, atChest, fuelLevel, numDropOffs, allowedItems, compareSlots, dumpSlots, selectedSlot, extraDropItems, oldOreQuarry, specialSlots, relzPos, eventInsertionPoint
207 = 0, 1, 1, 0, 0, 0, 0, 1, true , false, true, 1, 0, 0, false, "", false, 0, 0, {}, {}, {}, 1, false, false, {explicit = {}}, 0, 1
208
209--These are slot options that need to exist as variables for parameters to work.
210 enderChest, fuelChest, lavaBucket, compareChest
211= false, false, false, false
212
213local chestID, lavaID, lavaMeta = "minecraft:chest", "minecraft:flowing_lava", 0
214
215local statusString
216
217--Initializing various inventory management tables
218for i=1, inventoryMax do
219 allowedItems[i] = 0 --Number of items allowed in slot when dropping items
220 dumpSlots[i] = false --Does this slot contain junk items?
221end --compareSlots is a table of the compare slots, not all slots with a condition
222totals = {cobble = 0, fuel = 0, other = 0} -- Total for display (cannot go inside function), this goes up here because many functions use it
223
224local function newSpecialSlot(index, value, explicit) --If isn't explicit, it will move whatever is already in the slot around to make room.
225 value = tonumber(value) or 0 --We only want numerical indexes
226 local flag = false --Used in slot moving, moved slot is returned for ease of use
227 local function check(num) return num >= 1 and num <= inventoryMax end
228 if not check(value) then error("from newSpecialSlot: number "..value.." out of range",2) end
229 local function getFirstFree(start)
230 for i=1, math.max(inventoryMax-value,value-1) do
231 for a=-1,1,2 do
232 local num = value + (a*i)
233 if check(num) and not specialSlots[num] then return num end
234 end
235 end
236 return false
237 end
238 if specialSlots[value] and specialSlots[value] ~= index then --If we aren't trying to override the same slot :P
239 if not explicit then
240 value = getFirstFree(value) or error("from newSpecialSlots: all slots full, could not add")
241 elseif explicit and not specialSlots.explicit[value] then --Moving around other slots
242 flag = getFirstFree(value)
243 if not flag then error("from newSpecialSlots: could not add explicit in slot: "..index.." "..value.." Taken by "..specialSlots[value],2) end
244 specialSlots[flag] = specialSlots[value]
245 specialSlots[specialSlots[value]] = flag --These will get set to the new thing later
246 else
247 error('You cannot put a "'..index..'" in the same slot as a "'..specialSlots.explicit[value]..'" (Slot '..value..")",0) --Show the user an understandable error :)
248 end
249 end
250 specialSlots[index] = value
251 specialSlots[value] = index
252 if explicit then
253 specialSlots.explicit[value] = index
254 end
255 return value, flag
256end
257
258function resetDumpSlots()
259 for i=1, inventoryMax do
260 if oldOreQuarry then
261 if turtle.getItemCount(i) > 0 and i~= specialSlots.enderChest then
262 dumpSlots[i] = true
263 else
264 dumpSlots[i] = false
265 end
266 else
267 dumpSlots[i] = false
268 end
269 end
270 if not oldOreQuarry and specialSlots.enderChest == 1 then
271 dumpSlots[2] = true
272 elseif not oldOreQuarry then
273 dumpSlots[1] = true
274 end
275end
276
277local function copyTable(tab) if type(tab) ~= "table" then error("copyTable received "..type(tab)..", expected table",2) end local toRet = {}; for a, b in pairs(tab) do toRet[a] = b end; return toRet end --This goes up here because it is a basic utility
278
279--NOTE: rowCheck is a bit. true = "right", false = "left"
280
281local foundBedrock = false
282
283local checkFuel, checkFuelLimit
284if turtle then --Function inits
285 checkFuel = turtle.getFuelLevel
286 if turtle.getFuelLevel() == "unlimited" then --Fuel is disabled --Unlimited screws up my calculations
287 checkFuel = function() return math.huge end --Infinite Fuel
288 end --There is no "else" because it will already return the regular getFuel
289 if turtle.getFuelLimit then
290 checkFuelLimit = function() return math.min(turtle.getFuelLimit(), excessFuelAmount) end --Return the limiting one
291 if turtle.getFuelLimit() == "unlimited" then
292 checkFuelLimit = function() return math.huge end
293 end
294 else
295 checkFuelLimit = function() return excessFuelAmount end --If the function doesn't exist
296 end
297
298
299 turtle.select(1) --To ensure this is correct
300end
301
302
303function select(slot)
304 if slot ~= selectedSlot and slot > 0 and slot <= inventoryMax then
305 selectedSlot = slot
306 return turtle.select(slot), selectedSlot
307 end
308end
309
310
311 -----------------------------------------------------------------
312--Input Phase
313local function screen(xPos,yPos)
314xPos, yPos = xPos or 1, yPos or 1
315term.setCursorPos(xPos,yPos); term.clear(); end
316local function screenLine(xPos,yPos)
317term.setCursorPos(xPos,yPos); term.clearLine(); end
318
319screen(1,1)
320print("----- Welcome to Quarry! -----")
321print("")
322
323local sides = {top = "top", right = "right", left = "left", bottom = "bottom", front = "front"} --Used to whitelist sides
324local tArgs --Will be set in initializeArgs
325local originalArgs = {...}
326local changedT, tArgsWithUpper, forcePrompts = {}, {}, {}
327changedT.new = function(key, value, name) table.insert(changedT,{key, value, name}); if name then changedT[name] = #changedT end end --Numeric list of lists
328changedT.remove = function(num) changedT[num or #changedT].hidden = true end --Note actually remove, just hide :)
329local function capitalize(text) return (string.upper(string.sub(text,1,1))..string.sub(text,2,-1)) end
330local function initializeArgs()
331 tArgs = copyTable(originalArgs) --"Reset" tArgs
332 for i=1, #tArgs do --My signature key-value pair system, now with upper
333 tArgsWithUpper[i] = tArgs[i]
334 tArgsWithUpper[tArgsWithUpper[i]] = i
335 tArgs[i] = tArgs[i]:lower()
336 tArgs[tArgs[i]] = i
337 if tArgs[i] == "-forceprompt" and i ~= #tArgs then --If the prompt exists then add it to the list of prompts
338 forcePrompts[tArgs[i+1]:lower()] = true
339 end
340 end
341end
342initializeArgs()
343
344local restoreFound, restoreFoundSwitch = false --Initializing so they are in scope
345function parseParam(name, displayText, formatString, forcePrompt, trigger, variableOverride, variableExists) --Beware confusion, all ye who enter here
346 --[[ Guide to Variables
347 originalValue: what the variable was before the function
348 givenValue: This is the value after the parameter. So -invert fAlSe, givenValue is "fAlSe"
349 ]]
350 if variableExists ~= false then variableExists = true end --Almost all params should have the variable exist. Some don't exist unless invoked
351 if trigger == nil then trigger = true end --Defaults to being able to run
352 if not trigger then return end --This is what the trigger is for. Will not run if trigger not there
353 if restoreFoundSwitch or tArgs["-default"] then forcePrompt = false end --Don't want to prompt if these. Default is no variable because resuming
354 if not restoreFoundSwitch and (tArgs["-promptall"] or forcePrompts[name:lower()]) then forcePrompt = true end --Won't prompt if resuming, can prompt all or checks list of prompts
355 local toGetText = name:lower() --Because all params are now lowered
356 local formatType = formatString:match("^%a+"):lower() or error("Format String Unknown: "..formatString) --Type of format string
357 local args = formatString:match(" (.+)") or "".."" --Everything in formatString after the type
358 local variable = variableOverride or name --Goes first to the override for name
359 local func = loadstring("return "..variable) --Note to future self: If you want to remove loadstring, this breaks on tables. You will have to remove tables or figure something else out
360 setfenv(func,getfenv(1))
361 local originalValue = assert(func)() --This is the default value, for checking to add to changed table
362 if originalValue == nil and variableExists then error("From addParam, \""..variable.."\" returned nil",2) end --I may have gotten a wrong variable name
363 local givenValue, toRet, values --Initializing for use
364 if tArgs["-"..toGetText] then
365 givenValue = tArgsWithUpper[tArgs["-"..toGetText]+1] --This is the value after the desired parameter
366 elseif forcePrompt then
367 write(displayText.."? ")
368 givenValue = io.read()
369 end
370 if formatType == "force" then --This is the one exception. Should return true if givenValue is nothing
371 toRet = (tArgs["-"..toGetText] and true) or false --Will return true if param exists, otherwise false
372 end
373 if not (givenValue or toRet) or (type(givenValue) == "string" and #givenValue == 0) then return end --Don't do anything if you aren't given anything. Leave it as default, except for "force". Also don't want empty strings
374 if formatType == "boolean" then --All the format strings will be basically be put through a switch statement
375 toRet = givenValue:sub(1,1):lower() ~= "n" and givenValue:sub(1,1):lower() ~= "f" --Accepts anything but false or no
376 elseif formatType == "string" then
377 toRet = givenValue:match("^[%w%./]+") --Basically anything not a space or control character etc
378 elseif formatType == "number" or formatType == "float" then
379 toRet = tonumber(givenValue) --Note this is a local, not the above so we don't change anything
380 if not toRet then return end --We need a number... Otherwise compare errors
381 if formatType == "number" then toRet = math.floor(toRet) end --Get proper integers
382 local startNum, endNum = formatString:match("(%d+)%-(%d+)") --Gets range of numbers
383 startNum, endNum = tonumber(startNum), tonumber(endNum)
384 if not ((toRet >= startNum) and (toRet <= endNum)) then return end --Can't use these
385 elseif formatType == "side" then
386 local exclusionTab = {} --Ignore the wizardry here. Just getting arguments without format string
387 for a in args:gmatch("%S+") do exclusionTab[a] = true end --This makes a list of the sides to not include
388 if not exclusionTab[givenValue] then toRet = sides[givenValue] end --If side is not excluded
389 elseif formatType == "list" then
390 toRet = {}
391 for a in args:gmatch("[^,]") do
392 table.insert(toRet,a)
393 end
394 elseif formatType == "slot" then
395 if givenValue:sub(1,1):lower() == "n" or givenValue:sub(1,1):lower() == "f" then --Copied from boolean
396 toRet = false
397 else
398 local userNumber, correction = givenValue:match("^%d+$") --This makes sure the value is a number | Locally initialize correction
399 toRet, correction = newSpecialSlot(variable, tonumber(userNumber or args), userNumber) --If givenValue was "true", it won't be explicit and will use default number
400 if correction then changedT[changedT[specialSlots[correction]]][2] = tostring(correction) end --This changes the value field of the changedT index taken from the named pointer (which is the value in specialSlots under correction)
401 end
402 elseif formatType == "force" then --Do nothing, everything is already done
403 else error("Improper formatType",2)
404 end
405 if toRet == nil then return end --Don't want to set variables to nil... That's bad
406 tempParam = toRet --This is what loadstring will see :D
407 local func = loadstring(variable.." = tempParam")
408 setfenv(func, getfenv(1)) --Note to future self: If you want to remove loadstring, this breaks on tables. You will have to remove tables or figure something else out
409 func()
410 tempParam = nil --Cleanup of global
411 if toRet ~= originalValue and displayText ~= "" then
412 changedT.new(displayText, tostring(toRet), variable)
413 end
414 return toRet
415end
416
417local paramLookup = {}
418local function addParam(...)
419 local args = {...}
420 if not paramLookup[args[1]] then
421 local toRet = copyTable(args)
422 for i=2, table.maxn(toRet) do --Have to do this because table.remove breaks on nil
423 toRet[i-1] = toRet[i]
424 end
425 table.remove(toRet)
426 paramLookup[args[1]] = toRet
427 end
428 return parseParam(unpack(args, 1, table.maxn(args)))
429end
430
431local function paramAlias(original, alias)
432 local a = paramLookup[original]
433 if a then
434 if a[5] == nil then a[5] = original end --This is variableOverride because the originals won't put a variable override
435 return parseParam(alias, unpack(a, 1, table.maxn(a)))
436 else
437 error("In paramAlias: '"..original.."' did not exist",2)
438 end
439end
440
441--Check if it is a turtle
442if not(turtle or tArgs["help"] or tArgs["-help"] or tArgs["-?"] or tArgs["?"]) then --If all of these are false then
443 print("This is not a turtle, you might be looking for the \"Companion Rednet Program\" \nCheck My forum thread for that")
444 print("Press 'q' to quit, or any other key to start help ")
445 if ({os.pullEvent("char")})[2] ~= "q" then tArgs.help = true else error("",0) end
446end
447
448if tArgs["help"] or tArgs["-help"] or tArgs["-?"] or tArgs["?"] then
449 print("You have selected help, press any key to continue"); print("Use arrow keys to navigate, q to quit"); os.pullEvent("key")
450 local pos = 1
451 local key = 0
452 while pos <= #help and key ~= keys.q do
453 if pos < 1 then pos = 1 end
454 screen(1,1)
455 print(help[pos].title)
456 for a=1, #help[pos] do print(help[pos][a]) end
457 repeat
458 _, key = os.pullEvent("key")
459 until key == 200 or key == 208 or key == keys.q
460 if key == 200 then pos = pos - 1 end
461 if key == 208 then pos = pos + 1 end
462 end
463 error("",0)
464end
465
466if tArgs["-version"] or tArgs["version"] then
467 print("QUARRY VERSION: ",VERSION)
468 error("",0) --Exit not so gracefully
469end
470
471--Loading custom parameter lists
472local function split(str, sep)
473 assert(#sep == 1, "Split seperator too long. Got '"..sep.."'")
474 if not str:match(sep) then return {str} end --So everything else isn't pointless
475 local toRet = {}
476 toRet[1] = str:match("^([^"..sep.."]-)"..sep)
477 for i in str:gmatch(sep.."([^"..sep.."]*)") do --Matches not seperator chars
478 toRet[#toRet+1] = i
479 end
480 return toRet
481end
482
483if addParam("file","Custom Parameters","string", false, nil, "parameterFile", false) and parameterFile then --This will not load when resuming because there is no "file" parameter when resuming.
484 if not fs.exists(parameterFile) then
485 print("WARNING: '"..parameterFile.."' DOES NOT EXIST. FILE NOT LOADED")
486 sleep(3)
487 changedT.remove()
488 else
489 local file = fs.open(parameterFile, "r")
490 local text = file.readAll()
491 file.close()
492 text = text.."\n" --So that all replacements work properly
493 text = text:gsub("#[^\n]-\n","") --Replace program codes/comment lines+
494 local commands = {} --Contains all the parameters
495 local append = table.insert
496 for _, a in pairs(split(text,"\n")) do
497 local words = split(a," ")
498 if not a:match("-") then --This means only one command per line
499 append(originalArgs,"-"..words[1])
500 for i=2, #words do
501 append(originalArgs, words[i])
502 end
503 else --Otherwise the dashes are already ordered where we want!
504 for i=1, #words do
505 append(originalArgs, words[i])
506 end
507 end
508 end
509 initializeArgs() --Manipulate the args again, because we modified them
510 print("Finished loading file: ",tArgs[tArgs["-file"]+1])
511 sleep(0.5) --Give em a sec
512 end
513end
514
515
516
517--Saving
518addParam("doBackup", "Backup Save File", "boolean")
519addParam("saveFile", "Save File Name", "string")
520
521restoreFound = fs.exists(saveFile)
522restoreFoundSwitch = (tArgs["-restore"] or tArgs["-resume"] or tArgs["-atchest"]) and restoreFound and doBackup
523if restoreFoundSwitch then
524 local file = fs.open(saveFile,"r")
525 local test = file.readAll() ~= ""
526 file.close()
527 if test then
528 local temp = shell and copyTable(shell) --For whatever reason, the shell table doesn't survive resuming. shell and ... so that copyTable doesn't error
529 os.run(getfenv(1),saveFile) --This is where the actual magic happens
530 shell = temp
531 numResumed = numResumed + 1
532 if checkFuel() ~= math.huge then --If turtle uses fuel
533 if fuelLevel - checkFuel() == 1 then
534 if facing == 0 then xPos = xPos + 1
535 elseif facing == 2 then xPos = xPos - 1
536 elseif facing == 1 then zPos = zPos + 1
537 elseif facing == 3 then zPos = zPos - 1 end
538 elseif fuelLevel - checkFuel() ~= 0 then
539 print("Very Strange Fuel in Restore Section...")
540 print("Current: ",checkFuel())
541 print("Saved: ",fuelLevel)
542 print("Difference: ",fuelLevel - checkFuel())
543 os.pullEvent("char")
544 end
545 end
546 if gpsEnabled then --If it had saved gps coordinates
547 print("Found GPS Start Coordinates")
548 local currLoc = {gps.locate(gpsTimeout)} or {}
549 local backupPos = {xPos, yPos, zPos} --This is for comparing to later
550 if #currLoc > 0 and #gpsStartPos > 0 and #gpsSecondPos > 0 then --Cover all the different positions I'm using
551 print("GPS Position Successfully Read")
552 if currLoc[1] == gpsStartPos[1] and currLoc[3] == gpsStartPos[3] then --X coord, y coord, z coord in that order
553 xPos, yPos, zPos = 0,1,1
554 if facing ~= 0 then turnTo(0) end
555 print("Is at start")
556 else
557 if inverted then --yPos setting
558 ------------------------------------------------FIX THIS
559 end
560 local a, b = copyTable(gpsStartPos), copyTable(gpsSecondPos) --For convenience
561 local flag = true --So we can account for left quarry
562 if b[3] - a[3] == -1 then--If went north (-Z)
563 a[1] = a[1] - 1 --Shift x one to west to create a "zero"
564 xPos, zPos = -currLoc[3] + a[3], currLoc[1] + -a[1]
565 elseif b[1] - a[1] == 1 then--If went east (+X)
566 a[3] = a[3] - 1 --Shift z up one to north to create a "zero"
567 xPos, zPos = currLoc[1] + -a[1], currLoc[3] + -a[3]
568 elseif b[3] - a[3] == 1 then--If went south (+Z)
569 a[1] = a[1] + 1 --Shift x one to east to create a "zero"
570 xPos, zPos = currLoc[3] + a[3], -currLoc[1] + a[3]
571 elseif b[1] - a[1] == -1 then--If went west (-X)
572 a[3] = a[3] + 1 --Shift z down one to south to create a "zero"
573 xPos, zPos = -currLoc[1] + a[1], -currLoc[3] + a[3]
574 else
575 flag = false
576 print("Improper Coordinates")
577 print("GPS Locate Failed, Using Standard Methods") ----Maybe clean this up a bit to use flags instead.
578 end
579 if flag and goLeftNotRight then --This accounts for left quarry (barred to left only because there might be errors in a regular, causing neg/0
580 zPos = math.abs(zPos-1) + 1
581 end
582 end
583 print("X Pos: ",xPos)
584 print("Y Pos: ",yPos)
585 print("Z Pos: ",zPos)
586 print("Facing: ",facing)
587 for i=1, 3, 2 do --We want 1 and 3, but 2 could be coming back to start.
588 if backupPos[i] ~= currLoc[i] then
589 events = {} --We want to remove event queue if not in proper place, so won't turn at end of row or things.
590 end
591 end
592 else
593 print("GPS Locate Failed, Using Standard Methods")
594 end
595 print("Restore File read successfully. Starting in 3"); sleep(3)
596 end
597 else
598 fs.delete(saveFile)
599 print("Restore file was empty, sorry, aborting")
600 error("",0)
601 end
602else --If turtle is just starting
603 events = {} --This is the event queue :D
604 originalFuel = checkFuel() --For use in logging. To see how much fuel is REALLY used
605end
606
607--Dimensions
608if tArgs["-dim"] then
609 local a,b,c = x,y,z
610 local num = tArgs["-dim"]
611 x = tonumber(tArgs[num + 1]) or x; z = tonumber(tArgs[num + 2]) or z; y = tonumber(tArgs[num + 3]) or y
612 if a ~= x then changedT.new("Length", x) end
613 if c ~= z then changedT.new("Width", z) end
614 if b ~= y then changedT.new("Height", y) end
615elseif not (tArgs["-default"] or restoreFoundSwitch) then
616 print("What dimensions?")
617 print("")
618 --This will protect from negatives, letters, and decimals
619 term.write("Length? ")
620 x = math.floor(math.abs(tonumber(io.read()) or x))
621 term.write("Width? ")
622 z = math.floor(math.abs(tonumber(io.read()) or z))
623 term.write("Height? ")
624 y = math.floor(math.abs(tonumber(io.read()) or y))
625 changedT.new("Length",x); changedT.new("Width",z); changedT.new("Height",y)
626end
627--Params: parameter/variable name, display name, type, force prompt, boolean condition, variable name override
628--Invert
629addParam("flatBedrock","Go to bedrock", "boolean") --Not done before GPS because GPS only runs on restart
630addParam("invert", "Inverted","boolean", true, not flatBedrock, "inverted") --Not flat bedrock, because invert will be set to false
631addParam("startDown","Start Down","number 1-256", nil, not flatBedrock)
632addParam("left","Left Quarry","boolean", nil, nil, "goLeftNotRight")
633--Inventory
634addParam("chest", "Chest Drop Side", "side front", nil, nil, "dropSide")
635addParam("enderChest","Ender Chest Slot","slot 16") --Note: All slots can be 16 and they will auto-assign, but I feel it is less confusing if they are always the same
636addParam("fuelChest","Fuel Chest Slot","slot 15")
637--Rednet
638addParam("rednet", "Rednet Enabled","boolean",true, supportsRednet, "rednetEnabled")
639addParam("sendChannel", "Rednet Send Channel", "number 1-65535", false, supportsRednet, "channels.send")
640addParam("receiveChannel","Rednet Receive Channel", "number 1-65535", false, supportsRednet, "channels.receive")
641addParam("fingerprint","Sending Fingerprint", "string", false, supportsRednet, "channels.fingerprint")
642addParam("legacyRednet","Legacy Rednet","boolean", false, supportsRednet)
643--Quad Rotor --Must be before GPS
644if addParam("quad", "Quad Rotor Enabled","boolean",nil, rednetEnabled, "quadEnabled") then --This returns true if param found :3
645 gpsEnabled = true
646end
647addParam("quadTimeout","Quad Rotor Timeout","number 1-1000000", nil, quadEnabled) --The amount of time to wait for a quadRotor
648--GPS
649addParam("gps", "GPS Location Services", "force", nil, (not restoreFoundSwitch) and supportsRednet and not quadEnabled, "gpsEnabled" ) --Has these triggers so that does not record position if restarted.
650if gpsEnabled and not restoreFoundSwitch then
651 gpsStartPos = {gps.locate(gpsTimeout)} --Stores position in array
652 gpsEnabled = #gpsStartPos > 0 --Checks if location received properly. If not, position is not saved
653 if quadEnabled and not gpsEnabled then
654 error("You have no GPS network. You may not use Quad Rotors",0)
655 end
656end
657--Fuel
658addParam("uniqueExtras","Unique Items", "number 0-15")
659addParam("doRefuel", "Refuel from Inventory","boolean", nil, checkFuel() ~= math.huge) --math.huge due to my changes
660addParam("doCheckFuel", "Check Fuel", "boolean", doCheckFuel and fuelChest, checkFuel() ~= math.huge) --Will prompt if doCheckFuel and fuelChest are on. Probably don't want
661excessFuelAmount = excessFuelAmount or math.huge --Math.huge apparently doesn't save properly (Without saving, this is the config, on save it is actually set to nil if math.huge)
662addParam("maxFuel", "Max Fuel", "number 1-999999999", maxFuel == checkFuelLimit() and fuelChest, checkFuel() ~= math.huge, "excessFuelAmount") --Will prompt if fuel chest and the limit isn't changed
663addParam("fuelMultiplier", "Fuel Multiplier", "float 1-9001", nil, checkFuel() ~= math.huge)
664paramAlias("fuelMultiplier","fuelRequestMultiplier")
665paramAlias("fuelMultiplier","overFuel")
666--Logging
667addParam("logging", "Logging", "boolean")
668addParam("logFolder", "Log Folder", "string")
669addParam("logExtension","Log Extension", "string")
670--Misc
671addParam("startY", "Start Y","number 1-256")
672addParam("maxTries","Tries Before Bedrock", "number 1-9001")
673--Inventory
674addParam("keepOpen", "Slots to Keep Open", "number 1-15")
675addParam("careAboutResources", "Care About Resources","boolean")
676addParam("preciseTotals","Precise Totals","boolean", rednetEnabled and turtle.inspect, turtle.getItemDetail ~= nil)
677if preciseTotals and not restoreFoundSwitch then
678 exactTotals = {} --Don't want to initialize if we aren't using this
679end
680--Auto Startup
681addParam("autoResume", "Auto Resume", "boolean", nil, doBackup)
682paramAlias("autoResume","autoRestart")
683addParam("startupRename", "Startup Rename","string", nil, autoResume)
684addParam("startupName", "Startup File", "string", nil, autoResume)
685--Ore Quarry
686addParam("oreQuarry", "Ore Quarry", "boolean" )
687if oreQuarry and not turtle.inspect then
688 oldOreQuarry = true
689 oreQuarry = false
690end
691addParam("lavaBucket","Lava Bucket Slot", "slot 14", nil, oreQuarry)
692paramAlias("lavaBucket","lava")
693paramAlias("lavaBucket","lavaRefuel")
694addParam("lavaBuffer","Lava Buffer","number 1-19999", nil, lavaBucket)
695--Old Ore
696addParam("oldOreQuarry", "Old Ore Quarry", "boolean")
697addParam("dumpCompareItems", "Dump Compare Items", "boolean", nil, oldOreQuarry) --Do not dump compare items if not oreQuarry
698addParam("extraDropItems", "", "force", nil, oldOreQuarry) --Prompt for extra dropItems
699paramAlias("extraDropItems","extraDumpItems") --changed to Dump
700addParam("compareChest","Compare Chest Slot","slot 13", nil, oldOreQuarry)
701addParam("frontChest","Front Chest Check","boolean", nil, compareChest or turtle.insepect) --Does not need oreQuarry, but is similar (does need inspect if not compareChest)
702--New Ore
703addParam("blacklist","Ore Blacklist", "string", nil, oreQuarry, "oreQuarryBlacklistName")
704paramAlias("blacklist","blacklistFile")
705--Mod Related
706
707--Extra
708if tArgs["-testparams"] then
709 screen()
710 print("KEY: VALUE (VARIABLE)")
711 for key, val in ipairs(changedT) do
712 if not val.hidden then
713 print(val[1],": ",val[2]," (",val[3] or "",")")
714 end
715 end
716 error("Done",0)
717end
718
719
720--for flatBedrock
721if flatBedrock then
722 inverted = false
723end
724
725--Auto Startup functions
726local function doAutoResumeStuff()
727 if fs.exists(startupName) then
728 if fs.exists(startupRename) then fs.delete(startupRename) end
729 fs.move(startupName, startupRename)
730 end
731 local file = fs.open(startupName,"w") --Startup File
732 file.writeLine( --The below is on the left because spacing
733[[
734--This is an auto-generated startup
735--Made by civilwargeeky's Variable Size Quarry
736print("Now Resuming Quarry")
737print("Press any key to quit. You have 5 seconds.")
738function deleteStuff()
739 fs.delete("]]..startupName..[[")
740 if fs.exists("]]..startupRename..[[") then
741 fs.move("]]..startupRename.."\",\""..startupName..[[")
742 end
743end
744local event
745if fs.exists("]]..saveFile..[[") then
746 for i=5,1,-1 do
747 print(i)
748 os.startTimer(1)
749 event = os.pullEvent()
750 if event == "key" then break end
751 end
752 if event == "timer" then
753 os.run({},"]]..shell.getRunningProgram()..[[","-resume")
754 else
755
756 deleteStuff()
757 end
758else
759 print("Never mind, no save file found")
760 deleteStuff()
761end
762 ]])
763 file.close()
764end
765if autoResume and not restoreFoundSwitch then --Don't do for restore because would overwrite renamed thing. Can't edit mid-run because no shell in restarted
766 doAutoResumeStuff()
767end
768--oreQuarry blacklist
769local blacklist = { "minecraft:air", "minecraft:bedrock", "minecraft:cobblestone", "minecraft:dirt", "minecraft:ice", "minecraft:ladder", "minecraft:netherrack", "minecraft:sand", "minecraft:sandstone",
770 "minecraft:snow", "minecraft:snow_layer", "minecraft:stone", "minecraft:gravel", "minecraft:grass", "minecraft:torch" }
771for a,b in pairs(copyTable(blacklist)) do
772 blacklist[b], blacklist[a] = true, nil --Switch
773end
774if fs.exists(oreQuarryBlacklistName) then --Loading user-defined blacklist
775 local file = fs.open(oreQuarryBlacklistName, "r")
776 blacklist = {}
777 for a in file:readAll():gmatch("[^,\n]+") do
778 blacklist[a:match("[%w_.]+:[%w_.]+")] = true --Grab only the actual characters, not whitespaces
779 end
780 file:close()
781end
782
783--Manual Position
784if tArgs["-manualpos"] then --Gives current coordinates in xPos,zPos,yPos, facing
785 local a = tArgs["-manualpos"]
786 xPos, zPos, yPos, facing = tonumber(tArgs[a+1]) or xPos, tonumber(tArgs[a+2]) or zPos, tonumber(tArgs[a+3]) or yPos, tonumber(tArgs[a+4]) or facing
787 changedT.new("xPos",xPos); changedT.new("zPos",zPos); changedT.new("yPos",yPos); changedT.new("facing",facing)
788 restoreFoundSwitch = true --So it doesn't do beginning of quarry behavior
789 for i=0,4 do tArgs[a+i] = "" end --Get rid of this argument from future restores
790end
791if addParam("atChest", "Is at Chest", "force") then --This sets position to 0,1,1, facing forward, and queues the turtle to go back to proper row.
792 local neededLayer = math.floor((yPos+1)/3)*3-1 --Make it a proper layer, +- because mining rows are 2, 5, etc.
793 if neededLayer > 2 and neededLayer%3 ~= 2 then --If turtle was not on a proper mining layer
794 print("Last known pos was not in proper layer, restarting quarry")
795 sleep(4)
796 neededLayer = 2
797 end
798 xPos, zPos, yPos, facing, rowCheck, layersDone = 0,1,1, 0, true, math.ceil(neededLayer/3)
799 doAutoResumeStuff() --This was probably deleted when they hit a key to launch with -atChest
800 events = {{"goto",1,1,neededLayer, 0}}
801end
802
803
804local function saveProgress(extras) --Session persistence
805exclusions = { modem = true, shell = true, _ENV = true}
806if doBackup then
807local toWrite = ""
808for a,b in pairs(getfenv(1)) do
809 if not exclusions[a] then
810 --print(a ," ", b, " ", type(b)) --Debug
811 if type(b) == "string" then b = "\""..b.."\"" end
812 if type(b) == "table" then b = textutils.serialize(b) end
813 if type(b) ~= "function" then
814 toWrite = toWrite..a.." = "..tostring(b).."\n"
815 end
816 end
817end
818toWrite = toWrite.."doCheckFuel = false\n" --It has already used fuel, so calculation unnecessary
819local file
820repeat
821 file = fs.open(saveFile,"w")
822until file
823file.write(toWrite)
824if type(extras) == "table" then
825 for a, b in pairs(extras) do
826 file.write(a.." = "..tostring(b).."\n")
827 end
828end
829if checkFuel() ~= math.huge then --Used for location comparing
830 file.write("fuelLevel = "..tostring(checkFuel()).."\n")
831end
832file.close()
833end
834end
835
836local area = x*z
837local volume = x*y*z
838local lastHeight = y%3
839layers = math.ceil(y/3)
840local yMult = layers --This is basically a smart y/3 for movement
841local moveVolume = (area * yMult) --Kept for display percent
842--Calculating Needed Fuel--
843do --Because many local variables unneeded elsewhere
844 local changeYFuel = 2*(y + startDown)
845 local dropOffSupplies = 2*(x + z + y + startDown) --Assumes turtle as far away as possible, and coming back
846 local frequency = math.ceil(((moveVolume/(64*(15-uniqueExtras) + uniqueExtras)) ) ) --This is complicated: volume / inventory space of turtle, defined as 64*full stacks + 1 * unique stacks.
847 --max of 15 full stacks because once one item is picked up, slot is "full". Ceil to count for initial back and forth
848 if enderChest then frequency = 0 end --Never goes back to start
849 neededFuel = moveVolume + changeYFuel + (frequency * dropOffSupplies) + ((x + z) * layers) --x + z *layers because turtle has to come back from far corner every layer
850 neededFuel = neededFuel + fuelTable[fuelSafety] --For safety
851end
852
853if neededFuel > checkFuelLimit() and doCheckFuel then--Checks for if refueling goes over turtle fuel limit
854 if not (doRefuel or fuelChest) then
855 screen()
856 print("Turtle cannot hold enough fuel\n")
857 print("Options: \n1. Select a smaller size \n2. Enable Mid-Run Refueling (RECOMMENDED) \n3. Turn fuel checking off (only if fuel chest) \n4. Do nothing")
858 local _, key = os.pullEvent("char")
859 if key == "1" then
860 screen(); print("Okay"); error("",0)
861 elseif key == "3" then
862 doCheckFuel = false
863 elseif key == "4" then
864 --pass
865 else --Not for number two because this is default
866 doRefuel = true
867 end
868 end
869 neededFuel = checkFuelLimit()-checkFuel()-1
870end
871
872
873--Getting Fuel
874local hasRefueled --This is for oldOreQuarry prompting
875if doCheckFuel and checkFuel() < neededFuel then
876 neededFuel = math.min(math.floor(neededFuel * fuelMultiplier), checkFuelLimit()-checkFuel()-1) --Does the same as above, but not verbose because optional
877 hasRefueled = true
878 print("Not enough fuel")
879 print("Current: ",checkFuel()," Needed: ",neededFuel)
880 print("Starting SmartFuel...")
881 sleep(2) --So they can read everything.
882 term.clear()
883 local oneFuel, neededFuelItems = 0,0 --Initializing Variables
884 local currSlot = 0
885 local function output(text, x, y) --For displaying fuel statistics
886 local currX, currY = term.getCursorPos()
887 term.setCursorPos(x,y)
888 term.clearLine()
889 term.write(text)
890 term.setCursorPos(currX,currY)
891 end
892 local function roundTo(num, target) --For stacks of fuel and turtle slots when undergoing addition/subtraction
893 if num >= target then return target elseif num < 0 then return 0 else return num end
894 end
895 local function updateScreen()
896 output("Welcome to SmartFuel! Now Refueling...", 1,1)
897 output("Fuel Request Multiplier: "..tostring(fuelMultiplier).."x",1,2)
898 output("Currently taking fuel from slot "..currSlot,1,3)
899 output("Current single fuel: "..tostring(oneFuel or 0),1,4)
900 output("Current estimate of needed fuel: ",1,4)
901 output("Single Items: "..math.ceil(neededFuelItems),4,6)
902 output("Stacks: "..math.ceil(neededFuelItems / 64),4,7)
903 output("Needed Fuel: "..tostring(neededFuel),1,12)
904 output("Current Fuel: "..tostring(checkFuel()),1,13)
905 end
906 while checkFuel() < neededFuel do
907 currSlot = currSlot + 1
908 select(currSlot)
909 if currSlot ~= 1 and not turtle.refuel(0) then --If it's not the first slot, and not fuel, go back to start
910 currSlot = 1; select(currSlot)
911 end
912 updateScreen()
913 while turtle.getItemCount(currSlot) == 0 do
914 sleep(1.5)
915 end
916 repeat --TODO