Posted 24 May 2013 - 04:11 PM
Hi, I'm begining in lua and I made a program to automaticaly have obsidian, and put it in a chest.
Here's the code :
If it don't works, here's pastebin : http://pastebin.com/7QKCeCtr
Edit : I forgot it. When I put the number of obsidian I'm looking for, the error appears :
Sorry for my english, I'm french
Thanks for your help
floguaz
Here's the code :
print("How many obsidian ?")
local nombreDemande = read() -- read the number of obsidian requested
local nombreMine = 0 -- number of mined obsidian
term.clear()
term.setCursorPos(1,1)
print("Commande : "..nombreDemande)
while nombreMine <= nombreDemande do
if turtle.getFuelLevel() < 10 then
turtle.select(1)
turtle.refuel(1)
end
turtle.select(2) -- Placing redstone
turtle.forward()
turtle.forward()
turtle.place()
turtle.back()
turtle.place()
turtle.back()
turtle.place()
rs.setOutput("left", true) -- Desactivate piston and lava goes on redstone
sleep(8)
rs.setOutput("left", false) -- Reactivate piston
sleep(2)
if turtle.getFuelLevel() < 10 then
turtle.select(1)
turtle.refuel(1)
end
turtle.dig() -- Mine the obsidian
nombreMine = nombreMine + 1
turtle.forward()
turtle.dig()
nombreMine = nombreMine + 1
turtle.forward()
turtle.dig()
nombreMine = nombreMine + 1
turtle.back() -- Return on the default place
turtle.back()
turtle.select(3) -- Put the obsidian in the chest
turtle.turnRight()
turtle.drop()
turtle.turnLeft()
end
print("Here are your obsidians")
If it don't works, here's pastebin : http://pastebin.com/7QKCeCtr
Edit : I forgot it. When I put the number of obsidian I'm looking for, the error appears :
untitled:9: attempt to compare string with number expected, got string
Sorry for my english, I'm french
Thanks for your help
floguaz
Edited on 24 May 2013 - 03:42 PM