Tomoli75

CraftFlare

May 5th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. rednet.open('right')
  2. local tRecord={}
  3. if fs.exists('banned') then
  4. local oFile=io.open('banned','r')
  5. local tBanned=textutils.unserialize(oFile:read())
  6. oFile:close()
  7. else
  8. local tBanned={}
  9. end
  10. print("ID | Distance | Message")
  11. print("---+----------+--------")
  12. while true do
  13. local id,msg,dist=rednet.receive()
  14. if not tRecord[id] then
  15. tRecord[id]={}
  16. end
  17. while #tRecord[id]>=4 do
  18. table.remove(tRecord[id],1)
  19. end
  20. tRecord[id][#tRecord[id]+1]=msg
  21. if tRecord[id][1]==tRecord[id][2] and tRecord[id][1]==tRecord[id][3] and tRecord[id][1]==tRecord[id][4] then
  22. tBanned[id]=true
  23. local oFile=io.open('banned','w')
  24. oFile:write(textutils.serialize(tBanned))
  25. oFile:close()
  26. elseif not tBanned[id] then
  27. id=string.sub(id,1,3) --shorten the id to 3 chars if it is too long
  28. dist=string.sub(dist,1,9)
  29. print(id..string.rep(' ',3-#id)..'| '..dist..string.rep(' ',9-#dist)..'| '..msg) --add spaces to fill up the gap
  30. end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment