ID:268982
 
Welp I never really thought about this before but, well lets take a look at the following example of a production bar in my game -

proc/Status_BarS(mob/a as mob)
a.overlays-=a.SBS
var/obj/Status_Bar/S/o=new/obj/Status_Bar/S
a.SBS=o
a.overlays+=a.SBS


now what this does to my understanding is it creates a new obj/status_bar/S/o just in the world, and not in the map. so since the location is not put, it simply is located in null, but still exists in world.contents correct?

So by simply removing it from overlays would not actually delete the obj, but simply remove it from the overlays list?

So in order to delete the obj I would have to del(a.SBS) at the beginning, and then create the new one?

Or is that not necessary?

Likewise, if you remove anything from a list you are simply removing it from a list and not deleting it, so anything you create and add to a list to a brief period of time also needs to be deleted in the correct fashion, aye?


on to the next question about my little procedure using while() and a procedure inside while() without spawn() being used to call it.

take a look at this code

proc/Status_Timer(mob/a as mob,timer as num,var/ddd)
if(a.statuscheck==1)return
a.statuscheck=1
a.status=0
a.statusprocess=timer
while(timer)
if(!a) return
if(a.statuscheck==0) return
timer-=a.conw
a.status+=a.conw
Status_Bar(a)
if(timer<=0)timer=0
else
sleep(time)
spawn(1)
if(!a) return
a.overlays-=a.SB
a.statuscheck=0
a<<"[ddd]"
return

what I'm familiar with doing is remembering to put spawn()
in to call a procedure and to prevent infinite loops. However, I do believe that since the procedure to create a new overlay is a small procedure, there is less risk of the world being bogged down. Then again, every player will have 3 of these procs going at the same time a good majority of the time...

So in this case, this proc is wrong simply because Status_Bar(a) does not have a spawn() infront of it, causing possibility of problems arising.

or am I wrong? does spawn() not needed to be there?
what other errors can you see in this proc? Shouldn't I delete a.SB (since it's equal to an object) to delete the object from world and remove it from the system cache?

Another thing, would setting the background to 1 be any different really then spawn() or sleep() and would it have more positive resaults? I don't quite understand the background thing... does it mean it runs slower, or just spawns randomly sleep() somewhere at any given point in the procedure?

*Note the status bar example up above was trimmed, it doesn't contain the change icon_state information which a lot of the variables in the above procedure correlate to.
Jon Snow wrote:
now what this does to my understanding is it creates a new obj/status_bar/S/o just in the world, and not in the map. so since the location is not put, it simply is located in null, but still exists in world.contents correct?

So by simply removing it from overlays would not actually delete the obj, but simply remove it from the overlays list?

So in order to delete the obj I would have to del(a.SBS) at the beginning, and then create the new one?

Or is that not necessary?
No---at least I don't think so. Objects are removed by garbage collecting when there are no references to them. The object should be in the world.contents as well. Everything (all areas, turfs, mobs, and objs (and others?)) are in the world.contents. Note that this doesn't count as a reference to garbage collecting. (And garbage collecting ignores turfs and areas as well.) I suggest reading the article on garbage collecting itself, that could probably answer a lot of your questions.
In response to Nova2000
wow -- just about all of them. I had no idea that was there nor would I think that it was there :) Thanks a ton!