HUD help

Status
Not open for further replies.

MikeTheDigiFloof

Creator of Online+
i'm wanting to make a health display that shows diffrent pictures depending on the player's health (a custom health wheel as i am setting) but every time i set it up, it wont work

Code:
		if (p.hp = 1)
		v.draw(5, 5, p_hp1)
		elseif (p.hp = 2)
		v.draw(5, 5, p_hp2)
		end
 
An error message reguarding what's going wrong would help, but reguardless I'll just assume p_hp1 is supposed to be the name of a lump and isn't a local variable representing the cached hud graphic.
  • hud items must be cached using v.cachePatch(<string name_of_lump>), eg: v.cachePatch("p_hp1")
  • Instead of tiresome ifs and elseifs for a simple display, use string concatenation, allowing you to paste the value of p.hp in the string, this works since cachePatch expects a string
  • Lastly, you might wanna use the V_SNAPTO flags so that your HUD looks alright on non green resolutions, with 5, 5 the combination of V_SNAPTO flags would be V_SNAPTOTOP|V_SNAPTOLEFT, all of the above resulting in the following code:
    Code:
    v.draw(5, 5, v.cachePatch("p_hp"..p.hp), V_SNAPTOTOP|V_SNAPTOLEFT)
    -- no need for any ifs or whatever, lumps in cachepatch are case insensitive as well so it doesn't matter.

I hope this helped you.
 
An error message reguarding what's going wrong would help, but reguardless I'll just assume p_hp1 is supposed to be the name of a lump and isn't a local variable representing the cached hud graphic.
  • hud items must be cached using v.cachePatch(<string name_of_lump>), eg: v.cachePatch("p_hp1")
  • Instead of tiresome ifs and elseifs for a simple display, use string concatenation, allowing you to paste the value of p.hp in the string, this works since cachePatch expects a string
  • Lastly, you might wanna use the V_SNAPTO flags so that your HUD looks alright on non green resolutions, with 5, 5 the combination of V_SNAPTO flags would be V_SNAPTOTOP|V_SNAPTOLEFT, all of the above resulting in the following code:
    Code:
    v.draw(5, 5, v.cachePatch("p_hp"..p.hp), V_SNAPTOTOP|V_SNAPTOLEFT)
    -- no need for any ifs or whatever, lumps in cachepatch are case insensitive as well so it doesn't matter.

I hope this helped you.

actully i already did this, but its just not drawing when i add the "if" and "else"
 
Status
Not open for further replies.

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

Back
Top