Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Copyright Wily#3114 2021--
- --Computer placed with an ender modem and monitors on any side
- --"Server" Script
- -- Initial vars --
- modem_side = "top"
- monitor_side = "left"
- jump = false
- -- Init table --
- Display={}
- table.insert(Display,{["name"]="Cinder Flour",["id"]="create:cinder_flour",["count"]=0})
- table.insert(Display,{["name"]="Matter Plastics",["id"]="kubejs:matter_plastics",["count"]=0})
- table.insert(Display,{["name"]="Cured Rubber",["id"]="thermal:cured_rubber",["count"]=0})
- table.insert(Display,{["name"]="Oak Log",["id"]="minecraft:oak_log",["count"]=0})
- -- Load touchpoint api --
- if not fs.exists("/touchpoint") then shell.run("pastebin get pFHeia96 /touchpoint") end
- os.loadAPI("touchpoint")
- -- Screen Init --
- t = touchpoint.new(monitor_side)
- for i,k in pairs(Display) do
- local name = k.name.." = "..k.count
- print(name)
- t:add(name, function()
- t:flash(name)
- 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)
- jump=not jump
- end
- t:draw()
- -- Func --
- function Rounding(Nbr)
- local Nbr2 = tonumber(Nbr)
- if Nbr2 >= 1000 then
- return string.format("%.2f", Nbr2 / 1000, 2).."K"
- else
- return tostring(Nbr2)
- end
- end
- function Id2Name(Str)
- for i,k in pairs(Display) do
- if Str == k.id then
- if string.sub(k.count, -1) == "K" then
- value = k.name.." = "..k.count
- else
- value = k.name.." = "..Rounding(k.count)
- end
- return value
- end
- end
- end
- function Id2Names(Str)
- for i,k in pairs(Display) do
- if Str == k.id then
- return k.name
- end
- end
- end
- function Split(s, delimiter)
- result = {};
- for match in (s..delimiter):gmatch("(.-)"..delimiter) do
- table.insert(result, match);
- end
- return result;
- end
- -- RedNet --
- rednet.open(modem_side)
- -- RedNet Receving --
- while true do
- local senderId, message, protocol = rednet.receive()
- local r2 = Split(message, " ")
- t:rename(Id2Name(r2[1]), Id2Names(r2[1]).." = "..Rounding(r2[2]))
- Display[1].count = Rounding(r2[2])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement