William8812

Untitled

Dec 7th, 2021
812
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Copyright Wily#3114 2021--
  2. --Computer placed with an ender modem and monitors on any side
  3. --"Server" Script
  4.  
  5. -- Initial vars --
  6. modem_side = "top"
  7. monitor_side = "left"
  8. jump = false
  9.  
  10. -- Init table --
  11. Display={}
  12.  
  13. table.insert(Display,{["name"]="Cinder Flour",["id"]="create:cinder_flour",["count"]=0})
  14. table.insert(Display,{["name"]="Matter Plastics",["id"]="kubejs:matter_plastics",["count"]=0})
  15. table.insert(Display,{["name"]="Cured Rubber",["id"]="thermal:cured_rubber",["count"]=0})
  16. table.insert(Display,{["name"]="Oak Log",["id"]="minecraft:oak_log",["count"]=0})
  17.  
  18. -- Load touchpoint api --
  19. if not fs.exists("/touchpoint") then shell.run("pastebin get pFHeia96 /touchpoint") end
  20. os.loadAPI("touchpoint")
  21.  
  22. -- Screen Init --
  23. t = touchpoint.new(monitor_side)
  24.  
  25. for i,k in pairs(Display) do
  26.     local name = k.name.." = "..k.count
  27.     print(name)
  28.  
  29.     t:add(name, function()
  30.  
  31.         t:flash(name)
  32.     end , 3+25*(jump and 1 or 0), 2+2*math.floor((i-1)/2), 23+24*(jump and 1 or 0),2+2*math.floor((i-1)/2), colors.red, colors.lime)
  33.  
  34.     jump=not jump
  35. end
  36. t:draw()
  37.  
  38. -- Func --
  39. function Rounding(Nbr)
  40. local Nbr2 = tonumber(Nbr)
  41.     if Nbr2 >= 1000 then
  42.         return string.format("%.2f", Nbr2 / 1000, 2).."K"
  43.     else
  44.         return tostring(Nbr2)
  45.     end
  46. end
  47.  
  48. function Id2Name(Str)
  49.     for i,k in pairs(Display) do
  50.         if Str == k.id then
  51.             if string.sub(k.count, -1) == "K" then
  52.                 value = k.name.." = "..k.count
  53.             else
  54.                 value = k.name.." = "..Rounding(k.count)
  55.             end
  56.             return value
  57.         end
  58.     end
  59. end
  60.  
  61. function Id2Names(Str)
  62.     for i,k in pairs(Display) do
  63.         if Str == k.id then
  64.             return k.name
  65.         end
  66.     end
  67. end
  68.  
  69. function Split(s, delimiter)
  70.     result = {};
  71.     for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  72.         table.insert(result, match);
  73.     end
  74.     return result;
  75. end
  76.  
  77.  
  78. -- RedNet --
  79. rednet.open(modem_side)
  80.  
  81.  
  82. -- RedNet Receving --
  83. while true do
  84.     local senderId, message, protocol = rednet.receive()
  85.     local r2 = Split(message, " ")
  86.     t:rename(Id2Name(r2[1]), Id2Names(r2[1]).." = "..Rounding(r2[2]))
  87.     Display[1].count = Rounding(r2[2])
  88. end
  89.  
RAW Paste Data