Posted 23 March 2013 - 07:39 AM
Good day!
I try to create a melee turtle with the code:
http://pastebin.com/NFj2Taja
Script at startup every time writing
Farm:72: attempt to index ? (a nil value)
Thank you very much in advance for your help!
I try to create a melee turtle with the code:
http://pastebin.com/NFj2Taja
Spoiler
local junkItem = true
local count = 0
local sides = {"top","bottom","right","left","back"}
term.clear()
term.setCursorPos(1,1)function drop(side)
if side == "left" then
turtle.turnLeft()
turtle.drop()
turtle.turnRight()
elseif side == "right" then
turtle.turnRight()
turtle.drop()
turtle.turnLeft()
elseif side == "top" then
turtle.dropUp()
elseif side == "bottom" then
turtle.dropDown()
elseif side == "back" then
turtle.turnLeft()
turtle.turnLeft()
turtle.drop()
turtle.turnLeft()
turtle.turnLeft()
end
end
print("Welcome to Engineer's mob destroyer!")if turtle.getItemCount(1) == 0 and junkItem == true then
print("Put in slot 1 your 'junk' item")
while true do
if turtle.getItemCount(1) > 0 then
break
end
sleep(0)
end
end
if not fs.exists("/chestPositions") then
local ask_junk = true
local ask_misc = true
while ask_junk do
term.setCursorPos(1, 3)
term.clearLine()
print("What side is your 'junk' chest?")
junkSide = string.lower(read())
for i = 1, 5 do
if junkSide == sides[i] then
ask_junk = false
break
end
end
end
while ask_misc do
term.setCursorPos(1, 4)
term.clearLine()
print("What side is your good items chest?")
goodSide = string.lower(read())
for i = 1, 5 do
if goodSide == sides[i] then
ask_misc = false
break
end
end
end
local tTable = {}
tTable.junkSide = junkSide
tTable.goodSide = goodSide
local file = fs.open("/chestPositions", "w")
textutiles.serialize(tTable) (<=== 72 Line)
file.close()
elseif fs.exists("/chestPositions") then
local file = fs.open("/chestPositions", "r")
local handler = file.readAll()
junkSide = handler.junkSide
goodSide = handler.goodSide
file.close()
end
while true do
turtle.select(2)
turtle.attack()
if turtle.getItemCount(16) > 0 then
for i = 2, 16 do
local counter = turtle.getItemCount(i)
count = count + counter
term.setCursorPos(1,4)
term.clearLine()
print("Loots collected: "..count)
turtle.select(i)
if turtle.compareTo(1) then
drop(junkSide)
else
drop(goodSide)
end
end
end
sleep(.5)
end
Script at startup every time writing
Farm:72: attempt to index ? (a nil value)
Thank you very much in advance for your help!