Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- quartz-hunter-verbose.lua
- local TARGET = "ae2:quartz_cluster"
- -- Direction names so the log reads nicely
- local directions = { "north", "east", "south", "west" }
- local heading = 1 -- assume we start facing north
- -- Simple coloured logger (falls back to white on colourless terminals)
- local function log(msg, colour)
- local old = term.getTextColor and term.getTextColor() or colours.white
- if term.isColor and term.isColor() and colour then
- term.setTextColor(colour)
- end
- print(("[%s] %s"):format(textutils.formatTime(os.time(), true), msg))
- if term.isColor and term.isColor() then
- term.setTextColor(old)
- end
- end
- -- Look with inspectFn; if it’s the TARGET, mine it with digFn.
- local function checkAndMine(label, inspectFn, digFn)
- local ok, info = inspectFn()
- if not ok then
- log(label .. ": nothing there", colours.lightGrey)
- return
- end
- if info.name == TARGET then
- log(label .. ": found " .. info.name .. " → mining", colours.lime)
- if digFn() then
- log(label .. ": mined successfully", colours.green)
- else
- log(label .. ": dig failed!", colours.red)
- end
- else
- log(label .. ": saw " .. info.name .. " (ignored)", colours.grey)
- end
- end
- while true do
- for _ = 1, 4 do -- do a full spin
- log(("=== Facing %s ==="):format(directions[heading]), colours.yellow)
- checkAndMine("front", turtle.inspect, turtle.dig)
- checkAndMine("above", turtle.inspectUp, turtle.digUp)
- checkAndMine("below", turtle.inspectDown, turtle.digDown)
- turtle.turnRight()
- heading = heading % 4 + 1 -- keep heading in 1-4
- end
- sleep(1) -- short breather before next sweep
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement