Posted 07 June 2012 - 04:12 AM
I'm getting the following error: (copied exactly from turtle)
disk> test
bios:206: [string "miner"]:89:
unexpected symbol
test:3: attempt to index ? (a nil value)
disk>
Here is my code:
miner
test
Any help would be very appreciated.
disk> test
bios:206: [string "miner"]:89:
unexpected symbol
test:3: attempt to index ? (a nil value)
disk>
Here is my code:
miner
[spoiler]function mineForward1()<br>&nbsp;&nbsp;while(turtle.forward()==false) do<br>&nbsp;&nbsp;&nbsp;&nbsp;turtle.dig()<br>&nbsp;&nbsp;&nbsp;&nbsp;sleep(0.3)<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;return true<br>end<br>function mineForward(n)<br>&nbsp;&nbsp;local i = 0<br>&nbsp;&nbsp;while(i&lt;n) do<br>&nbsp;&nbsp;&nbsp;&nbsp;mineForward1()<br>&nbsp;&nbsp;&nbsp;&nbsp;i = i + 1<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;return true<br>end<br>function mineUp1()<br>&nbsp;&nbsp;while(turtle.up()==false) do<br>&nbsp;&nbsp;&nbsp;&nbsp;turtle.digUp()<br>&nbsp;&nbsp;&nbsp;&nbsp;sleep(0.3)<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;return true<br>end<br>function mineUp(n)<br>&nbsp;&nbsp;local i = 0<br>&nbsp;&nbsp;while(i&lt;n) do<br>&nbsp;&nbsp;&nbsp;&nbsp;mineUp1()<br>&nbsp;&nbsp;&nbsp;&nbsp;i = i + 1<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;return true<br>end<br>function mineDown1()<br>&nbsp;&nbsp;while(turtle.down()==false) do<br>&nbsp;&nbsp;&nbsp;&nbsp;turtle.digDown()<br>&nbsp;&nbsp;&nbsp;&nbsp;sleep(0.3)<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;return true<br>end<br>function mineDown(n)<br>&nbsp;&nbsp;local i = 0<br>&nbsp;&nbsp;while(i&lt;n) do<br>&nbsp;&nbsp;&nbsp;&nbsp;mineDown1()<br>&nbsp;&nbsp;&nbsp;&nbsp;i = i + 1<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;return true<br>end<br>function backUp(n)<br>&nbsp;&nbsp;local i = 0<br>&nbsp;&nbsp;while(i&lt;n) do<br>&nbsp;&nbsp;&nbsp;&nbsp;while(turtle.back()==false) do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(0.1)<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;i = i + 1<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;return true<br>end<br>function turnAround()<br>&nbsp;&nbsp;turtle.turnLeft()<br>&nbsp;&nbsp;turtle.turnLeft()<br>&nbsp;&nbsp;return true<br>end<br>function place(n)<br>&nbsp;&nbsp;turtle.select(n)<br>&nbsp;&nbsp;turtle.place()<br>&nbsp;&nbsp;return true<br>end<br>function digRoomLayer(width, PT)<br>&nbsp;&nbsp;for i=1, width-2 do<br>&nbsp;&nbsp;&nbsp;&nbsp;mineForward(i)<br>&nbsp;&nbsp;&nbsp;&nbsp;turtle.turnLeft()<br>&nbsp;&nbsp;&nbsp;&nbsp;mineForward(i)<br>&nbsp;&nbsp;&nbsp;&nbsp;turtle.turnLeft()<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;for i=1, 3 do<br>&nbsp;&nbsp;&nbsp;&nbsp;mineForward((n-1)/2+1)<br>&nbsp;&nbsp;&nbsp;&nbsp;if PT then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;turnAround()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;place(1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;turnAround()<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;mineForward((n-1)/2)-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;turtle.turnLeft()<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;mineForward(2)<br>&nbsp;&nbsp;turtle.turnRight()<br>&nbsp;&nbsp;backUp(1)<br>&nbsp;&nbsp;if PT then<br>&nbsp;&nbsp;&nbsp;&nbsp;place(1)<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;backUp((n-1)/2-1)<br>&nbsp;&nbsp;return true<br>end<br>function digRoom(width, height)<br>&nbsp;&nbsp;digRoomLayer(width, true)<br>&nbsp;&nbsp;for i=1, height-1 do<br>&nbsp;&nbsp;&nbsp;&nbsp;mineDown(1)<br>&nbsp;&nbsp;&nbsp;&nbsp;digRoomLayer(width, false)<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;return true<br>end[/spoiler]
test
os.loadAPI("miner")
miner.mineForward(10)
miner.mineUp(1)
miner.digRoom(5, 3)
miner.turnAround()
miner.mineForward(10)
miner.turnAround()
miner.mineUp(1)
os.unloadAPI("miner")
Any help would be very appreciated.