ID:2412683
 
Code:
mob/verb
TestHUD()
createHUD()

mob/proc

createHUD() for(var/BodyPart/A in src)


HudGroups += list("HudGroup_row1" = new/HudObject(client=src.client)) //This should be based on each limb, and not a single .dmi


var/HudObject/hudrow_1 = HudGroups["HudGroup_row1"]

hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Left Arm Healthy", screen_loc="1,1"))

//Using a test .dmi with all body parts in it, these should all reference the icons for each players bodyparts objs
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Left Leg Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Torso Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Right Arm Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Right Leg Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Head Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Throat Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Eyes Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Reproduction Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Ears Healthy", screen_loc="1,1"))
hudrow_1.addObject(new/HudObject(hudrow_1, client=A,icon_state="Mouth Healthy", screen_loc="1,1"))


hudrow_1.renderObjects()
// hudrow_2.renderObjects()



Problem description:


So, I have the top, calling in the var/BodyPart/A in src in order to get all of the src's body parts to be able to be called.

I currently have the HUDObjects with temp icon states that was to prove design concept, but now I need to change it over to call the icon & icon state of each body type.

The bodyparts are named as such:

/BodyPart/Head
/BodyPart/Chest
/BodyPart/Eyes
/BodyPart/Ears
/BodyPart/Left_Arm
/BodyPart/Right_Arm
/BodyPart/Reproduction
/BodyPart/Left_Leg
/BodyPart/Right_Leg

Any help would be greatly appreciated
So what exactly is the problem? Are you saying you do not know how to reference the objects individually to access their properties?

I don't think I'm following and your code is a bit confusing (it seems extra; over-complicated).
I'm trying to change my current code over from referencing a set icon and icon state, to directly referencing the icons that belong to the objects listed in the comments below the icon.

This is essentially a body status HUD system, that will show the body HUD on the player screen and the body parts will change color based on status of limb
I think I get you...

Why not create object types for your body parts and define their information there, as opposed to using a generic HudObject type?

e.g.:
obj/hud
bodypart
part1
icon = 'part1.dmi'
icon_state = "healthy"
part2
part3


Or, alternatively, could you not modify HudObject to be able to accept a different icon in the same way you are specifying an icon_state for them to use?
So, essentially the issue is this:

The icon and icon state are defined in a separate code file. I need to reference that code and have my HUD reflect what that code is doing.

I have something similar happening in a pop up window, but want it to work as a HUD and place all the icons on the same portion of the screen (And build the body essentially)

mob/verb/Toggle_Body_Parts()
set category=null//"Other"
src=usr
winclone(src, "InjurySheet", "Injuries")
winshow(client,"Injuries",1)
//winset(src,"Activities","title=\"Languages Insight\"")
winset(client,"Injuries.GridIC","cells=0x0")
var/Row=0
for(var/BodyPart/S in src)
Row++
src << output(S, "Injuries.GridIC:1,[Row]")
src << output("\[[round((S.Health/S.MaxHealth)*100,0.1)]%\] ([S.Status])", "Injuries.GridIC:2,[Row]")


That is what I am using to display the already defined icons and icon states. I'd like to reference this for the HUD
I'm pretty much trying to call the object as the icon
Or, alternatively, could you not modify HudObject to be able to accept a different icon in the same way you are specifying an icon_state for them to use?

What I said above should be a step in the right direction. If you want to avoid refactoring what you already have, then just reference the body part objects you are already using. It already looks like you are trying to do something like that already with the client=A line in the for() loop, but it looks incorrect (or the client argument is misleading in its name), albeit essentially what I'm suggesting.

obj/HUD for(var/BodyPart/Left_Arm/A in src)
bodypart
LeftArm
icon = A
icon_state = Status


Is this what you're suggesting?
Status is the var that exist where the original object is defined
In response to FKI
The icon states defined are just placeholders, I want the icon states to come from what is pulled in the original objects
In response to FKI
I honestly just need to know how to properly call on the icon/icon state of another obj. That is my main bottleneck
Is this what you're suggesting?

No, not even close. That for() loop is very out of place too.

I honestly just need to know how to properly call on the icon/icon state of another obj.

Reference the object and use it the way you need to. For example, I usually have some sort of universal "update" proc for my HUD objects. If I were to do what you want using your requirements, I would have a unique HUD type where I override my "update" proc to grab the proper information using the body part object it references.
#define HEAD    1
#define TORSO 2
#define LEGS 3

// Defines are used for PART in edit.

mob/var/tmp/paperdoll/doll

paperdoll
parent_type = /obj; screen_loc = "1,1"
part{icon = 'paperdoll.dmi';New(L){layer=L}}
New()
vis_contents = list(
new/paperdoll/part(3),
new/paperdoll/part(2),
new/paperdoll/part(1),
)
proc/edit(PART,STATE)
vis_contents[PART]:icon_state = "[STATE]"

mob/Login()
doll = new/paperdoll
edit(HEAD,"human head")
edit(TORSO,"panda torso")
edit(LEGS,"human legs")
// Creates a character from [paperdoll.dmi] with the icon states in order [Human head, Panda torso, Human legs]