Code: The preview create
var/mob/preview = new()
src << output(preview, "previewgrid")

Problem description: Ok this works fine for the most part. it grabs the icon and then it grabs the overlays and sends them on their merry way to that grid perfectly fine.

My problem is i went to test just my character create with a few friends the other day and as we were making our sexy lil chars we all noticed that the preview would randomly disappear from the grid and then re-appear.

Im not quite sure if our overlays also got mixed because of this.

Either way is there any reason why this would be occuring.

If further code is needed please say the word and it will be provided.

(Naturally this problem does not occur during self testing due to no other players being present.)


This sounds like it could be a garbage collection issue. Since your new mob is stored in a variable that only exists as long as the procedure runs, it is likely ending up deleted at some point, which can cause trouble with grid display.
In response to Schnitzelnagler
Yeah i thought it might of been something to do with garbage collection, but im not quite sure how you would actually go about doing anything about it.

I thought that even though garbage collection would pick up anything not being used it wouldn't delete images if someone else was on the same screen since it is only an image afterall with no relevance after being shown.
In response to Midgetbuster
Midgetbuster wrote:
(...)im not quite sure how you would actually go about doing anything about it.

By keeping an active reference to an object, you can prevent it from being deleted by the garbage collector. Lummox JR had a very informative posting on the subject just recently.
In response to Midgetbuster
if its the garbage collection why not make a tmp var as a reference to it, it could also be useful for other things like a who verb/proc

In response to Masschaos100
Yeah Thanks.

Also the preview was being wiped when the sliders i use for selecting family and affinity are changed

EDIT2; Deleted epic fail code.
In response to Midgetbuster
If you actually have your code like that (the declaration of preview isn't indented under anything, so it's global), that will end up only ever creating one preview mob that always exists. If multiple players see a preview at the same time, all of them will see the last player's icon.

Say, have you even considered just outputting the player's mob to the grid, instead of a new mob made to look like it?
In response to Kaioken
Surprised someone replied.. And yes i tried just outputting it directly to the grid (and yes im aware that previous code screws up i think i changed it but iunno if its a perma fix (or right))

But heck if you got the code that your referring to by all means point me in the right direction

This is what im running.. And i think this works but prove me wrong.

mob/var/tmp/mob/PreviewRef  //Maintains a reference so that garbage monster doesnt eat the preview
var/mob/preview = new()
PreviewRef = preview
src << output(PreviewRef, "previewgrid")

By all means if thats wrong steer me in the right direction, i only learn through practical exercises right?
In response to Midgetbuster
That would work fine. Notwithstanding, you can spare having an extra /mob var which is only useful very seldom (only in character creation I take it) by giving the preview object a tag instead. Then, it's still spared by garbage collection, and you can still find it again later using locate(tag), and remove its tag to make it garbage'd when you no longer need it.
Of course, there could also be other methods to pull everything off without causing all characters to carry an extraneous var forever, but I don't know what exactly you're doing

Yet still, you haven't described why a simple src << output(src,"previewgrid") won't suffice for you. Is the preview display not supposed to update in real-time?
In response to Kaioken
so a simple

src << output(src, "previewgrid")

i didnt think that would work.. but it appears to be working atm. is that what you were talking about?

Reason i didnt try that first is cause it seemed to simple so yea lol

And about the vars, i have a number of vars that check for certain stages to ensure there complete.

Could these vars be avoided ever being in my mob (so never having to use tmp)

And if so, can you point me to a good guide which would explain this in detail for me.