Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendWithThisBox(boxKey)
- for k,v in pairs(sendTheseMessages) do
- curMessageKey = k
- curMessage = v["message"]
- curPlayer = v["player"]
- curColor = v["color"]
- break
- end
- local chatBox = chatBoxes[boxKey]["peripheral"]
- if type(curMessage) ~= "table" then
- local json = textutils.serialiseJSON({text = curMessage, color = curColor})
- chatBox.sendFormattedMessageToPlayer(json, curPlayer, systemName)
- table.remove(sendTheseMessages, curMessageKey)
- chatBoxes[boxKey]["cooldownTime"] = os.epoch("local")
- return
- end
- for k,v in pairs(curMessage) do
- if type(v) == "table" then
- if not v["color"] then
- curMessage[k]["color"] = curColor
- end
- else
- curMessage[k] = {text = v, color = curColor}
- end
- end
- local json = textutils.serialiseJSON(curMessage)
- chatBox.sendFormattedMessageToPlayer(json, curPlayer, systemName)
- table.remove(sendTheseMessages, curMessageKey)
- chatBoxes[boxKey]["cooldownTime"] = os.epoch("local")
- end
- sleep(1)
- while true do
- if table.maxn(sendTheseMessages) < 1 then
- os.pullEvent("sendMessage")
- else
- sleep(0.05)
- end
- for chatBoxKey,chatBox in pairs(chatBoxes) do
- if os.epoch("local") - chatBox["cooldownTime"] > 999 then
- sendWithThisBox(chatBoxKey)
- end
- if table.maxn(sendTheseMessages) < 1 then
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement