Advertisement
osmarks

Chorus City Signage System

Mar 15th, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. --process.spawn(function() shell.run "ccss_player_positions_agent" end, "ccss_player_positions_agent")
  2. process.spawn(function()
  3.     while true do
  4.         local game_time_start = os.epoch "utc"
  5.         sleep(1)
  6.         local game_time_end = os.epoch "utc"
  7.         local utc_elapsed_seconds = (game_time_end - game_time_start) / 1000
  8.         local tps = 20 / utc_elapsed_seconds
  9.         os.queueEvent("ccss_update", ("TPS is approximately %f"):format(tps))
  10.     end
  11. end, "tpsmeter")
  12.  
  13. local palette = {
  14.     blue =      0x303289,
  15.     yellow =    0xedad15,
  16.     red =       0x8d2423,
  17.     magenta =   0xa43098,
  18.     green =     0x4a5b25,
  19.     lightBlue = 0x2587c5,
  20.     white =     0xffffff,
  21.     pink =      0xd06385
  22. }
  23.  
  24. local function draw(street, sub, super, col)
  25.     local m = peripheral.find "monitor"
  26.     local w, h = m.getSize()
  27.     m.setBackgroundColor(colors.black)
  28.     m.setTextColor(colors.white)
  29.     m.clear()
  30.     m.setCursorPos(2, 1)
  31.     m.write(super)
  32.     bigfont.writeOn(m, 1, street, 2, 2)
  33.     m.setCursorPos(2, 5)
  34.     m.write(sub)
  35.     if col then
  36.         local c, p = colors[col], palette[col]
  37.         if p then
  38.             m.setPaletteColor(c, p)
  39.         end
  40.         m.setBackgroundColor(c)
  41.         for y = 1, h do
  42.             m.setCursorPos(w, y)
  43.             m.write " "
  44.         end
  45.     end
  46. end
  47.  
  48. local street = settings.get "ccss.street"
  49. local super = settings.get "ccss.super" or ""
  50. if not street then
  51.     street = "Name Wanted"
  52.     super = "Submit your suggestions to gollark."
  53. end
  54. local col = settings.get "ccss.color"
  55.  
  56. print("Sign for", street, "running.")
  57.  
  58. local sub = ""
  59. while true do
  60.     local ok, err = pcall(draw, street, sub, super, col)
  61.     if not ok then printError(err) end
  62.     local _, newsub = os.pullEvent "ccss_update"
  63.     sub = newsub
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement