ID:2384601
 
Code:
client
var/list/upcomingturns = new/list()

proc/DRAWTURNHUD(var/list/UT)
if(!UT)
return
upcomingturns = UT.Copy()

var/obj/TurnHUD/first = upcomingturns [1]
first.screen_loc = "CENTER+18,CENTER+12"
first.maptext = first.name
first.maptext_width = 64
first.maptext_height = 32
first.maptext_x = 32
first.maptext_y = 25

var/obj/second = upcomingturns [2]
second.screen_loc = "CENTER+18,CENTER+9"
second.maptext = second.name
second.maptext_width = 64
second.maptext_height = 32
second.maptext_x = 32
second.maptext_y = 25


Problem description:So I'm trying to show, within a HUD element the mobs in the upcoming turns. My initial thought was to equate an object variable to the item in each index of the list. However, in doing so, if I edit the maptext of the obj, it also edits the maptext of the mob. Any suggestions for better way of going about this?

First of all, when you set those objects to the contents of upcomingturns, you're literally associating them together, what you meant to do was to create new objects of the same types, which you could've done with a for() loop and the type var.

BUT you shouldn't need separate objects to represent the mobs that you want to add to your screen, you can just add the mobs themselves (close to the way you're currently doing it) and remove the maptext after a certain amount of time (when the round starts).

client
proc/DRAWTURNHUD(var/list/UT)
var/tmp/Y = 12
for(var/mob/a in UT)
a.screen_loc = "CENTER+18,CENTER+[Y]"
Y -= 3
a.maptext = firstname
spawn(50)a.maptext = null

And you can set the rest of the maptext variables in the default mob vars, since they appear to be all the same in your case.
In response to Konlet
Konlet wrote:
First of all, when you set those objects to the contents of upcomingturns, you're literally associating them together, what you meant to do was to create new objects of the same types, which you could've done with a for() loop and the type var.

BUT you shouldn't need separate objects to represent the mobs that you want to add to your screen, you can just add the mobs themselves (close to the way you're currently doing it) and remove the maptext after a certain amount of time (when the round starts).

> client
> proc/DRAWTURNHUD(var/list/UT)
> var/tmp/Y = 12
> for(var/mob/a in UT)
> a.screen_loc = "CENTER+18,CENTER+[Y]"
> Y -= 3
> a.maptext = firstname
> spawn(50)a.maptext = null
>

And you can set the rest of the maptext variables in the default mob vars, since they appear to be all the same in your case.

While that shows their name in their maptext, and then disappears some seconds later, it does that for both the HUD element and the actual mob. I understand why that is, as they are associated, but I want to permanently display the text within the HUD without effecting the maptext of the actual mob.

That said, this has given me a much cleaner method to draw the HUD, so that's still be helpful.

In response to Ko Senpai
I was under the impression that the mobs wouldn't be shown to the user while it shows them that they're upcoming. If you need to make a new type, it's pretty straightforward.

var/mob/m = new a.type