321 posts
Location
Melbourne, Australia
Posted 04 March 2013 - 12:19 AM
I am trying to turn rednet messages into fast pulsing redstone signals and back, so I can send long range messages using Wireless Redstone. If anyone has an idea on how to do so, or has some example code, it would be much appreciated.
25 posts
Posted 04 March 2013 - 12:49 AM
You might want to check out the
Rednet,
Os.pullEvent(), and
Redstone API pages.
As for how to do it, well if I gave you the code then you wouldn't learn anything.
I would suggest waiting for an event(os.pullEvent() or rednet.receive()) until a certain message is received and
if that message is what you want
then do a certain action(redstone signals).
If you don't want to learn then click the spoiler for an idea of how to do it :
Spoiler
while true do
local senderID, message, distance = os.pullEvent(rednet_message)
--You could also use rednet.receive() instead of os.pullEvent()
if (senderID == "12") and (message == "Hello") then
--do stuff
else
--do other stuff
end --ends if statement
end -- ends while loop
321 posts
Location
Melbourne, Australia
Posted 04 March 2013 - 01:13 AM
If anyone has any ideas for turning redstone to rednet it would be great!
25 posts
Posted 04 March 2013 - 01:14 AM
It's exactly the opposite of this…
When you receive a redstone signal then send a rednet message..
321 posts
Location
Melbourne, Australia
Posted 04 March 2013 - 01:37 AM
Oh right…
2088 posts
Location
South Africa
Posted 04 March 2013 - 03:59 AM
You might want to check out the
Rednet,
Os.pullEvent(), and
Redstone API pages.
As for how to do it, well if I gave you the code then you wouldn't learn anything.
I would suggest waiting for an event(os.pullEvent() or rednet.receive()) until a certain message is received and
if that message is what you want
then do a certain action(redstone signals).
If you don't want to learn then click the spoiler for an idea of how to do it :
Spoiler
while true do
local senderID, message, distance = os.pullEvent(rednet_message)
--You could also use rednet.receive() instead of os.pullEvent()
if (senderID == "12") and (message == "Hello") then
--do stuff
else
--do other stuff
end --ends if statement
end -- ends while loop
senderID is a number, not a string