ID:913709
 
Keywords: click, icon, images, null
(See the best response by Super Saiyan X.)
Code:
mob
proc
IconPop()
world<<"([src.icon]) clicked"
if(!src.icon)
world<<"No valid icon detected"

if(src.icon == "")
world <<"Invalid icon Detected"
src.DownloadImage()

if(src.icon == null)
world<<"Null Icon Clicked [src], [src.icon]"
src.DownloadImage()

if(src.icon == "")
world<<"Blank Icon Found, Icon is [src.icon]"
src.DownloadImage()


Problem description:

I am creating icons from images and then assigning them to objects. Im tring to figure out a way to find out whether the icon is null or if its blank because sometimes I get a blank icon whilst other icons display on the object. I want to make it so when I click on the blank icon it will check whether its blank or not. Note the user will see a blank icon which can be clicked

None of the above works, i just get world<<"() clicked" whether the icon displays or not.

Anyone know how to do this ?

Any help would be great, thanks
"\icon [src.icon]"
?
You run two seperate checks for the exact same thing. I'm assuming you're calling this from inside Click()? Ensure that the mob/obj you're trying to click has a mouse_opacity of 3.

Other than that, I can't help you at the moment.
Not Quite,

looking for something like

if("\icon[src.icon]") // if the icon will display with something that can be seen then it will approve. Right now some icons are blank and some icons display but that still does not do what I want. Maybe if anyone knows a icon size check code ?
\icon is a text macro and cannot be used in an if statement like that.

mob/verb/test()
src << "\icon[src]"


This will output your current icon.
Sometimes I get a blank icon due to errors, I want to know whether I can check the size or check if the icon exists and is set basically. I have been trying,

if(src.icon) {do this else reassign icon} but that does not work.

Hope that helps, need help on this

Thanks!
Best response
You can check the size.
there is a length() procedure.
length(iconfile)

You could also check the size of a specific icon state (or the blank icon state) like this
mob
verb
test_length(_icon as icon)

var/_ic = input("") in icon_states(_icon)+"blank"

if(_ic=="blank") _ic = ""

var/icon/t = icon(_icon, _ic)
t = fcopy_rsc(t)
world << length(_icon) //the size of the entire file

world << length(t) //size of the icon state (with the name of the icon_state, and other stuff considered)

world << length(t) - length(_ic) //subtract the name of the icon_state...this should always equal 20, atleast from my testing.


otherwise, you can just check the entire icon if it's blank or not.
mob
verb
test_length()
world << length('your file here.dmi') //or a variable icon/file in place of a string.