Posted 26 June 2012 - 04:51 PM
Hello CC forum.
I am MaryuZ and I've been playing minecraft with the Tekkit mod-pack for about 3 months now.
Today I've decided to learn about CC and use it in my Minecraft so I head over to the wiki and had a read.
I'm no stranger to coding i have some experience in C and C++ but none in Lua.
So I wrote a small program for a turtle that I would like to use.
I thought I had it all figured out but the turtle just doesn't do what I expect it to do.
I wanted a program that digs out an square area of height 2 (K x K x 2) centered on where i place the turtle until the turtles inventory is full. I would use this to clear out areas at map height 11 because that's where the lava is and I use lava to power my IC2 machines.
I decided i'll settle just for one that digs at first and do with the inventory checks after i get it to dig.
Here's what I wrote and it doesn't seem to work…I really don't know what i'm missing
dig, turn, dig, turn, dig 2 blocks, turn, dig 2 blocks, turn, dig 3 blocks, turn, dig 3 blocks, turn, etc.
Can someone with more experience in lua please tell me what i'm doing wrong?
Just read a tutorial on this forum and realised how stupid my gravel detection system is because it's checking above and after it has moved forward….instead on in front and before it has moved forward….but that's not the problem i tested this in 3 deep dirt and still doesn't work so even if I fix this it still won't work…it just stops after it digs one block in front of the turtle.
I am MaryuZ and I've been playing minecraft with the Tekkit mod-pack for about 3 months now.
Today I've decided to learn about CC and use it in my Minecraft so I head over to the wiki and had a read.
I'm no stranger to coding i have some experience in C and C++ but none in Lua.
So I wrote a small program for a turtle that I would like to use.
I thought I had it all figured out but the turtle just doesn't do what I expect it to do.
I wanted a program that digs out an square area of height 2 (K x K x 2) centered on where i place the turtle until the turtles inventory is full. I would use this to clear out areas at map height 11 because that's where the lava is and I use lava to power my IC2 machines.
I decided i'll settle just for one that digs at first and do with the inventory checks after i get it to dig.
Here's what I wrote and it doesn't seem to work…I really don't know what i'm missing
function dig2()
turtle.dig()
turtle.forward()
while turtle.detectUp() do
"this is for gravel removal if gravel is above the unit"
turtle.digUp()
end
end
local i=0
print("How big a square?")
i=read()
for j=1,i
while j>0 do
dig2()
j=j-1
end
turtle.turnRight()
j=i
while j>0 do
dig2()
j=j-1
end
turtle.turnRight()
end
print("done")
with this code i was expecting the turtle to do this:dig, turn, dig, turn, dig 2 blocks, turn, dig 2 blocks, turn, dig 3 blocks, turn, dig 3 blocks, turn, etc.
Can someone with more experience in lua please tell me what i'm doing wrong?
Just read a tutorial on this forum and realised how stupid my gravel detection system is because it's checking above and after it has moved forward….instead on in front and before it has moved forward….but that's not the problem i tested this in 3 deep dirt and still doesn't work so even if I fix this it still won't work…it just stops after it digs one block in front of the turtle.