Posted 01 December 2012 - 12:26 PM
Hello everyone. This is my first attempt at creating a multi turtle quarry clearing system. For some reason the program on my computer will end after entering a Bot number. FYI the turtles rednet is already open and getJob() function has been ran. Thanks in advance!
I want it to:
1. pass the bot number choice into the callBot() function from the event pull
2. have the "Enter Job" text appear and ask for job number
3. send the x,y,zed coordinates to the respective turtle
Computer code program "Manage"
[php]choice = 0
botNum = 0
function clear()
term.clear()
term.setCursorPos(1,1)
end
function callBot(choice)
if choice == 1 then
rednet.send(21,"yes")
term.setCursorPos(1,1)
print("Enter Job #")
local jobNum1 = 1
local input = read("*")
if input == jobNum1 then
print("Sending Bot #"..choice.." to Job #"..input)
rednet.send(21,-9)
rednet.send(21,-122)
rednet.send(21,62)
else
print("Invalid Job #")
mainmenu()
end
end
end
function mainmenu()
print("Enter Bot# (1-2) ")
event,botNum = os.pullEvent("char")
if botNum == "1" then
clear()
sleep(1)
choice = botNum
term.setCursorPos(1,1)
callBot(choice)
else
clear()
sleep(1)
print("Bot out of order")
mainmenu()
end
end
mainmenu()[/php]
Turtle function that checks for job number:
[php]function getJob()
while jobAvailable do
id,message = rednet.receive()
if message == "yes" then
id,qx = rednet.receive()
id,qz = rednet.receive()
id,qy = rednet.receive()
digQuarry(qx,qz,qy)
elseif message == "no" then
jobAvailable = false
end
end
end
getJob()[/php]
I want it to:
1. pass the bot number choice into the callBot() function from the event pull
2. have the "Enter Job" text appear and ask for job number
3. send the x,y,zed coordinates to the respective turtle
Computer code program "Manage"
[php]choice = 0
botNum = 0
function clear()
term.clear()
term.setCursorPos(1,1)
end
function callBot(choice)
if choice == 1 then
rednet.send(21,"yes")
term.setCursorPos(1,1)
print("Enter Job #")
local jobNum1 = 1
local input = read("*")
if input == jobNum1 then
print("Sending Bot #"..choice.." to Job #"..input)
rednet.send(21,-9)
rednet.send(21,-122)
rednet.send(21,62)
else
print("Invalid Job #")
mainmenu()
end
end
end
function mainmenu()
print("Enter Bot# (1-2) ")
event,botNum = os.pullEvent("char")
if botNum == "1" then
clear()
sleep(1)
choice = botNum
term.setCursorPos(1,1)
callBot(choice)
else
clear()
sleep(1)
print("Bot out of order")
mainmenu()
end
end
mainmenu()[/php]
Turtle function that checks for job number:
[php]function getJob()
while jobAvailable do
id,message = rednet.receive()
if message == "yes" then
id,qx = rednet.receive()
id,qz = rednet.receive()
id,qy = rednet.receive()
digQuarry(qx,qz,qy)
elseif message == "no" then
jobAvailable = false
end
end
end
getJob()[/php]