Multitile Hud Bar only works at 0 and 5+(Resolved) in Developer Help
|
|
Code:
mob/proc hudproc() serp sleep(1) for(var/obj/crhud/grenade1/A in usr.client.screen) for(var/obj/crhud/grenade2/B in usr.client.screen) for(var/obj/crhud/grenade3/C in usr.client.screen) for(var/obj/crhud/grenade4/D in usr.client.screen) for(var/obj/crhud/grenade5/E in usr.client.screen) A.icon_state = "[usr.grenades]grenade" B.icon_state = "[usr.grenades]grenade" C.icon_state = "[usr.grenades]grenade" D.icon_state = "[usr.grenades]grenade" E.icon_state = "[usr.grenades]grenade" goto serp
|
Problem description: Thats the code I have and it only works whenever I have 0 grenades or 5+ grenades however I cant understand why, I've tried recoding this 5 different ways and all of them have produced the same outcome, and before you say it's the icon_states believe me I checked them and thats not it.. Any ideas?
|
1) Avoid using goto unless you have a reason to. Study up on flow control structures (if, else if, else, for, while)
2) The usr variable is not reliable outside of verbs and a procs that require client activity (Click, ect)
3) A little bit of OOP can allow you to program far less. Why bother creating 5 different types of grenade HUD objects when you can create 1 type and offset it's location slightly for the same effect.
Even still, there are better ways to do this, methinks.