SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 08-03-2018   #1
Lion Sora
SRB2 Freeplay Owner
 
Lion Sora's Avatar
Default HUD help

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
__________________
Creator of SRB2 FreePlay, the SRB2 server for anyone and everyone
Mod is being publicly tested
Lion Sora is offline   Reply With Quote
Old 08-03-2018   #2
"Lat'"
Stop it
 
"Lat'"'s Avatar
Default

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.
__________________
Quote:
Originally Posted by Bronydude2k5 View Post
If you make me a Sash Lilac wad, I'll make you a sonic sprite hack of any choice.
"Lat'" is offline   Reply With Quote
Old 08-03-2018   #3
Lion Sora
SRB2 Freeplay Owner
 
Lion Sora's Avatar
Default

Quote:
Originally Posted by "Lat'" View Post
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"
__________________
Creator of SRB2 FreePlay, the SRB2 server for anyone and everyone
Mod is being publicly tested
Lion Sora is offline   Reply With Quote
Old 08-04-2018   #4
Lion Sora
SRB2 Freeplay Owner
 
Lion Sora's Avatar
Default

thanks anyways, i used what you put and it works perfectly now
__________________
Creator of SRB2 FreePlay, the SRB2 server for anyone and everyone
Mod is being publicly tested
Lion Sora is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.