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

Rednet monitor + license system

Started by theeboris, 29 October 2012 - 04:25 PM
theeboris #1
Posted 29 October 2012 - 05:25 PM
Hello,
I have made a program that monitor rednet.
Sorry for my bad english. I am dutch.


Client code

AutoBroadcaster = true
ClearScreen = true
SetCursorPos = true
OpenRednet = true
timeOut = 10
if ClearScreen == true then
term.clear()
end
if SetCursorPos == true then
term.setCursorPos(1,1)
end
if OpenRednet == true then
print("Opening rednet...")
local function connect()
  print("Starting location system...")
  print("Connecting to rednet...")
  for _,s in ipairs(rs.getSides()) do
   if peripheral.isPresent(s) and peripheral.getType(s) == "modem" then
   rednet.open(s)
   return true
  end
end
print("No modem found")
print("Aborting")
sleep(3)
os.shutdown()
return false
end
connect()
print("Rednet open...")
end
if AutoBroadcaster == true then
print("Obtaining computerid...")
local compID = os.computerID()
print("Computerid obtained...")
rednet.broadcast(compID .." Is monitoring.")
end
if ShowExitKey == true then
print("CTRL+T to close this program")
end
rednet.send(50," ")
senderId, message, distance = rednet.receive(timeOut)
if senderId == 50 then
while true do
  print("Waiting for messages...")
  id, message = rednet.receive()
  redstone.setOutput("back", true)
  local nTime = os.time()write(textutils.formatTime( nTime, false))
  print (" - "..message)
  print ()
  sleep(1)
  redstone.setOutput("back", false)
end
end
Edit rule 41 to rednet.send(your server id," ")
Edit rule 43 to if senderId == your server id then



Server code

print("Opening rednet...")
rednet.open("back")
print("rednet is open...")
while true do
print("Waiting for messages...")
senderId, message, distance = rednet.receive()
print("Message received...")
if senderId == 23 then
rednet.send(23," ")

end
print("Done")
term.clear()
end
Edit rule 2 to rednet.open("modem side")
Edit rule 9 to if senderId == id of person that must have acces then
Edit rule 19 to rednet.send(id of person that must have acces," ")
If you want to add more people add add this code on rule 12

if senderId == id of person that must have acces then
rednet.send(id of person that must have acces," ")
theeboris #2
Posted 29 October 2012 - 05:27 PM
Oops wrong topic. Please move it to
API's and Utilities
Cruor #3
Posted 29 October 2012 - 05:55 PM
Please use the report button if you wish your thread to be moved. Either way, moved.
theeboris #4
Posted 08 November 2012 - 09:44 AM
Please comment
cmurtheepic #5
Posted 21 November 2012 - 05:13 PM
i think this has a very big potential at use in other programs:)