This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
waffles05's profile picture

Lua Code Error! Rednet

Started by waffles05, 02 May 2012 - 04:12 PM
waffles05 #1
Posted 02 May 2012 - 06:12 PM
Im trying to make a program that sends a message over rednet to a turtle. When the message is recieved by the turtle it runs a program. How do i do this?
kazagistar #2
Posted 02 May 2012 - 07:04 PM
The turtle has to be running a program that is listening for messages. You can test if it is the right message with a if statement, and then use shell.run() to run your program.
Dirkus7 #3
Posted 02 May 2012 - 10:07 PM
Something like this:

rednet.open('right')
event, sender, msg = os.pullEvent('rednet_message')
if sender == 5  then --change to the id of the host computer
if msg == 'Go forward' then -- change to the message
shell.run('Anotherprogram', arguments)
end
end
waffles05 #4
Posted 04 November 2012 - 02:07 AM
Thanks for the replies!

It took me ages to reply because I forgot I had even posted this. Your code works great and thanks both of you for your help :D/>/>

Clicking green doohickey!