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!
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
Can somebody check out what is wrong with fuel? I can't seem to resolve the issue :/
Just so you know it will be impossible to calculate exactly how much fuel it will use as its inventory might become full forcing it to go back up before you predicted it would. This will cause it to use more fuel than you expect. The only way around this is for it to use a enderchest only if it uses normal chests to store which is a feature that you have it will not work.
(((((x-1)*2)) * z)+((2*z)-2)) * y)+y-1 This right here is the equation required only for digging the area out
x+z+y-3 This is equation for fuel required to get back to home position assuming you use most efficient route to get back This might fix the calculation for perfect world scenario.
This calculation was done quickly based on the fact that in a 5 x 5 grid a turtle would have to move 44 times to move the entire area. (((5-1)*2) * 5)+(4)) = 44 the equation above also includes the fuel required to get back to the home x and z coords but the one i worked out does not
If you wish me to explain this equation i can, but for sake of time i am not going to right now This equation only will work for the way that the program is set up in the video if the mining pattern has been changed at all this equation will not work
Can somebody check out what is wrong with fuel? I can't seem to resolve the issue :/
Just so you know it will be impossible to calculate exactly how much fuel it will use as its inventory might become full forcing it to go back up before you predicted it would. This will cause it to use more fuel than you expect. The only way around this is for it to use a enderchest only if it uses normal chests to store which is a feature that you have it will not work.
Well, at that time it needs ender chests to work. I will try your method of calculating out, I don't know if it fit the code though. It should work though
Can somebody check out what is wrong with fuel? I can't seem to resolve the issue :/
Just so you know it will be impossible to calculate exactly how much fuel it will use as its inventory might become full forcing it to go back up before you predicted it would. This will cause it to use more fuel than you expect. The only way around this is for it to use a enderchest only if it uses normal chests to store which is a feature that you have it will not work.
Well, at that time it needs ender chests to work. I will try your method of calculating out, I don't know if it fit the code though. It should work though
make sure to use the most recent i updated it some where around 10 times
also if you wish you could come onto my server and i could help you with it if you need help http://www.computerc...tive-valicraft/ -- server information
Can somebody check out what is wrong with fuel? I can't seem to resolve the issue :/
Just so you know it will be impossible to calculate exactly how much fuel it will use as its inventory might become full forcing it to go back up before you predicted it would. This will cause it to use more fuel than you expect. The only way around this is for it to use a enderchest only if it uses normal chests to store which is a feature that you have it will not work.
Well, at that time it needs ender chests to work. I will try your method of calculating out, I don't know if it fit the code though. It should work though
Fail...
Gives me this
bios:339: [string "quarry"]:64:
unexpected symbol
Current code is:
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 = { ... }
x = tonumber(arg[1])
y = tonumber(arg[2])
z = tonumber(arg[3])
local fuel = turtle.getFuelLevel()
local fuelNeeded = ((((x-1)*2))*z)+(2*z-2))*y
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)
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
dumpIntoChest()
end
valithor, on 02 November 2013 - 12:34 AM, said:
deFENCE_, on 02 November 2013 - 12:28 AM, said:
valithor, on 02 November 2013 - 12:13 AM, said:
deFENCE_, on 31 October 2013 - 05:05 AM, said:
Can somebody check out what is wrong with fuel? I can't seem to resolve the issue :/
Just so you know it will be impossible to calculate exactly how much fuel it will use as its inventory might become full forcing it to go back up before you predicted it would. This will cause it to use more fuel than you expect. The only way around this is for it to use a enderchest only if it uses normal chests to store which is a feature that you have it will not work.
Well, at that time it needs ender chests to work. I will try your method of calculating out, I don't know if it fit the code though. It should work though
make sure to use the most recent i updated it some where around 10 times
also if you wish you could come onto my server and i could help you with it if you need help http://www.computerc...tive-valicraft/ -- server information
Can somebody check out what is wrong with fuel? I can't seem to resolve the issue :/
The movement makes the calculation harder. If at the end of a row, instead of having the turtle come back to the starting place and then moving over, it just moved over and dug on its way back, the fuel would be (height * width * length). You've made it traverse every block twice, basically, so it is (height * width * length * 2).
Can somebody check out what is wrong with fuel? I can't seem to resolve the issue :/
The movement makes the calculation harder. If at the end of a row, instead of having the turtle come back to the starting place and then moving over, it just moved over and dug on its way back, the fuel would be (height * width * length). You've made it traverse every block twice, basically, so it is (height * width * length * 2).
The problem is, it isn't height*2, it is (height-1)*2 because if it is 5 long, it goes 4 blocks forward. Then it goes 4 blocks backward. I have thought of ((height-1) * width * length * 2) too, but that didn't work sadly.