Posted 01 July 2014 - 04:05 PM
hello all trying to get a little help i just started making functions and am having a little bit of a time trying to send a string through a veriable can anyone help me do so here is my code that i need with some notes
function test()
os.loadAPI("rom/apis/rednet")
rednet.open("right")
com = rednet.isOpen("right")
if com == true then
print("communication established")
print("testing connections")
rednet.send(21, "test")
event,id, message = os.pullEvent("rednet_message")
if id ==21 and message== "test" then
print("communication good")
rednet.send(18, "test")
event,id, message = os.pullEvent("rednet_message")
if id ==18 and message== "test" then
print("communication good")
else
print("message error")print(id)print(message)
end
else
print("message error")print(id)print(message)
end
else
print("communication error")
end
end
--###############################################
function isOpen(messageSend, idnum)
rednet.open("right")
com = rednet.isOpen("right")
if com == true then
rednet.send(messageSend, idnum)-- need to send message as string and idnum as number
else
print("communication error")
end
end
--###############################
function isRec(messageRec, idnum)
event,id, message = os.pullEvent("rednet_message")
if id ==idnum and message== messagerec then
return true
else
return false
end
end
--################################
function plant()
redstone.setOutput("top", true)
sleep(15)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(15)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(15)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(15)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(15)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(15)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(15)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(15)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(3)
redstone.setOutput("back", true)
sleep(2)
redstone.setOutput("back", false)
sleep(3)
redstone.setOutput("back", true)
sleep(2)
redstone.setOutput("back", false)
sleep(1)
redstone.setOutput("top", true)
sleep(1)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(1)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(1)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(1)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(1)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(1)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(1)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
sleep(1)
redstone.setOutput("top", true)
sleep(1)
redstone.setOutput("top", false)
redstone.setOutput("top", false)
end
--################################
while true do
os.loadAPI("rom/apis/rednet")
test()
print("supply and enable processing")
isOpen(supply, 21) -- need to send word as string into veriable and number as number
if not isRec(supply, 21) then --need to recieve word as string and number as number
print("message error")print(id)print(message)
else
print("supply complete")
print("planting")
isOpen(plant, 18)
if not isRec(plant, 18) then
print("message error")print(id)print(message)
else
print("bot planting")
plant()
sleep(1)
redstone.setOutput("bottom", false)
print("disable processing")
isOpen(harvest, 21)
if not isRec(harvest, 21) then
print("message error")print(id)print(message)
else
print("harvest Complete")
isOpen(supply, 21)
if not isRec(supply, 21) then
else
print("supply complete")
end
end
end
end
end
--#############################
if anyone can help me it would be most appreciated