14 posts
Posted 18 November 2012 - 10:53 AM
Hello, I've been looking for a decent excavate program that only uses one turtle that is decently fast and fuel efficient. Then I had the idea of why not just see if the default Excavate could be adjusted to be more efficient because it works great as is. Basically I'm not all that great a code, I tried to figure out the code of the default and failed really bad. My only idea was to make it so that the turtle mines three blocks at a time instead of the one block that it currently mines. Kinda like this
http://i.imgur.com/eKqCJ.png but that's all. Thanks for any help you can give.
2088 posts
Location
South Africa
Posted 18 November 2012 - 11:27 AM
So what exactly do you want? Do you want help on how to code it to mine the 3 blocks at a time?
14 posts
Posted 18 November 2012 - 12:38 PM
Yes sorry I wasn't really specific on what I need help with. Yes I need help knowing where to change the code and what to do in order to get that three block pattern
2088 posts
Location
South Africa
Posted 18 November 2012 - 01:45 PM
Oh thats easy, heres a simple code I quickly made for you:
(I wish turtles could use colour text :)/>/>)
Pastebinor
Raw codeSpoiler
args = {...}
if not args[1] then
print("Usage:nex <distance>")
return
end
t = 0
dist = tonumber(args[1])
x, y = term.getSize()
term.clear()
m = "Simple Excavation program"
term.setCursorPos((x - #m)/2, y / 2 - 1)
print(m)
m = "Mining " .. dist .. " blocks forward"
term.setCursorPos((x - #m)/2, y / 2)
print(m)
m = "Fuel level: " .. turtle.getFuelLevel()
term.setCursorPos((x - #m)/2, y / 2 + 1)
print(m)
m = "Total mined: " .. t
term.setCursorPos((x - #m)/2, y / 2 + 2)
term.clearLine()
print(m)
function refuel()
term.setCursorPos(1,1) term.clearLine()
print("Please refuel me...")
repeat
term.setCursorPos(1,2) term.clearLine()
write("Which slot: ")
slot = tonumber(read())
until slot ~= nil and slot > 0 and slot <= 16
turtle.select(slot)
term.setCursorPos(1,2) term.clearLine()
term.setCursorPos(1,1) term.clearLine()
if turtle.refuel() then write("Refueled! Fuel level is now " .. turtle.getFuelLevel() .. ".") else write("No available fuel in that slot.") sleep(1.25) return refuel() end
sleep(1.25)
term.clearLine()
end
function updateFuelAndBlocks()
m = "Fuel level: " .. turtle.getFuelLevel()
term.setCursorPos((x - #m)/2, y / 2 + 1)
term.clearLine()
print(m)
m = "Total mined: " .. t
term.setCursorPos((x - #m)/2, y / 2 + 2)
term.clearLine()
print(m)
end
function main()
for i = 1, dist do
if turtle.getFuelLevel() < 5 then refuel() end
if turtle.detect() then turtle.dig() t = t + 1 end
turtle.forward()
if turtle.detectUp() then turtle.digUp() t = t + 1 end
if turtle.detectDown() then turtle.digDown() t = t + 1 end
updateFuelAndBlocks()
end
end
main()
-- Clean up
term.clear()
term.setCursorPos(1,1)
print("Mined a total of " .. t .. " blocks.n")
PicturesSpoiler
While it's digging:
Spoiler
When it's done:
Spoiler