Posted 30 October 2013 - 08:54 AM
Hi everybody! I started a new survival world and didn't have enough materials to make a BC quarry with engines. However, I had tons of coal and a few diamonds and a house under the ice and a bit of coding knowledge from java :)/>. So I started to script this little quarry.
Usage: quarry <length> <width> <height>
Features:
+Variable size
+Calculates fuel usage (broken)
+Doesn't start if you don't have enough fuel
+Ender Chest Support! They go into slot 16!
Demo Videos:
[media]http://youtu.be/S_bMF1FsrOI[/media]
[media]http://youtu.be/Iwev1y2uiKM[/media]
Version 0.0.0000000001 alpha: http://pastebin.com/C3vLZEdM
Version 0.0.0000000002 alpha: http://pastebin.com/7vQjFQT7
Version 0.0.01 beta: http://pastebin.com/XhfhG8XH
Version 0.0.02 beta: http://pastebin.com/cJBrhLwv
Version 0.0.03 beta: http://pastebin.com/t2CCnSL9
Changelog:
Current code:
Please test this out and report bugs back to me!
-deFENCE
Usage: quarry <length> <width> <height>
Features:
+Variable size
+Calculates fuel usage (broken)
+Doesn't start if you don't have enough fuel
+Ender Chest Support! They go into slot 16!
Demo Videos:
[media]http://youtu.be/S_bMF1FsrOI[/media]
[media]http://youtu.be/Iwev1y2uiKM[/media]
Version 0.0.0000000001 alpha: http://pastebin.com/C3vLZEdM
Version 0.0.0000000002 alpha: http://pastebin.com/7vQjFQT7
Version 0.0.01 beta: http://pastebin.com/XhfhG8XH
Version 0.0.02 beta: http://pastebin.com/cJBrhLwv
Version 0.0.03 beta: http://pastebin.com/t2CCnSL9
Changelog:
0.0.03:
+Fixed a crash with nil params
+Added unlimited fuel support!
-Removed dungeon loot raiding
0.0.02:
+Added dungeon chest support!
[i][u][b][color=#ff0000]Don't use this if you don't want to get dungeon loot! This is slower than 0.0.01![/color][/b][/u][/i]
0.0.01:
+Added Ender Chest support
+Fixed fuel calculation (hopefully) Nope, still broken :/
Out of alpha stage! Finally!
0.0.0000000002: Fixed last bit of code not being inside the main loop and executing even if there is not enough fuel
0.0.0000000001: Initial release
Current code:
Spoiler
function dumpIntoChest()
turtle.select(16)
turtle.placeUp()
for i = 1, 15 do
turtle.select(i)
turtle.dropUp()
end
turtle.select(16)
turtle.digUp()
turtle.select(1)
end
function digStripe(length)
for xDec = 1, length - 1 do
if turtle.getItemCount(15) > 0 then
dumpIntoChest()
end
turtle.digDown()
turtle.forward()
end
turtle.digDown()
turtle.turnRight()
turtle.turnRight()
for xDec = 1, length - 1 do
turtle.forward()
end
turtle.turnRight()
turtle.turnRight()
end
function digSquare(length, width)
for yDec = 1, width -1 do
digStripe(length)
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
digStripe(length)
turtle.turnLeft()
for yDec = 1, width - 1 do
turtle.forward()
end
turtle.turnRight()
end
function digCube(length, width, height)
for zDec = 1, height - 1 do
digSquare(length, width)
turtle.down()
end
digSquare(length, width)
for zDec = 1, height - 1 do
turtle.up()
end
end
local arg = { ... }
if #arg == 3 then
x = tonumber(arg[1])
y = tonumber(arg[2])
z = tonumber(arg[3])
local fuel = turtle.getFuelLevel()
if fuel == "unlimited" then
fuel = 0
fuelNeeded = -1
else
fuelNeeded = ((((x-1)*2)+1) * (y-1) * z + z - 1)
end
--print (x..y..z)
print("Quarrying out area")
print("Dimensions:")
print("x: "..x)
print("y: "..y)
print("z: "..z)
print("")
print("Fuel: "..fuel)
print("Fuel needed: "..fuelNeeded)
print("")
if fuel < fuelNeeded then
print("Please refuel me! I need a minimum of "..fuelNeeded.." fuel!")
else
--Main quarry program
digCube(x, y, z)
if turtle.getFuelLevel() == "unlimited" then
print("Unlimited fuel, fuel calculation disabled!")
else
fuelReallyNeeded = fuel - turtle.getFuelLevel()
print("Fuel after quarrying: "..turtle.getFuelLevel())
print("Fuel needed: "..fuelReallyNeeded)
if fuelReallyNeeded == fuelNeeded then
print("Fuel needed equals what I calculated!")
else
print("Aww shit. I calculated the wrong fuel usage! :-[")
print("Creepers may kill me")
end
end
dumpIntoChest()
end
else
print("Usage: quarry <length> <width> <height>")
print("[stderr] Wrong parameters.")
end
Please test this out and report bugs back to me!
-deFENCE
Edited on 01 December 2013 - 05:19 AM