ID:1170078
 
(See the best response by Keeth.)
Hello,

I have screen objects that are created within my game, but my problem is that i cannot manage to remove them when needed.

Here's an example of what I am doing:

    verb
add_hud()
usr.client.screen += new/obj/black
remove_hud()
usr.client.screen -= /obj/black



This isn't the code I want to implement what I am trying to do, but it is a simpler version.

The add_hud() works, and adds an onscreen object at a location i have specified.

The remove_hud() does not work. I'm assuming I'm using the code incorrectly, and if so, it's only because I am still learning.

I have tried looking through the forums and in Dream Maker's built in help, but to no avail.

What am i doing wrong?


Balt
Best response
The screen is not like the overlays list. The screen is literally a list of objects that are on the screen, unlike the overlays list which is just a list of images and has all sorts of shortcuts to make it easier to add and remove overlays.

If you want to remove /obj/black from your screen, you need to get the /obj/black object and remove it. Which you can either do by locating it (locate()), or storing the reference ahead of time.
So I would call the locate() proc and locate the /obj/black, and then del() it?

Or how would I go about doing it?

After locating the obj on the screen, what is the command to have it removed?

Balt
Either delete it or subtract if from client.screen
I solved my issue by adding the /obj/black and many other objs to a list, and instead of adding the objects, i added the list of objects, which seems to work in 2 ways because i have so many objs i want to add and remove, and because removing via -= and adding via += works with the list.


Thanks for the help.