0

计算机 0 是中央计算机,用于从其他地方的终端接收信息、解释信息并将其发送到监视器。我会让外部终端以不同的速率发送信息。有的每秒更新几次,有的可能每分钟更新一次。基本思想很简单。电脑 0

local mon = peripheral.wrap("top")
rednet.open("right")

local id = nil
local msg = {}
while true do
    mon.clear()
    id, smsg = rednet.receive()
    if smsg ~= nil then
        msg[id]= smsg
    end
    for i = 1,#msg do
        mon.setCursorPos(1,i)
        mon.write(msg[i])
    sleep(0.1)
end

其他电脑

rednet.open("top")
local n=1
while true do
    rednet.broadcast(0,n)
    n = n+1
    sleep(0.5) --Sleep timer is arbitrary. I just want the central computer to update each individual computers info as they come in.
end

是的,我知道这会造成严重破坏,但我只想让基本想法发挥作用。然后我可以稍后根据需要进行 ID 和协议检查。我知道我需要做一些平行的事情,但仅此而已。我对这件事还是有点陌生​​,至少我只是在初学者之上。

4

0 回答 0