ID:141296
 
Code:
 // Comments added to explain

var/obj/dam/damage_num/first // Defining

first = new // Creation

var/mob/target = ref
target = target.loc
if(first) first.loc = target // Weird placing system which actually works brilliantly


Problem description:
I'm using a personally modified version of spuzzum's s_damage library, and it works great, and does whatever I want it to do. The problem is really, really, weird. I put objects in a grid, and these objects also change icon and flick. However, this doesn't happen (afaik) to my inventory items (which are also in a grid). So in the end, I'm left with blank icons in my Skillgrid.

The way I add the grid objects;
// I'm leaving out redundant code, so don't be surprised when you see unrelated errors.
var/skillpath = text2path("/obj/playerskill/[src.basejob]/[A]")
var/obj/playerskill/PS = new skillpath
src<<output(null,"skillgrid")
src<<output(PS,"skillgrid")
del(PS)


Inventory is like.. Exactly the same way, and also in a grid.

Paths; (Both of them flick)
/obj/dam/damage_num
/obj/playerskill/
/obj/whatever (Inventory)

Help pretty please? What the hell's going on?
Little update, it seems as though the proc makes a copy of the number it's displaying and outputs it to the grid, because the grid also shows the name of the numbericon.

Why the HELL does it output itself?!

Screenshot to clarify:
http://i161.photobucket.com/albums/t217/Mysame/wtfglitch.jpg
Mysame wrote:
Help pretty please? What the hell's going on?

I'm not entirely sure either (if all else fails, you might want to put together a demo for this), but I may have found a cause. ;P

Mysame programmed:
> var/obj/playerskill/PS = new skillpath
> src<<output(PS,"skillgrid")
> del(PS)


Objects displayed in a grid should be kept in existence. If not, while after they're deleted they will remain displayed until the next update, 'unexpected phenomena' (probably the very artifacts you're experiencing) could occur, most likely (speculation) because the grid is using some sort of internal ID to refer to the [now deleted] object, and that ID is going to be later re-used for something else. Or something to that extent. In short, you shouldn't use temporary objects in grids (should be no different with labels). So in that case you may want to cache objects, et cetera.
Note 1: The obj would still normally be deleted even if you didn't call del() yourself. This is mainly because it has no location, so most likely it's going to be garbage collected. It's a little more recommended to let DM clean up objects itself when applicable (or safe) to do.
Note 2: The Skin Reference specifically warns against the above; here is the excerpt.
"Very important: If you send an atom to a grid like you would with a statpanel, keep that object in a list or make sure it actually exists somewhere in the world. Do not use a temporary object that will be deleted when the proc ends, or it can disappear/change in the grid when a new object is created. Statpanels don't have this problem because of the way they update, but it's a good idea even there not to use temporary atoms."
While probably not applicable/desired for this case, note quick workarounds to prevent objects being garbage collected are leaving it referenced in some var (or list) or giving it a loc or a tag.
EDIT: Added a link for clarity.
In response to Kaioken
They're in a list, and I actually added the delete there to make SURE it's deleted, it was one of my "This might fix it" thingies for this specific bug. Doesn't matter if it's there or not, bug is still there :)

Whenever I attack, random skill icons (wether I delete them or not) change icon to the damage icon, and flick(). So whenever I'm attacking, I'm killing my skillgrid icons :< And this doesn't happen in the inventory grid.

Holy [stuff]. Adding a tag to 'PS' on creation stops this behaviour. o.O Guess I really did had to stop it being garbage collected, and then the reason the Inventory isn't affected is because all of those items have a location (contents). Heh. Good idea there, Kaioken.

On the other hand, I doubt wether this should be default BYOND behaviour :< Flicking an icon outputs it in a grid with a deleted object ? That's just weird. Anyway, yay, fixed!
In response to Mysame
Glad I could help. =)

Mysame wrote:
Inventory isn't affected is because all of those items have a location (contents).

Exactly. Oh, and just not to spread a common misconception: contents itself isn't the location, the player mob is. Locations are, by definition, strictly atoms.

Adding a tag to 'PS' on creation stops this behaviour. [...]
Heh. Good idea there, Kaioken.

And I wondered whether it was worthwhile to add that last sentence about the tag and all, heh. ;) Guess the list you spoke of might also be getting deleted somewhere along the line itself (due to garbage collection!), and as a result so does the obj.

On the other hand, I doubt whether this should be default BYOND behaviour :< Flicking an icon outputs it in a grid with a deleted object?

Well, it wouldn't be a bad idea if upon deletion of an atom DM will try to remove it from any grids and labels, but I it's probably not so trivial to implement.
As to why this weirdness occurs, expanding on my speculation from before, when you use flick() it may be creating some sort of internal object (or *thing*) to display the graphic. Like all objects it's referred to in Dream Seeker (or the world) with a certain ID; and because this object was created just after an object ("SP") got deleted, it ends up getting assigned that object's ID. So it also appears in the grid, because the grid referred to the object ("SP") by its ID, and the ID now points to the flick-stuff... yeah. :P