Posted 26 February 2015 - 11:11 PM
i'm trying to make a little program where i can change my mob farm to automated killing with turtles, or manual killing (and the turtles move away). i want to control everything from a central computer next to the turtles.
This is my turtle program:
and this is my computer code:
The one problem i have is that the turtle program keeps giving the error (killer:39: attempt to index ? (a nil value)).
What am I doing wrong?
This is my turtle program:
rednet.open("right")
local place = 0
local function moveTo()
turtle.down()
turtle.forward()
end
local function moveFrom()
turtle.back()
turtle.up()
end
local function check()
while true do
event, text = os.pullEvent()
if event == "rednet_message" then
if text == "KILL" then
if place == 0 then
moveTo()
place = 1
end
else if text == "BACK OFF" then
if place == 1 then
moveFrom()
place = 0
end
end
end
end
end
end --this one is somehow necessary else it will say it expected an end...
local function attack()
while true do
turtle.attack()
end
end
parrallel.waitforAny(attack, check)
and this is my computer code:
rednet.open("back")
while true do
lever = redstone.getInput("right")
if lever == true then
for i = 1, 5 do
rednet.broadcast("KILL")
sleep(0.1)
end
sleep(10)
else
for i = 1, 5 do
rednet.broadcast("BACK OFF")
sleep(0.1)
end
sleep(10)
end
end
(ignore the wierd "end" placement, the site doesn't like my placement somehow.)The one problem i have is that the turtle program keeps giving the error (killer:39: attempt to index ? (a nil value)).
What am I doing wrong?