ID:2403000
 
Code:
/obj/security_monitor
name = "Monitor"
appearance_flags = KEEP_TOGETHER
icon_state = "monitor"
var/image/full_image = new

New()
..()

full_image.appearance_flags = KEEP_TOGETHER
src.full_image = image('stuff.dmi', "crate")
src.overlays += src.full_image

mob/verb/add_contents()
for (var/obj/security_monitor/M in world)


//delete vis_contents contents
M.full_image.vis_contents = null

//populate vis_contents
for (var/i in view(1, src))
if (isturf(i))
M.full_image.vis_contents += i
world << "added"
break


Problem description:

Basically, I'm trying to make a TV screen that will display a group of turfs somewhere else on the map. I thought the easiest way to do so would be to make a TV monitor frame Icon, and add a blank image as an overlay to that object for which I will add the turfs to its vis_contents so that I can offset and scale down the displayed turfs to fit snugly in any sized TV monitor I want to make with a few transforms.

I can't seem to display the vis_contents of the /image when it's added as an overlay to that object, the correct image icon will appear, the crate(placeholder), but not vis_contents.

For explanation purposes, I have a world with a single obj/security_monitor on the map. In the add_contents verb on /mob, I try to add the turfs adjacent to the mob to vis_contents of the /image in that security_monitor object.

It seems like the code executes properly, and the "added" printf displays in the chat log, but the image does not display its vis_contents.

I assume that the problem is that there's some weirdness with displaying something with vis_contents as an overlay. If that's the case I'm really not sure what the best way to do this is, maybe just another blank object to represent the screen and add its vis_contents, but that seemed clunky to me.
Ironically, you'd also want to use vis_contents instead of overlays to display the object the things are attached to, I'm not even sure an /image is going to do what you want unless you display it to everyone as they login using <<.

Basically with an overlay you're adding an appearance to overlays, not the actual object (though it is stored in the list using a reference to the object), so updates to that object won't be reflected by the one that's in your overlays unless you remove it and add it back, causing an appearance update.

vis_contents doesn't suffer this limitation and it's one of the biggest reasons to use it at all.
That makes sense to me, I guess I only bothered with trying to display the image to it as an overlay on the object because I was more used to that. I assumed that the vis_contents of that image would update should display for everyone.

But in my floundering explanation of how I tried to solve my problem I kind of got away from asking about the problem itself. Ideally, I wanted to add the surrounding turfs to the vis_contents of the monitor object AND offset/scale JUST the vis_contents (not the actual object sprite) so that it will appear to fit inside the TV screen.

So I understand that using an image and overlay is flawed since it won't update like vis_contents does, but do I just have to make a new object to add those turfs to its vis_contents and transform/offset that to fit in the area I want? Or how do I manipulate an object's display of its vis_contents WITHOUT changing the referenced turfs or changing the object's sprite?
Apologies, lost track of this post.

I started (but never finished) a system like what you're after for console.

You can find that code at https://github.com/Nadrew/console/blob/development/code/ hardware/security_camera.dm

Like I said, it's not finished, but it may give you an idea of where to head.