Sebo2205's custom HUD thing

Sebo2205's custom HUD thing v2.0.1

SweetCoffy

get real
Sebo2205 submitted a new resource:

Sebo2205's custom HUD thing - A custom HUD i decided to make while i was bored

(obligatory "this is my first mod")
A custom HUD i made with only Lua

Features:

A speedometer (+ a tails flight meter if you're playing as tails), which can be turned on/off with speedometer On/Off
View attachment 45671

A boss health bar
View attachment 45672

Certain parts of the HUD have colors that depend on your skincolor
View attachment 45673

A little slide in animation when you start moving...

Read more about this resource...
 
Basically Sonic Forces' HUD in SRB2 but not on Modern Sonic, perfect
 
I Got A Problem!
When I Turn Off The Custom Hub & Turn It Back On The Custom Hub Does Not Come Back!
It Keeps The Old Hud!

Edit: Out Of Rage Error Some How Shows Up In Multiplayer!
 

Attachments

  • srb20033.gif
    srb20033.gif
    3.1 MB · Views: 462
  • srb20352.png
    srb20352.png
    126.3 KB · Views: 345
Last edited:
I Got A Problem!
When I Turn Off The Custom Hub & Turn It Back On The Custom Hub Does Not Come Back!
It Keeps The Old Hud!

Edit: Out Of Rage Error Some How Shows Up In Multiplayer!
The HUD only is enabled with hud On because for some reason var.value always returns 0, gonna release a new version with a fix soon

edit: released 2 versions in a row, because i forgot to remove the case sensitivity
 
Last edited:
just thought I'd let you know, this file can flood the console with errors when a boss disappears in an inconventional way. For example, when fighting the final boss in Mystic Realm, the boss mobj is swapped with a different one when triggering the second phase. This causes errors to flood the console, saying "Warning in 'P_CheckSight': accessed mobj_t doesn't exist anymore, please check 'valid' before using mobj_t.
 
I Did Some Edit To The Lua Here!

Edit: Also The Flag MFE_ONGROUND Is To Stop That Out Of Rage Error Form The Objectplace

Fixed Code:
-- 320x200

-- Don't mind my variable names
local coolCounter = 0
local goRed = false


local speedometerEnabled = true
local bossHealthEnabled = true
local showMultiplayerName = false
local iconSize = 10;

-- Boss stuff
local boss = nil
local bossMaxHealth = 0
local bossHealth = 0

-- Width and Height
local width = 130;
local height = 10;

-- X and Y offsets
local ypos = 1
local xpos = 0

local targetxpos = 0

-- Text X and Y offsets
local txoffset = 2
local tyoffset = 0

local rtxoffset = 0
local rtyoffset = 0

local hudEnabled = true

local a = 0x00090000
-- Water/Space timer X offsets
local timerxoffset = 1;
addHook("BossThinker", function (mob)
    boss = mob
    bossHealth = mob.health
    bossMaxHealth = mob.info.spawnhealth
end)
local animspeed = 10
local started = false
local curspeed = animspeed
addHook("MapLoad", function ()
    boss = nil
    bossHealth = 0
    bossMaxHealth = 0
    curspeed = 0
    started = false
    xpos = -width
    a = 0x00090000
end)
local function disableHudElements()
    if hudEnabled then      
        if hud.enabled("textspectator") then hud.disable("textspectator") end
        if hud.enabled("score")         then hud.disable("score")         end
        if hud.enabled("time")          then hud.disable("time")          end
        if hud.enabled("rings")         then hud.disable("rings")         end
        if hud.enabled("lives")         then hud.disable("lives")         end
    else
        if not hud.enabled("textspectator") then hud.enable("textspectator") end
        if not hud.enabled("score")         then hud.enable("score")         end
        if not hud.enabled("time")          then hud.enable("time")          end
        if not hud.enabled("rings")         then hud.enable("rings")         end
        if not hud.enabled("lives")         then hud.enable("lives")         end
    end
end
addHook("PreThinkFrame", disableHudElements)
CV_RegisterVar({name="hudwidth", defaultValue="" + width, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var)
    width = var.value;
end})
CV_RegisterVar({name="hudxpos", defaultValue="" + xpos, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var)
    targetxpos = var.value
end})
CV_RegisterVar({name="hudypos", defaultValue="" + ypos, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var)
    ypos = var.value
end})
CV_RegisterVar({name="showname", defaultValue=0, flags=CV_CALL, pv=CV_OnOff, func=function (var)
    local v = string.lower(var.string)
    if v == "on" or v == "1" or v == "Yes" then
        showMultiplayerName = true
    else
        showMultiplayerName = false
    end
end})
CV_RegisterVar({name="speedometer", defaultValue=1, flags=CV_CALL, pv=CV_OnOff, func=function (var)
    local v = string.lower(var.string)
    if v == "on" or v == "1" or v == "Yes" then
        speedometerEnabled = true
    else
        speedometerEnabled = false
    end
end})
CV_RegisterVar({name="bosshealth", defaultValue=1, flags=CV_CALL, pv=CV_OnOff, func=function (var)
    local v = string.lower(var.string)
    if v == "on" or v == "1" or v == "Yes" then
        bossHealthEnabled = true
    else
        bossHealthEnabled = false
    end
end})
CV_RegisterVar({name="hud", defaultValue=1, flags=CV_CALL, pv=CV_OnOff, func=function (var)
    local v = string.lower(var.string)
    if v == "on" or v == "1" or v == "Yes" then
        hudEnabled = true
    else
        hudEnabled = false
    end
    print(var.value)
end})
local deccel = FRACUNIT
local accelAdd = -1
local minSpeed = 1
local function hudHandler(v, p, cam)
    if not hudEnabled then return end
    if not (p.mo and p.mo.valid) then return end
    if not (p.mo.eflags & MFE_ONGROUND) then return end
    if p.mo.skin == "modernsonic" then return end
    if v.renderer() == "none" then return end
    if p.mo == nil or not p.valid then return end
    if p.powers[pw_carry] == CR_NIGHTSMODE then return end
    if G_IsSpecialStage() then return end
    xpos = xpos + (max(min(targetxpos - xpos, curspeed), -curspeed))
    if a > 0 and xpos == targetxpos then
        a = a - 0x00010000
    end
    coolCounter = coolCounter + 1
    local timer = 0
    local timerMax = 0
    if not started and p.speed > FRACUNIT/10 then
        started = true
        curspeed = animspeed
    end
    if p.powers[pw_underwater] then
        timerMax = 1050
        timer = min(p.powers[pw_underwater], timerMax)
    elseif p.powers[pw_spacetime] then
        timerMax = 405
        timer = min(p.powers[pw_spacetime], timerMax)
    end
    local col = 29
    if v.RandomChance(deccel) then
        if curspeed > minSpeed then
            curspeed = curspeed - accelAdd
        end
    end
    if coolCounter > 7 then
        coolCounter = 0
        if not goRed then goRed = true else goRed = false end
    end
    if p.rings > 0 then goRed = false end
    if goRed then col = 38 end
    local txpos = 5;
    local rpos = -5;
    --Rings
    v.drawFill(xpos, ypos, width, height, col|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)  
    local ramp = 0
    if p.skincolor then ramp = skincolors[p.mo.color].ramp end
    local i = 0
    local step = width / 16
    if not ramp then return end
    v.drawFill(xpos, ypos + height, width, 1, ramp[15]|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
    while i < 16 do
        local c = ramp[i]
        local x = 0
        while x < step do
            v.drawFill(xpos + (i * step) + x, ypos + height, 1, 1, c|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
            x = x + 1
        end
        i = i + 1
    end
   
    v.drawString(xpos + txpos + rtxoffset, 1 + ypos, "Rings", V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")
   
    local twidth = v.stringWidth("" + p.rings, V_SNAPTOTOP|a|V_SNAPTOLEFT)
    v.drawString(xpos + width + txpos - twidth + rpos, 1 + ypos, "" + p.rings, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")
   
    --Time
    v.drawString(xpos + txpos + txoffset, 4 + ypos + height, "Time", V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")
    local f = "%02d"
    local str = string.format(f, G_TicsToMinutes(p.realtime, true)) + ":" + string.format(f, G_TicsToSeconds(p.realtime)) + ":" + string.format(f, G_TicsToCentiseconds(p.realtime))
    local twidth = v.stringWidth(str, V_SNAPTOTOP|a|V_SNAPTOLEFT)
    v.drawString(xpos + width + txpos - twidth + rpos, 4 + ypos + height, str, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")

    --Score
    v.drawString(xpos + txpos + txoffset, 4 + ypos + height + 10, "Score", V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")
    local str = "" + p.score
    local twidth = v.stringWidth(str, V_SNAPTOTOP|a|V_SNAPTOLEFT)
    v.drawString(xpos + width + txpos - twidth + rpos, 4 + ypos + height + 10, str, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")
 
    --Life counter
    local lname = "placeholder"
    local lives = p.lives
    if showMultiplayerName then lname = p.name
    else lname = skins[p.skin].hudname end
    local xwidth = v.stringWidth("x", V_SNAPTOBOTTOM|a|V_SNAPTOLEFT, "small")
    local lifeWidth = v.stringWidth(lname, V_SNAPTOBOTTOM|a|V_SNAPTOLEFT) + 32 + iconSize + 8;
    v.drawFill(xpos, 200 - 2, lifeWidth, 2, ramp[15]|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
    local i = 0
    local lstep = lifeWidth / 16
    while i < 16 do
        local c = ramp[i]
        local x = 0
        while x < lstep do
            v.drawFill(xpos + (i * lstep) + x, 200 - 2, 1, 2, c|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
            x = x + 1
        end
        i = i + 1
    end
    local s = v.getSprite2Patch(p.realmo.skin, SPR2_LIFE, false, 0)
    local scaleMul = FRACUNIT;
    local colormap = v.getColormap(p.mo.skin, p.mo.color);
    if not s then
        s = v.getSpritePatch("TV1U", A)
        scaleMul = FRACUNIT/3
    end
    local off = 10;
    local nyoff = -2;
    local lyoff = -2;
    v.drawScaled((xpos + iconSize)*FRACUNIT, (200 - iconSize + 4)*FRACUNIT, FixedMul(FRACUNIT + (2/FRACUNIT), scaleMul), s, V_SNAPTOBOTTOM|a|V_SNAPTOLEFT, colormap)

    if not G_GametypeUsesLives() or p.lives == INFLIVES then          
        v.drawString(xpos + iconSize + off, nyoff + 200 - 10, lname, skincolors[p.mo.color].chatcolor|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
    else
        v.drawString(xpos + iconSize + off, nyoff + 200 - 10, lname, skincolors[p.mo.color].chatcolor|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
        v.drawString(xpos + lifeWidth - 18, lyoff + 200 - 10, string.format("%02d", lives), V_YELLOWMAP|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
        v.drawString((xpos + lifeWidth - (18 - (-xwidth) - -1)), lyoff + 200 - 10 + xwidth, "x", V_YELLOWMAP|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT, "small")
    end

    --Underwater/Space timer
    if timerMax > 0 then
        v.drawFill(xpos + timerxoffset, 4 + ypos + height + 20, width - timerxoffset - 1, 2, 159|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
        v.drawFill(xpos + timerxoffset, 4 + ypos + height + 20, FixedInt(FixedMul(FixedDiv(timer*FRACUNIT, timerMax*FRACUNIT), width*FRACUNIT)) - timerxoffset - 1, 2, 131|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
    end

    --Boss health
    local h = 3;
    if not (boss == nil) and bossMaxHealth > 0 and P_CheckSight(p.mo, boss) and bossHealthEnabled then  
        local off = 32 + 4;
        v.drawString(320 - xpos - width - xpos - off, ypos, "BOSS", V_REDMAP|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
        v.drawFill(320 - xpos - width - xpos, ypos, width, height, 29|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
        local w = width - (h * 2)
        v.drawFill(320 - xpos - width - xpos + h, ypos + h, w, height - (h * 2), 40|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
        v.drawFill(320 - xpos - width - xpos + h, ypos + h, min(FixedInt(FixedMul(FixedDiv((bossHealth*FRACUNIT),(bossMaxHealth*FRACUNIT)), w*FRACUNIT)), w), height - (h * 2), 35|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
    end

    --Speedometer
    if not speedometerEnabled then return end
    local off = (8 * 5) + 4;
    v.drawString(320 - xpos - width - off, 200 - height, "SPEED", skincolors[p.mo.color].chatcolor|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT)
    v.drawFill(320 - xpos - width, 200 - height, width, height, 29|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT)
    local w = width - (h * 2)
    v.drawFill(320 - xpos - width + h, 200 - height + h, w, height - (h * 2), ramp[15]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT)
    v.drawFill(320 - xpos - width + h, 200 - height + h, min(FixedInt(FixedMul(FixedDiv((p.speed),(skins[0].runspeed*2 + (skins[0].runspeed/2))), w*FRACUNIT)), w), height - (h * 2), ramp[4]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT)
    if p.powers[pw_tailsfly] > 0 then
        v.drawFill(320 - xpos - width + h, 200 - height + h + (height - (h * 2)), w, 1, ramp[13]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT)
        v.drawFill(320 - xpos - width + h, 200 - height + h + (height - (h * 2)), min(FixedInt(FixedMul(FixedDiv((p.powers[pw_tailsfly]*FRACUNIT),280*FRACUNIT), w*FRACUNIT)), w), 1, ramp[0]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT)
    end
    local i = 0;
    local sstep = width / 16;
    v.drawFill(320 - xpos - width, (200 - 1), width, 1, ramp[15]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT)
    while i < 16 do
        local c = ramp[i]
        local x = 0
        while x < sstep do
            v.drawFill(320 - xpos - width + (i * sstep) + x, (200 - 1), 1, 1, c|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT)
            x = x + 1
        end
        i = i + 1
    end
end
hud.add(hudHandler, "game")
 
Last edited:
Sebo2205 updated Sebo2205's custom HUD thing with a new update entry:

i can't think of an update title, send help

probably the biggest update out of all the previous ones lol

Changes:
- Changed up the life counter, also placed it at the top right corner
View attachment 46118

- Speedometer is now at the bottom left corner so that the fps counter doesn't overlap it
View attachment 46119

- Removed boss health bar
- Added a custom intermission screen, disabled by default as it isn't completeView attachment 46120

- Fixed HUD randomly popping out of...

Read the rest of this update entry...
 
Oh Not That Multiplayer Error Again!
It Have To Be ramp = 0
Not ramp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Here's The Fix Code Again!

Fix Multiplayer Code Again!:
-- 320x200

-- Don't mind my variable names
local coolCounter = 0
local goRed = false


local speedometerEnabled = true
local iconSize = 10;

-- Width and Height
local width = 130;
local height = 10;

-- X and Y offsets
local ypos = 1
local xpos = 0

local targetxpos = 0

-- Text X and Y offsets
local txoffset = 2
local tyoffset = 0

local rtxoffset = 0
local rtyoffset = 0

local hudEnabled = true

local useOpposite = false

local customIntermission = false

local a = 0x00090000
-- Water/Space timer X offsets
local timerxoffset = 1;
local animspeed = 10
local started = false
local curspeed = animspeed

freeslot("SKINCOLOR_HUD")
addHook("MapLoad", function ()
    curspeed = 0
    started = false
    xpos = -width - 48;
    a = 0x00090000
end)
local function disableHudElements()
    if hud.enabled("intermissiontally") and customIntermission then hud.disable("intermissiontally") end
    if not hud.enabled("intermissiontally") and not customIntermission then hud.enable("intermissiontally") end
    if hudEnabled then    
        if hud.enabled("score")         then hud.disable("score")         end
        if hud.enabled("time")          then hud.disable("time")          end
        if hud.enabled("rings")         then hud.disable("rings")         end
        if hud.enabled("lives")         then hud.disable("lives")         end
    else
        if not hud.enabled("score")         then hud.enable("score")         end
        if not hud.enabled("time")          then hud.enable("time")          end
        if not hud.enabled("rings")         then hud.enable("rings")         end
        if not hud.enabled("lives")         then hud.enable("lives")         end
    end
end
addHook("PreThinkFrame", disableHudElements)
CV_RegisterVar({name="hudwidth", defaultValue="" + width, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var)
    width = var.value;
end})
CV_RegisterVar({name="hudxpos", defaultValue="" + xpos, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var)
    targetxpos = var.value
end})
CV_RegisterVar({name="hudypos", defaultValue="" + ypos, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var)
    ypos = var.value
end})
CV_RegisterVar({name="speedometer", defaultValue=1, flags=CV_CALL, pv=CV_OnOff, func=function (var)
    local v = string.lower(var.string)
    if v == "on" or v == "1" or v == "Yes" then
        speedometerEnabled = true
    else
        speedometerEnabled = false
    end
end})
CV_RegisterVar({name="hud", defaultValue=1, flags=CV_CALL, pv=CV_OnOff, func=function (var)
    local v = string.lower(var.string)
    if v == "on" or v == "1" or v == "Yes" then
        hudEnabled = true
    else
        hudEnabled = false
    end
    print(var.value)
end})
CV_RegisterVar({name="hudopposite", defaultValue=0, flags=CV_CALL, pv=CV_OnOff, func=function (var)
    local v = string.lower(var.string)
    if v == "on" or v == "1" or v == "Yes" then
        useOpposite = true
    else
        useOpposite = false
    end
    print(var.value)
end})
CV_RegisterVar({name="hudintermission", defaultValue=0, flags=CV_CALL, pv=CV_OnOff, func=function (var)
    local v = string.lower(var.string)
    if v == "on" or v == "1" or v == "Yes" then
        customIntermission = true
    else
        customIntermission = false
    end
    print(var.value)
end})
local deccel = FRACUNIT
local accelAdd = -1
local minSpeed = 1
local color
local play = nil
local function hudHandler(v, p, cam)
    if not hudEnabled then return end
    if not (p.mo or p.mo.valid) then return end
    play = p
    color = p.mo.color
    if p.mo.skin == "modernsonic" then return end
    if v.renderer() == "none" then return end
    if p.mo == nil or not p.valid then return end
    if p.powers[pw_carry] == CR_NIGHTSMODE then return end
    if G_IsSpecialStage() then return end
    xpos = xpos + (max(min(targetxpos - xpos, curspeed), -curspeed))
    if a > 0 and xpos == targetxpos then
        a = a - 0x00010000
    end
    coolCounter = coolCounter + 1
    local timer = 0
    local timerMax = 0
    if not started and p.speed > FRACUNIT/10 then
        started = true
        curspeed = animspeed
    end
    if p.powers[pw_underwater] then
        timerMax = 1050
        timer = min(p.powers[pw_underwater], timerMax)
    elseif p.powers[pw_spacetime] then
        timerMax = 405
        timer = min(p.powers[pw_spacetime], timerMax)
    end
    local col = 29
    if v.RandomChance(deccel) then
        if curspeed > minSpeed then
            curspeed = curspeed - accelAdd
        end
    end
    if coolCounter > 7 then
        coolCounter = 0
        if not goRed then goRed = true else goRed = false end
    end
    if p.rings > 0 then goRed = false end
    if goRed then col = 38 end
    local txpos = 5;
    local rpos = -5;
    --Rings
    v.drawFill(xpos, ypos, width, height, col|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
    local ramp = 0
    if p.skincolor then
        if useOpposite then
            ramp = skincolors[ColorOpposite(p.mo.color)].ramp
        else
            ramp = skincolors[p.mo.color].ramp
        end
    end
    local i = 0
    local step = width / 16
    if not ramp then return end
    v.drawFill(xpos, ypos + height, width, 1, ramp[15]|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
    while i < 16 do
        local c = ramp[i]
        local x = 0
        while x < step do
            v.drawFill(xpos + (i * step) + x, ypos + height, 1, 1, c|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
            x = x + 1
        end
        i = i + 1
    end
 
 v.drawString(xpos + txpos + rtxoffset, 1 + ypos, "Rings", V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")

    local twidth = v.stringWidth("" + p.rings, V_SNAPTOTOP|a|V_SNAPTOLEFT)
    v.drawString(xpos + width + txpos - twidth + rpos, 1 + ypos, "" + p.rings, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")

    --Time
    v.drawString(xpos + txpos + txoffset, 4 + ypos + height, "Time", V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")
    local f = "%02d"
    local str = string.format(f, G_TicsToMinutes(p.realtime, true)) + ":" + string.format(f, G_TicsToSeconds(p.realtime)) + "." + string.format(f, G_TicsToCentiseconds(p.realtime))
    local twidth = v.stringWidth(str, V_SNAPTOTOP|a|V_SNAPTOLEFT)
    v.drawString(xpos + width + txpos - twidth + rpos, 4 + ypos + height, str, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")

    --Score
    v.drawString(xpos + txpos + txoffset, 4 + ypos + height + 10, "Score", V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")
    local str = "" + p.score
    local twidth = v.stringWidth(str, V_SNAPTOTOP|a|V_SNAPTOLEFT)
    v.drawString(xpos + width + txpos - twidth + rpos, 4 + ypos + height + 10, str, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left")

    --Life counter
    local xwidth = v.stringWidth("x", V_SNAPTOBOTTOM|a|V_SNAPTOLEFT, "small")
    local s = v.getSprite2Patch(p.realmo.skin, SPR2_LIFE, false, 0)
    local scaleMul = FRACUNIT;
    local colormap = v.getColormap(p.mo.skin, p.mo.color);
    if not s then
        s = v.getSpritePatch("TV1U", A)
        scaleMul = FRACUNIT/3
    end
    local off = 10;
    local nyoff = -2;
    local lyoff = -2;
   
    if G_GametypeUsesLives() then
        v.drawScaled(((320 - xpos) - iconSize)*FRACUNIT, (ypos+iconSize)*FRACUNIT, FixedMul(FRACUNIT + (2/FRACUNIT), scaleMul), s, V_SNAPTOTOP|a|V_SNAPTORIGHT, colormap)
        v.drawString((320 - xpos) - (iconSize * 2) - 20, ypos + (iconSize/2) - 1, string.format("%02d", p.lives), V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
        v.drawString((((320 - xpos) - (iconSize * 2) - 4)), ypos + (iconSize/2) + 2, "x", V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTORIGHT, "small")
    end

    --Underwater/Space timer
    if timerMax > 0 then
        v.drawFill(xpos + timerxoffset, 4 + ypos + height + 20, width - timerxoffset - 1, 2, 159|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
        v.drawFill(xpos + timerxoffset, 4 + ypos + height + 20, FixedInt(FixedMul(FixedDiv(timer*FRACUNIT, timerMax*FRACUNIT), width*FRACUNIT)) - timerxoffset - 1, 2, 131|a|V_SNAPTOTOP|a|V_SNAPTOLEFT)
    end
    local h = 3;
    --Boss health
    --if not (boss == nil) and boss.valid and bossHealthEnabled then
    --    if P_CheckSight(p.mo, boss) then
    --        local off = 32 + 4;
    --        v.drawString(320 - xpos - width - xpos - off, ypos, "BOSS", V_REDMAP|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
    --        v.drawFill(320 - xpos - width - xpos, ypos, width, height, 29|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
    --        local w = width - (h * 2)
    --        v.drawFill(320 - xpos - width - xpos + h, ypos + h, w, height - (h * 2), 40|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
    --        v.drawFill(320 - xpos - width - xpos + h, ypos + h, min(FixedInt(FixedMul(FixedDiv((bossHealth*FRACUNIT),(bossMaxHealth*FRACUNIT)), w*FRACUNIT)), w), height - (h * 2), 35|a|V_SNAPTOTOP|a|V_SNAPTORIGHT)
    --    end
    --end

    --Speedometer
    if not speedometerEnabled then return end
    local off = (8 * 5) + 4;
    local px = 0;
    v.drawString(px + xpos, 200 - height - 9, "SPEED", skincolors[p.mo.color].chatcolor|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
    v.drawFill(px + xpos, 200 - height, width, height, 29|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
    local w = width - (h * 2)
    v.drawFill(px + xpos + h, 200 - height + h, w, height - (h * 2), ramp[15]|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
    v.drawFill(px + xpos + h, 200 - height + h, min(FixedInt(FixedMul(FixedDiv((p.speed),(skins[0].runspeed*2 + (skins[0].runspeed/2))), w*FRACUNIT)), w), height - (h * 2), ramp[4]|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
    if p.powers[pw_tailsfly] > 0 then
        v.drawFill(px + xpos + h, 200 - height + h + (height - (h * 2)), w, 1, ramp[13]|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
        v.drawFill(px + xpos + h, 200 - height + h + (height - (h * 2)), min(FixedInt(FixedMul(FixedDiv((p.powers[pw_tailsfly]*FRACUNIT),280*FRACUNIT), w*FRACUNIT)), w), 1, ramp[0]|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
    end
    local i = 0;
    local sstep = width / 16;
    v.drawFill(px + xpos, (200 - 1), width, 1, ramp[15]|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
    while i < 16 do
        local c = ramp[i]
        local x = 0
        while x < sstep do
            v.drawFill(px + xpos + (i * sstep) + x, (200 - 1), 1, 1, c|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT)
            x = x + 1
        end
        i = i + 1
    end
end
local function intermissionScreen(v)
    if v.renderer() == "none" then return end
    if play == nil or not play.valid then return end
    if not customIntermission then return end
    local str = "test"
    local tw = v.stringWidth(str)
    local testScore = play.score
    local testTime = play.realtime
    local p = play
    --Time
    v.drawString(targetxpos + txoffset, 4 + ypos, "Time", V_SNAPTOTOP|V_SNAPTOLEFT, "left")
    local f = "%02d"
    local time = testTime
    local str = string.format(f, G_TicsToMinutes(time, true)) + ":" + string.format(f, G_TicsToSeconds(time)) + "." + string.format(f, G_TicsToCentiseconds(time))
    local twidth = v.stringWidth(str, V_SNAPTOTOP|V_SNAPTOLEFT)
    v.drawString(targetxpos + width - twidth, 4 + ypos, str, V_YELLOWMAP|V_SNAPTOTOP|V_SNAPTOLEFT, "left")

    --Score
    v.drawString(targetxpos  + txoffset, 4 + ypos + 10, "Score", V_SNAPTOTOP|V_SNAPTOLEFT, "left")
    local str = "" + testScore
    local twidth = v.stringWidth(str, V_SNAPTOTOP|V_SNAPTOLEFT)
    v.drawString(targetxpos + width - twidth, 4 + ypos + 10, str, V_YELLOWMAP|V_SNAPTOTOP|V_SNAPTOLEFT, "left")

    --Now i have to calculate the bonuses, pain
    local ringBonus = p.rings * 100
    local seconds = G_TicsToSeconds(play.realtime, true)
    local timeBonus = 0
    if seconds <= 600 then timeBonus = 0 end
    if seconds <= 599 then timeBonus = 100 end
    if seconds <= 539 then timeBonus = 200 end
    if seconds <= 479 then timeBonus = 300 end
    if seconds <= 419 then timeBonus = 400 end
    if seconds <= 359 then timeBonus = 500 end
    if seconds <= 299 then timeBonus = 1000 end
    if seconds <= 239 then timeBonus = 2000 end
    if seconds <= 179 then timeBonus = 3000 end
    if seconds <= 119 then timeBonus = 4000 end
    if seconds <= 89 then timeBonus = 5000 end
    if seconds <= 59 then timeBonus = 10000 end
    if seconds <= 29 then timeBonus = 50000 end
    local y = 100 - 32
    local h = 175
    local w = 200
    local name = skins[play.skin].realname
    local col = skincolors[color]
    local c = col.chatcolor
    local ramp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    if color then
        if useOpposite then
            ramp = skincolors[ColorOpposite(color)].ramp
        else
            ramp = skincolors[color].ramp
        end
    end
    local tw = v.stringWidth(name + " ") + v.stringWidth("Got Through")
    local pos = 160 + (tw / 2)
    local ww = w + 8;
    local step = w / 16;
    v.drawString(pos - tw, y, name, c)
    v.drawString(pos - (tw - v.stringWidth(name + " ")), y, "Got Through", V_YELLOWMAP)
    y = y + 20
    pos = 160 + (w / 2)
    v.drawFill(pos - w, y + 8, w, 1, ramp[15])
    local i = 0
    while i < 16 do
        local c = ramp[i]
        local x = 0
        while x < step do
            v.drawFill((pos - w) + (i * step) + x, y + 8, 1, 1, c)
            x = x + 1
        end
        i = i + 1
    end
    v.drawString(pos - w, y, "RING BONUS")
    local s = ringBonus + ""
    local wi = v.stringWidth(s)
    v.drawString(pos - wi, y, s, V_YELLOWMAP)
    y = y + 12
    v.drawFill(pos - w, y + 8, w, 1, ramp[15])
    local i = 0
    while i < 16 do
        local c = ramp[i]
        local x = 0
        while x < step do
            v.drawFill((pos - w) + (i * step) + x, y + 8, 1, 1, c)
            x = x + 1
        end
        i = i + 1
    end
    v.drawString(pos - w, y, "TIME BONUS")
    local s = timeBonus + ""
    local wi = v.stringWidth(s)
    v.drawString(pos - wi, y, s, V_YELLOWMAP)
end
hud.add(hudHandler, "game")
hud.add(intermissionScreen, "intermission")

Edit: Maybe He Is Not Reply This Maybe I Should Attach The File!
 

Attachments

  • L_customhudthing-v1.5.1.lua
    13.9 KB · Views: 139
Last edited:
Sebo2205 updated Sebo2205's custom HUD thing with a new update entry:

Version 1.5.3

didn't actually work on this for a long time so i decided to release an update before releasing a new mod

this update doesn't have any visual changes, other than tails flight meter being a separate bar

also speaking of bars, added support for custom bars, if you want to add support for this mod to your character for some reason

Example bar (place inside of a PlayerThink):
local customBar = {
    -- The style of the bar, 0 is default and 1 is small
    style = 0...

Read the rest of this update entry...
 
Sebo2205 updated Sebo2205's custom HUD thing with a new update entry:

v1.5.5

Another update that changes nothing appearance wise (other than a few minor changes), though it adds a function

the function is: drawLabeledThing()

basically, you can add your own custom stuff in here
View attachment 48658

Example code:
hud.add(function (v, player)
    local c = player.customHudThing
    if c and c.hudEnabled and c.drawLabeledThing then
        local label = "TEST"
        local value = "H"...

Read the rest of this update entry...
 

Who is viewing this thread (Total: 0, Members: 0, Guests: 0)

Back
Top