ID:1845816
 
(See the best response by F0lak.)
Code:M.client.images -= I
 mob/proc/ChakraSight()
src.illuminating=1
src.hassharinganilluminate += 1
for(var/mob/npcs/Bunshin/B in world)
if(src.shari)
var/image/I = image('Bun.dmi',B,"clone")
src << I
src.illu = 1
if(!src.shari)
var/image/I = image('Bun.dmi',B,"clone")
B.client.images -= I
for(var/mob/npcs/KBunshin/K in world)
if(src.shari)
var/image/I = image('Bun.dmi',K,"clone")
src << I
src.illu = 1
if(!src.shari)
var/image/I = image('Bun.dmi',K,"clone")
K.client.images -= I
for(var/mob/M in oview(10))
if(src.shari&&M.client)
var/image/I = image('Bun.dmi',M,"normal")
src << I
M.invisibility = 0
if(!src.shari&&M.client)
var/image/I = image('Bun.dmi',M,"normal")
M.client.images -= I
if(M.Ingenjutsu&&M.client)
var/image/I = image('Bun.dmi',M,"genjutsu")
src << I
if(!src.shari&&M.Ingenjutsu&&M.client)
var/image/I = image('Bun.dmi',M,"genjutsu")
M.client.images -= I
sleep(40)
usr.illuminating=0
spawn(100) ChakraSight()


Problem description: Its not letting me remove the images from mobs or clones, the K.client.images -= I piece is just a place holder, same for the one with B instead of K

Best response
You've asked about images three times in the last week. Please read the reference.
I Did, the reference is what I used in the code, its not working. I added this to my other page that I still have up but nobody's responding on it so I started this one. Btw I'm assuming since u posted that, u didn't even read the code or anything even related to my post. Edit: I just closed the other page.
Ah... I don't think you should have closed the other page, even if only out of courtesy for those who gave their time trying to help you.

Anyway, as F0lak did mention in the other thread, you can clear an image offscreen by null-ing it's location i.e.
<image>.loc = null

Even with that answer, just looking at the image reference is not enough, instead try to become familiar with it's make-up and then how it ties in with other dm constructs, like atoms and icons, it'll be beneficial for you.

Also i urge you to take the time to listen to good advice when given to you by others (especially others who have travelled the road longer than you have :P), it'll benefit your learning process for sure.
And what if its not off screen? lol
You're nitpicking. That is not really relevant.

Anyway, your problem is that you are creating a new image and removing the new image, rather than removing the old one. What you want to do is store the image reference somewhere, and then remove it later.
Except I'm trying to remove the new image...The part where !src.shari won't be called unless the other one Above it can't happen, cuz their complete opposites.
     for(var/mob/npcs/Bunshin/B in world)
if(src.shari)
var/image/I = image('Bun.dmi',B,"clone")
src << I
src.illu = 1
if(!src.shari)
var/image/I = image('Bun.dmi',B,"clone")
B.client.images -= I
for(var/mob/npcs/KBunshin/K in world)
if(src.shari)
var/image/I = image('Bun.dmi',K,"clone")
src << I
src.illu = 1
if(!src.shari)
var/image/I = image('Bun.dmi',K,"clone")
K.client.images -= I
Everything below this point is irrelevant atm.
The image you're trying to remove is a brand new one you just created, not the image that you added earlier. If you want to remove that specific image, you either have to look for it or keep track of it after it's created.

This is different from how it works with overlays, which you might be used to working with. With an overlay, whenever you add or subtract to the overlays list you're really only adding or subtracting an appearance, a copy of the image or obj or whatever. So in that case it doesn't have to be the very same obj or image; it only has to look the same.
Ok so how do I remove the 1 I added earlier? and plz don't say something related to a list.
A list is actually the easiest way by far to keep track, if you're adding multiple images at once--which it appears you are.
Im not, lol. Their appearing on different mobs.
Well one thing that confuses me here is that it looks like you're removing images from the wrong mob's clients. If B and K are NPCs, then B.client and K.client would always be null, would they not? When the images are shown, they're shown to src, so logically it's src.client.images that needs to be updated.

From what I can tell, you only add images to src.client when src.shari is true, so logically, you should have a tmp list (you don't need to actually initialize it until using this proc) that holds all the images you created when you called this proc. Then when you call it again when src.shari is false, just subtract that list from src.client.images.
Its all one image but with different icon states, lol. Also in my original post that B.client.images and etc. are just placeholders for a removal code.
In response to Narutogx2
Narutogx2 wrote:
Its all one image but with different icon states, lol.

Do you mean all one icon? I can see that they're all the same icon, but you're creating multiple /image objects. In the first loop when src.shari is true, for each B you're creating a new image and adding it to src.client.images (using the old src << I form). So if you have, say, 12 different NPCs of this type, that's 12 images. That's why I think it's sensible to add those images to a list.

There is another way to do this without lists. Since the image appears to be shareable among multiple clients, you could simply create the image whenever it's needed, and store it in a tmp var belonging to that NPC (e.g., B.clone_image). Then when you remove those images from a player, you can simply subtract B.clone_image from src.client.images. The next time that image needs to be shown to a player, if it already exists then you don't need to create it again.
Ok, could u give me an example on how to do it without lists?
In response to Lummox JR
From what I can tell, you only add images to src.client when src.shari is true, so logically, you should have a tmp list (you don't need to actually initialize it until using this proc) that holds all the images you created when you called this proc. Then when you call it again when src.shari is false, just subtract that list from src.client.images.

Actually it adds them to the people/clones around the src, not the src itself, the src is the one seeing the images on the people/npcs around him/her.
In response to Narutogx2
Narutogx2 wrote:
From what I can tell, you only add images to src.client when src.shari is true, so logically, you should have a tmp list (you don't need to actually initialize it until using this proc) that holds all the images you created when you called this proc. Then when you call it again when src.shari is false, just subtract that list from src.client.images.

Actually it adds them to the people/clones around the src, not the src itself, the src is the one seeing the images on the people/npcs around him/her.

I should clarify. When I say an image is being added to something, I'm not talking about where it's attached; I mean it's being added to a client.images list. So your code is adding multiple images to src.client.images; those images are attached to NPCs.

The clone image is not, I think, unique. Based on what I see in your code, there's no reason multiple players couldn't see the same exact image depending on their shari var. So all you have to do is give each NPC a tmp var that points to the clone image, if it's already been created, and create the image only when it's needed and isn't already in that var. Then when you go to remove the images from a client (because that player's shari var is now false), you'd simply loop through each NPC and subtract their clone_image var if they have one.
Can u give me an example of the code I need to do that tho?