mob
icon = 'player.dmi'
var
hunger = 100
maxHunger = 100
bladder = 100
maxBladder = 100
clean = 100
maxClean = 100
fun = 100
maxFun = 100
social = 100
maxSocial = 100
energy = 0
maxEnergy = 100
Creds = 0
obj/hud_hunger
obj/hud_bladder
obj/hud_clean
obj/hud_fun
obj/hud_social
obj/hud_energy
overlays = list()
proc
decrementNeeds()
while(1)
hunger = max(0, hunger - 1)
bladder = max(0, bladder - 1)
clean = max(0, clean - 1)
fun = max(0, fun - 1)
social = max(0, social - 1)
energy = max(0, energy - 1)
updateHUD()
sleep(100)
updateHUD()
updateBar(hud_hunger,"hunger",hunger, maxHunger)
updateBar(hud_bladder,"bladder",bladder, maxBladder)
updateBar(hud_clean,"clean",clean, maxClean)
updateBar(hud_fun,"fun",fun, maxFun)
updateBar(hud_social,"social",social, maxSocial)
updateBar(hud_energy,"energy",energy, maxEnergy)
proc
updateBar(obj/hud_obj,need, current, max)
var percent = (current / max) * 100
if (percent > 75)
hud_obj.icon_state = "[need]_full"
if (percent > 50)
hud_obj.icon_state = "[need]_half"
if (percent > 25)
hud_obj.icon_state = "[need]_empty"
New()
..()
createHUD()
spawn() decrementNeeds()
proc
createHUD(client/c)
hud_hunger = new /obj/HUD/hunger_bar
hud_bladder = new /obj/HUD/bladder_bar
hud_clean = new /obj/HUD/clean_bar
hud_fun = new /obj/HUD/fun_bar
hud_social = new /obj/HUD/social_bar
hud_energy = new /obj/HUD/energy_bar
hud_hunger.screen_loc = "1,1"
hud_bladder.screen_loc = "1,2"
hud_clean.screen_loc = "1,3"
hud_fun.screen_loc = "1,4"
hud_social.screen_loc = "1,5"
hud_energy.screen_loc = "1,6"
hud_hunger.layer = MOB_LAYER + 1
hud_bladder.layer = MOB_LAYER + 1
hud_clean.layer = MOB_LAYER + 1
hud_fun.layer = MOB_LAYER + 1
hud_social.layer = MOB_LAYER + 1
hud_energy.layer = MOB_LAYER + 1
client.screen += hud_hunger
client.screen += hud_bladder
client.screen += hud_clean
client.screen += hud_fun
client.screen += hud_social
client.screen += hud_energy
updateHUD()
mob
verb
checkEnergy()
src << "Energy: [energy]/[maxEnergy]"
proc
addEnergy(amount)
energy += amount
if (energy > maxEnergy)
energy = maxEnergy
src << "Energy increased to [energy]/[maxEnergy]"
Problem description: Hello, I am trying to make a hud that shows bubbles that are various colors for each stat like hunger etc like in the Sims. I made the icons all in hud.dmi and each stat has 3 states. (like hunger_full,hunger_half and hunger_empty for example) But even though I get no errors the hud does not appear. I have not used Byond in a while and have been reading randomly on the forum and the documentation to brush up so I am likely just missing something or maybe my approch is wrong. I used to just use stat panel but I have always wanted to do away with that and use huds instead and I am hoping this would be a good learning project for me so I understand how they work better so any advice would be a big help. Thank you!
If the whole of the function is not working, it is your job to identify just where it is failing. First thing I'd do is comment out the updateHUD() call in your "CreateHUD()" function. From there, you can see if the problem persists. If not, then we know updateHUD() is the problem.
EDIT:
Also, lets make sure that the HUD objs all have a default icon_state.