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

News Server

Started by odivius, 06 June 2012 - 10:36 PM
odivius #1
Posted 07 June 2012 - 12:36 AM
Ok It's me with this problem:
I want to set up a news server which sends Messages to the clients, which should be shown on the screen.
It's running quite well, but after some seconds on the screen there is always '%getNews%..news'
Here is the clients code:

term.clear()
term.setCursorPos(1,1)
rednet.open("top")
print("Reader is only waiting for updates")
sleep(1.5)
term.clear()
term.setCursorPos(1,1)
while true do
event, param1, param2 = os.pullEvent("rednet_message")
if param2 == "exit" then
  break
end
print(param2)
sleep(1.5)
end

Any ideas how to prevent it from being shown?
MysticT #2
Posted 07 June 2012 - 01:02 AM
Well, the problem must be in the server, since that code has no errors. The only thing I would change on the client is making it receive only from the server, not every computer. Something like:

local serverID = 0 -- change to the id of the server

-- print message and open rednet, etc.

while true do
  local evt, id, msg = os.pullEvent("rednet_message")
  if id == serverID then
	if msg == "exit" then
	  break
	end
	print(msg)
  end
end
Bossman201 #3
Posted 08 June 2012 - 03:21 AM
It looks like your error has something to do with concatenation. Perhaps you forgot a ")" on or around that line?