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

Rednet Remote Message Board Help

Started by revjoe, 11 August 2014 - 01:14 PM
revjoe #1
Posted 11 August 2014 - 03:14 PM
Hi i am currently trying to rig up a remote message board, i have found the sender and receiver code pasted by StevenSeegal But i cannot get it working. Theres no errors but also no messages going through.
This is the message sender code

local mdmside = "top" -- Define the side of you modem
local srvid = "2" -- Define the server ID
rednet.open(mdmside)
term.clear()
term.setCursorPos(1,1)
print("Message Board Sender")
print("Type quit to stop")
while true do
  write("Enter text: ")
  message = io.read()
  if message == "quit" then
    break
  else
    rednet.send(srv, message)

  end
end

This is the message receiver code

local monside = "back" -- Define the side of your monitor
local mdmside = "top" -- Define the side of your modem
local montextsize = 2 -- Define the size of the text on your monitor
local header = "Teleporter Listings" -- Type the header of your board
local rson = false -- true is use redstone output, false don't uses the output
local rsoutput = "right" -- Define the redstone output towards a bell of light or something (only needed when rson is set to true)
local rstime = 1 -- The time the redstone output is open
mon = peripheral.wrap(monside)
mon.setCursorBlink(false)
mon.setTextScale(montextsize)
local monwidth, monheight = mon.getSize()
local messages = {}
local num = 0
local messageBegin = 0
local messageEnd = 0
local maxMessagesOS = monheight-3
function monprint(text)
  local cX,cY = mon.getCursorPos()
  mon.write(text)
  mon.setCursorPos(1,cY+1)
end
function clearscreen()
  mon.clear()
  mon.setCursorPos(1,1)
  monprint(header)
  mon.setCursorPos(1,3)
end
function addmessage(text)
  if #messages > maxMessagesOS then
    messageBegin = (#messages - maxMessagesOS)
    messageEnd = #messages
  elseif #messages <= maxMessagesOS then
    messageEnd = #messages
  end
  clearscreen()
  for b = messageBegin, messageEnd do
    monprint(messages[b])
  end
end
function init()
  clearscreen()
  running = true
end
init()
term.clear()
term.setCursorPos(1,1)
print("Message Board SERVER")
print("Press q to quit")
rednet.open(mdmside)
while running do
  event, id, receivedmessage = os.pullEventRaw()
  if event == "rednet_message" then
    local nTime = os.time()
    messages[num] =(textutils.formatTime( nTime, false).." - "..receivedmessage)
    num = num+1
    addmessage()
    if rson then
		  rs.setOutput(rsoutput, true)
		  sleep(rstime)
		  rs.setOutput(rsoutput, false)
    end
    sleep(0.1)
  elseif event == "key" and id == 16 then
    mon.clear()
    running = false
  end
end

Believe it could be something to do with server id im not sure tho, any help would be greatly appreciated. Thank You
flaghacker #2
Posted 11 August 2014 - 05:28 PM
At the beginning of both programs, there are a few lines containing the settings. The text behind the – explains what every setting does.

While editing the programs, make sure you leave the "" where they are and you don't add any.

You get the id of a computer by typing "label" or "id" (not sure :P/>) in the console.