Posted 25 March 2013 - 05:44 AM
Hi guys i wrote my own mining programm (minenow), but if i try to start it i get this message:
minenow:111: attempt to index ? (a nil value)
minenow (http://pastebin.com/xvUFFhtN):
goto (http://pastebin.com/7rngxspn):
Please help my, i spent to much time and effort in it for now failing and i really need this programm.
I installed it ond a "Wireless Mining Turtle" and i seted 4 "gps computer" up, they're working.
Sorry for my bad english.
Thank you for reading and may for helping me ;)/>
minenow:111: attempt to index ? (a nil value)
minenow (http://pastebin.com/xvUFFhtN):
Spoiler
function invClear()
turtle.select(16)
while not turtle.placeUp() do
turtle.digUp()
end
for i = 1, 14 do
turtle.select(i)
turtle.dropUp()
end
turtle.select(16)
turtle.digUp()
end
function refuel(x)
if x > turtle.getFuelLevel() then
invClear()
turtle.select(15)
while not turtle.placeUp() do
turtle.digUp()
end
end
while x > turtle.getFuelLevel() do
turtle.suckUp()
turtle.refuel()
end
turtle.select(15)
turtle.digUp()
end
function mine(x)
refuel(x + 10)
for i = 1, x do
if turtle.getItemCount(12) > 0 then
invClear()
end
while not turtle.forward() do
turtle.dig()
end
while turtle.detectUp() do
turtle.digUp()
end
turtle.digDown()
end
end
function turn()
if Richtung == "r" then
turtle.turnRight()
mine(1)
turtle.turnRight()
Richtung = "l"
else
turtle.turnLeft()
mine(1)
turtle.turnLeft()
Richtung = "r"
end
end
function calcx()
if (mgox - mendx) >= 0 then
return mgox - mendx
else
return mendx - mgox
end
end
function calcy()
if (mgoy - mendy) >= 0 then
return mgoy - mendy
else
return mendy - mgoy
end
end
function calcz()
if (mgoz - mendz) >= 0 then
return mgoz - mendz
else
return mendz - mgoz
end
end
function calcstart()
rednet.open("right")
cx, cy, cz = gps.locate(3)
if (mgox - cx) >= 0 then
x = mgox - cx
else
x = cx - mgox
end
if (mgoy - cy) >= 0 then
y = mgoy - cy
else
y = cy - mgoy
end
if (mgoz - cz) >= 0 then
z = mgoz - cz
else
z = cz - mgoz
end
return x + y + z + 200
end
function getvariables()
cx, cy, cz = gps.locate(3)
mnx = mgox
mnz = cz
file = fs.open("y", "r")
mny = file.readLine()
file.close()
mny = mny + 0
file = fs.open("end", "r")
ended = file.readLine()
file.close()
ended = ended + 0
end
function start()
if turtle.getItemCount(16) > 0 then
refuel(calcstart())
shell.run("goto", mgox, mgoy + 2, mgoz, "1")
turtle.select(13)
turtle.transferTo(16, 1)
else
refuel(calcx + calcz + 50)
shell.run("goto", mnx, mny + 2, mnz, "1")
end
for i = 1, 2 do
while not turtle.down() do
turtle.digDown()
end
end
end
function debug()
if turtle.getItemCount(16) > 0 then
turtle.select(15)
turtle.digUp()
elseif turtle.getItemCount(13) > 0 then
else
turtle.select(16)
turtle.digUp()
end
end
function nexty(x)
mny = mny - x
file = fs.open("y", "w")
file.writeLine(mny)
file.close()
end
function newy()
cx, cy, cz = gps.locate()
if cy - 4 >= mendy then
nexty(3)
elseif cy - 3 == mendy then
nexty(2)
elseif cy - 2 == mendy then
nexty(1)
else
file = fs.open("end", "w")
file.writeLine(1)
file.close()
end
end
function back()
invClear()
turtle.select(16)
turtle.transferTo(13, 1)
start()
turtle.up()
turtle.up()
end
function chegz()
cx, cy, cz = gps.locate(3)
if mendz - cz ~= 0 then
return true
else
return false
end
end
function createfile()
file = fs.open("y", "r")
if file.readLine() then
else
file.close()
file = fs.open("y", "w")
file.writeLine(mgoy)
file.close()
end
file = fs.open("end", "r")
if file.readLine() then
else
file.close()
file = fs.open("end", "w")
file.writeLine(0)
file.close()
end
end
mgox = -145
mendx = -135
mgoy = 240
mendy = 230
mgoz = 77
mendz = 67
Richtung = "r"
os.loadAPI("mine")
debug()
getvariables()
while ended == 0 do
start()
while chegz() do
mine(calcx())
turn()
end
mine(calcx())
newy()
getvariables()
end
back()
goto (http://pastebin.com/7rngxspn):
Spoiler
local ziel = {...}
local zx = ziel[1]
local zy = ziel[2]
local zz = ziel[3]
local zdirect = ziel[4]
zx = zx +0
zy = zy +0
zz = zz +0
zdirect = zdirect +0
rednet.open("right")
local fx, fy, fz = gps.locate(3)
for i = 1, 4 do
if turtle.forward() then
sx, sy, sz = gps.locate(3)
direct = nil
if fz < sz then
direct = 0
elseif fz > sz then
direct = 2
elseif fx > sx then
direct = 1
elseif fx < sx then
direct = 3
end
break
else
turtle.turnRight()
end
end
function turn(ndirect)
while ndirect ~= direct do
turtle.turnRight()
if direct ~= 3 then
direct = direct + 1
else
direct = 0
end
end
end
if direct ~= nil then
local fail = 0
function z0()
if zz > sz then
turn(0)
if turtle.forward() then
sz = sz + 1
fail = 0
z0()
else
x1()
end
else
x1()
end
end
function x1()
if zx < sx then
turn(1)
if turtle.forward() then
sx = sx - 1
fail = 0
x1()
else
z2()
end
else
z2()
end
end
function z2()
if zz < sz then
turn(2)
if turtle.forward() then
sz = sz - 1
fail = 0
z2()
else
x3()
end
else
x3()
end
end
function x3()
if zx > sx then
turn(3)
if turtle.forward() then
sx = sx + 1
fail = 0
x3()
else
yu()
end
else
yu()
end
end
function yu()
if fail ~= 1 then
if zy > sy then
if turtle.up() then
sy = sy + 1
fail = 0
yu()
else
yd()
end
else
yd()
end
elseif zy ~= sy then
else
turtle.up()
sy = sy + 1
z0()
end
end
function yd()
if zy < sy then
if turtle.down() then
sy = sy - 1
fail = 0
yd()
else
cheg()
end
else
cheg()
end
end
function cheg()
if fail == 1 then
if zx == sx then
if zy == sy then
if zz == sz then
print("Ich bin angekommen und schalte ab!")
else
print("fail")
end
else
print("fail")
end
else
print("fail")
end
else
if fail == 0 then
if zx == sx then
if zy == sy then
if zz == sz then
print("Ich bin angekommen und schalte ab!")
else
fail = 1
z0()
end
else
fail = 1
z0()
end
else
fail = 1
z0()
end
end
end
end
z0()
turn(zdirect)
else
print("I need space arround me!")
end
Please help my, i spent to much time and effort in it for now failing and i really need this programm.
I installed it ond a "Wireless Mining Turtle" and i seted 4 "gps computer" up, they're working.
Sorry for my bad english.
Thank you for reading and may for helping me ;)/>