ID:1755928
 
(See the best response by Reformist.)
Code:
        SightCheck()
for(var/Curiosity/C in view(src))
if(Per.Value >= C.Sight)
var/image/I = image(C.icon, C)
I.icon_state = C.StateText
src << I


Problem description:
I'm trying to make it so that the images only appear to people that pass sightcheck but no matter what I try, the player does not see the image.

Also this is a mob proc, just in case you need to know.
Best response
I assume the item in question has its invisibility variable changed, and the player cannot see it at all times. This is why it's not working with view().

view() proc

Returns:
A list of visible objects within Dist tiles of Center.

range(src) should do the trick for that.

The image() proc can set an icon_state for you, by the way. Simply:
var/image/I = image(C.icon, C, C.icon_state)

Or in your case, replace C.icon_state with C.StateText.
The item in question has an icon state of null so that other players can't see it. So view() is perfectly acceptable. And I tried your image() variation among many others the night I posted this. In fact I might have gone through just about all of the syntactic methods of image(). What you see is the last iteration. Your fix will not work. I can upload source files if you think that'll help you find the issue faster.
Side note, I think image() can also take an object as an icon argument to directly copy its appearance.
In response to Kaiochao
I thought that was how image() worked. That's why I figured I'd have to set icon state. But the objects have to be hidden from sight and player verb usage until they can "see" the target. So they exist on the map but the player doesn't see them unless the sight thing is done.
mob
verb
SightCheck()
for(var/Curiosity/C in range(src))
if(5 >= C.Sight)
var/image/I = image(C.icon, C, C.icon_state)
src << I

Curiosity
var
Sight = 2
invisibility = 99
parent_type = /obj
icon = 'Curiosity.dmi'
icon_state = "Pickle"


This is what I tested with, and it worked fine.
In response to Lugia319
I mean, image(A, B) would make an /image with the appearance of some object A, attached to some object B.

DM Reference:
icon: An icon [e.g. C.icon], object prototype [e.g. /Curiosity/Blah], object instance [e.g. C], or other image.
In response to Kaiochao
Gave it a go, still works. Which means the issue is indeed view().

mob
verb
SightCheck()
for(var/Curiosity/C in range(src))
if(5 >= C.Sight)
var/image/I = image(C.icon, C)
src << I
You code didn't work when I plugged it in. I checked to make sure SightCheck() was being called and it wasn't for some reason. I was calling it at the end of an overridden Move() proc which apparently it didn't like. I changed Move() to only call procs, problem solved itself. view() still works (because I'm not using invisibility)

EDIT: Unfortunately it seems that everyone sees the image immediately and not when sightcheck is called for them exclusively. Nevermind, I did some work with debugging code that always made it appear to everyone. Works fine.