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

Rednet Help

Started by eddnorton, 16 May 2013 - 07:30 AM
eddnorton #1
Posted 16 May 2013 - 09:30 AM
Title: Rednet Help

Hi,

I was wondering if anyone could help me with a rednet question. I am trying to create a group 'admin' shutdown over all computers witing for the terminate command. The way i want the code to work is that it has to wait for the 'terminate' command,( i know how to do this), but it also has to be from a certain computer (identified by it's id). So can someone please write a snippet of code for me, to help me for this issue, and the code is in an 'if' statement?

Thank you so much for your time,

Edd
TheS0m3b0dy #2
Posted 19 May 2013 - 01:43 PM
Well, I guess you could do it something like this (untested):

Admin:

rednet.broadcast("terminate")

Users:

id, msg = os.pullEvent("rednet_message")
if id == [admin id here] and msg == "terminate" then
shell.run("clear")
end

This should just clear the user's screen when the computer receives a message from the admin that says "terminate".
LBPHacker #3
Posted 19 May 2013 - 01:57 PM

id, msg = os.pullEvent("rednet_message")
if id == [admin id here] and msg == "terminate" then
shell.run("clear")
end
.pullEvent returns the event as the first parameter, so nope. Maybe:
local event, id, msg = os.pullEvent("rednet_message")

eddnorton, I'm still not sure what is what you want. Do you want all computers to shut instantly down when they get a "terminate" message from the admin?
TheS0m3b0dy #4
Posted 19 May 2013 - 02:04 PM

id, msg = os.pullEvent("rednet_message")
if id == [admin id here] and msg == "terminate" then
shell.run("clear")
end
.pullEvent returns the event as the first parameter, so nope. Maybe:
local event, id, msg = os.pullEvent("rednet_message")
Oops, that is what I meant, sorry :wacko:/>