Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local PPI = require("ppi")
- local LOCATION = 10
- --[[ The location on the screen to put the gauges.
- 4 = top left
- 5 = top
- 6 = top right
- 7 = right
- 8 = bottom right
- 9 = bottom
- 10 = bottom left
- 11 = left
- --]]
- local function WindowTextShadow(name, font, text,
- left, top, right, bottom,
- color,
- shadow_left, shadow_top,
- shadow_color)
- -- draw shadow
- WindowText(name, font, text,
- left + shadow_left, top + shadow_top, right, bottom,
- shadow_color)
- -- draw text
- WindowText(name, font, text,
- left, top, right, bottom,
- color)
- end
- local function clamp(num, min, max)
- return (num > max) and max or ((num < min) and min or num)
- end
- gauges = {
- name = GetPluginID(),
- stats = {
- nl = {curr = 0, max = 100, x = 56, y = 28},
- hp = {curr = 100, max = 100, x = 56, y = 53},
- mp = {curr = 100, max = 100, x = 56, y = 68},
- ep = {curr = 100, max = 100, x = 56, y = 83},
- wp = {curr = 100, max = 100, x = 56, y = 98},
- },
- percent = function(stat)
- return clamp(math.floor(stat.curr/stat.max * 100), 0, 100)
- end,
- draw = function ()
- local left, top, width
- -- Draw the base image
- WindowDrawImage(gauges.name, "gauges", 0, 0, 0, 0, 1)
- -- Draw the individual bars
- for name,stat in pairs(gauges.stats) do
- left, top = stat.x, stat.y
- width = math.floor(gauges.percent(stat)/2)
- if width > 0 then
- WindowDrawImage(gauges.name, name,
- left, top, 0, 0,
- 1,
- 0, 0, width, 0)
- end
- local txt = tostring(width*2) .. "%"
- WindowTextShadow(gauges.name, "f", tostring(width*2) .. "%",
- stat.x + 52, top-2, 0, 0,
- 0xAAFFCC,
- 2, 2,
- 0x000000)
- end
- WindowShow(gauges.name, true)
- end,
- }
- -- (ID, on_success, on_failure)
- PPI.OnLoad("29a4c0721bef6ae11c3e9a82", function(gmcp)
- gmcp.Listen("Char.Vitals", function(message, content)
- content.maxnl = 100
- for stat, data in pairs(gauges.stats) do
- data.curr = tonumber(content[stat] + 0)
- data.max = tonumber(content["max" .. stat])
- end
- Execute("maxhm:"..gauges.stats.hp.max.." "..gauges.stats.mp.max)
- gauges.draw()
- end)
- end)
- local atcp_stats = {H = "hp", M = "mp", E = "ep", W = "wp", NL = "nl"}
- PPI.OnLoad("7c08e2961c5e20e5bdbf7fc5", function(atcp)
- atcp.Listen("Char.Vitals", function(message, content)
- for stat, curr, max in string.gmatch(content, "(%w+):(%d+)/(%d+)") do
- gauges.stats[atcp_stats[stat]].curr = curr
- gauges.stats[atcp_stats[stat]].max = max
- end
- gauges.draw()
- end)
- end)
- function TellXP()
- ColourTell("lime", "black", "-", "white", "black", "(", "red", "black", gauges.stats.nl.curr.."%", "white", "black", ")", "lime", "black", "- ")
- end
- function TellPromptBlackout()
- ColourTell("#46813C", "black", gauges.stats.hp.curr.."h, "..gauges.stats.mp.curr.."m ")
- Execute("hm:"..gauges.stats.hp.curr.." "..gauges.stats.mp.curr)
- end -- TellPrompt()
- OnPluginListChanged = function()
- PPI.Refresh()
- end
- OnPluginInstall = function()
- local resources = plugger.path("resources")
- -- Set up the window
- WindowCreate(gauges.name, 0, 0, 150, 139, LOCATION, 0, ColourNameToRGB("black"))
- -- Add a font
- WindowFont(gauges.name, "f", "Arial", 7.5)
- -- Load the base image
- WindowLoadImage(gauges.name, "gauges", resources .. "gauges.bmp")
- -- Load the image for each gauge
- for stat,_ in pairs(gauges.stats) do
- WindowLoadImage(gauges.name, stat, resources .. stat .. ".bmp")
- end -- for
- -- Draw!
- gauges.draw()
- end
- OnPluginClose = function()
- WindowDelete(gauges.name)
- end
- OnPluginEnable = OnPluginInstall
- OnPluginDisable = OnPluginClose
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement