Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chars = {[" "]=4,["!"]=2,["#"]=6,["$"]=6,["%"]=6,["&"]=6,["("]=5,[")"]=5,["*"]=5,["+"]=6,[","]=2,["-"]=6,["."]=2,["/"]=6,["0"]=6,["1"]=6,["2"]=6,["3"]=6,["4"]=6,["5"]=6,["6"]=6,["7"]=6,["8"]=6,["9"]=6,[":"]=2,[";"]=2,["<"]=5,["="]=6,[">"]=5,["?"]=6,["@"]=7,["A"]=6,["B"]=6,["C"]=6,["D"]=6,["E"]=6,["F"]=6,["G"]=6,["H"]=6,["I"]=4,["J"]=6,["K"]=6,["L"]=6,["M"]=6,["N"]=6,["O"]=6,["P"]=6,["Q"]=6,["R"]=6,["S"]=6,["T"]=6,["U"]=6,["V"]=6,["W"]=6,["X"]=6,["Y"]=6,["Z"]=6,["^"]=6,["_"]=6,["'"]=3,["a"]=6,["b"]=6,["c"]=6,["d"]=6,["e"]=6,["f"]=5,["g"]=6,["h"]=6,["i"]=2,["j"]=6,["k"]=5,["l"]=3,["m"]=6,["n"]=6,["o"]=6,["p"]=6,["q"]=6,["r"]=6,["s"]=6,["t"]=4,["u"]=6,["v"]=6,["w"]=6,["x"]=6,["y"]=6,["z"]=6,["|"]=2,["~"]=7}
- white = -1
- function getStringWidth(str)
- local width = 0
- for i = 1, #str do
- local c = str:sub(i,i)
- width = width + chars[c]
- end
- return width-2
- end
- function drawHud(player, hud)
- local x,y = hud.getResolution()
- text_hud = "HUD: "
- hud.drawString(text_hud,3,3,white,false)
- text_status = "Offline"
- hud.drawString(text_status,3+getStringWidth(text_hud),3,hud.getColorFromRGB(255, 0, 0),false)
- hud.drawHorizontalLine(3, 10, getStringWidth(text_hud)+getStringWidth(text_status), hud.getColorFromRGB(51, 153, 255))
- --hud.drawRectangle(x/4, y/4, ((x/4)+1), ((y/4)+1), hud.getColorFromRGB(255, 255, 255))
- end
- function render(hud)
- hud.drawRectangle(0, 0, 0, 0, white) -- color fix
- hud.sync()
- end
- function handlePlayer(player)
- local hud = antenna.getHUD(player)
- drawHud(player,hud)
- render(hud)
- end
- function start()
- antenna = peripheral.wrap("left")
- playertable = antenna.getPlayers()
- running = true
- while running do
- for key,value in pairs( playertable ) do
- handlePlayer(value)
- end
- os.sleep(0.05)
- end
- end
- function init()
- frames = 0
- if peripheral.isPresent("left") then
- start()
- else
- print("No antenna!")
- end
- end
- print("Starting HUD")
- init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement