ID:151536
 
I figured out a workaround for the whole icon_state macro dilemma. It has probably occurred to some people but I'd just like to state it myself, just so I get credit for it.

You simply save the current icon state into a temporary variable, change the icon state into what you want it to be in the text output, then output the text, then change it back using the temporary variable! It's so simple!

It's genius in its simplicity. After I thought of it I was thinking myself to be a fool for not thinking of it before. But I realize that's unfair. I was just being lazy before. XD
I'm completely unsure if I understood what you're trying to achieve here, so I can only assume.
If you want to display a specific icon_state of a generic icon in a standard output on BYOND, there is a specially designed img tag for this.
In response to Schnitzelnagler
Schnitzelnagler wrote:
I'm completely unsure if I understood what you're trying to achieve here, so I can only assume.
If you want to display a specific icon_state of a generic icon in a standard output on BYOND, there is a specially designed img tag for this.

Yeah, but it doesn't always work... specifically, it doesn't work in the mini-browser.

Note that the \icon macro does not work in the 
mini-browser; it is only for text output. To make icons
appear in an HTML document, use browse_rsc() to send an
icon to the client before using browse() to display it.


I just found a work around that should work no matter what the situation is. Even if you have to use a lot of \icon macros this should work for every single one of them, with the correct timing of commands of course.
TuringAI wrote:

You simply save the current icon state into a temporary variable,
change the icon state into what you want it to be in the
text output,
then output the text, then change it back using the temporary variable! It's so simple!

Am I missing something? Because \icon is for the text output, like what Schnitzelnagler said. Then you say something about a mini-browser, and you never mentioned that in this post up there ^
In response to Leur
Leur wrote:
TuringAI wrote:

You simply save the current icon state into a temporary variable,
change the icon state into what you want it to be in the
text output,
then output the text, then change it back using the temporary variable! It's so simple!

Am I missing something? Because \icon is for the text output, like what Schnitzelnagler said. Then you say something about a mini-browser, and you never mentioned that in this post up there ^

Yeah, you can't make a specific icon state of an icon to be the one that is set in the mini-browser. I just found a workaround that is guaranteed to replicate the functionality of the non mini-browser htmlwise WRT icon_state.
In response to TuringAI
Perhaps this would be clearer if you would simply post a code snippet of what you are talking about.
In response to Garthor
Well since you asked I will show you what it is about which I am talking. You can try it out yourself. It will always work.

var/temp
temp = icon.icon_state
icon.icon_state = "desired"
usr << "This is the desired icon state: \icon [icon]"
icon.icon_state = temp


I've seen a lot of threads about this and this is the best way to represent non-current icon states in the mini-browser.
In response to TuringAI
TuringAI wrote:
> var/temp
> temp = icon.icon_state
> icon.icon_state = "desired"
> usr << "This is the desired icon state: \icon [icon]"
> icon.icon_state = temp
>

I've seen a lot of threads about this and this is the best way to represent non-current icon states in the mini-browser.

Or...You know.... image()
src<<"\icon[image(icon,icon_state="desired")]"
In response to Leur
Or icon() as well:
src<<"\icon[icon(src.icon, "icon_state")]"


As a side note, this so called "mini-broswer" is more well known as an output screen (or output element)
In response to GhostAnime
Yeah, but to the best of my knowledge they don't always work. Either that or the feature you are talking about is relatively new to BYOND, since it sure didn't work at this point in time.
In response to TuringAI
That's a browser, not a mini browser nor a text output, What you suggested earlier wouldn't work since it would only return the first state listed in the icon regardless like it usually would.(unless I did it wrong)
In response to Leur
Leur wrote:
That's a browser, not a mini browser nor a text output, What you suggested earlier wouldn't work since it would only return the first state listed in the icon regardless like it usually would.(unless I did it wrong)

You mean what I did here? Or what that other guy said? Because I know what he said doesn't work on, as you say, browsers. At least not when you have to put a bunch of other text along with it.

I think I may need to be more specific about my discovery though, the object may need to be somewhere on the map and you need to reference that particular instance. When I generalized the code I may have overlooked that. No problem though, because you can just create a new object and then delete the object after you're done using it for icon_state browser html generating purposes.
In response to TuringAI
I have been here since '03, so I am pretty sure that this method is not new. If anything, it usually is often ignored or forgotten.

Text output != browser.

The \icon macro was meant to work for the text outputs initially (I am not too sure but I think they work in grids as well).
<font color="#2a4680">(BTW, your work-around doesn't work for browsers as you inferred it earlier in 749677; the link mentioned 749750 is an example of one scenario it doesn't work in.)</font>
If you read the bottom of the reference that Schnitzelnagler ([link]) provided, it explicitly states it does not work in browsers (more specifically, "in HTML documents"). To make it appear in HTML documents, you need to use browse_rsc.
In response to GhostAnime
In the case where you want a specific icon_state, using the full faux-HTML tag is preferable:

src << "<IMG CLASS=icon SRC=\ref[usr.icon] ICONSTATE='[usr.icon_state]'>"
In response to TuringAI
TuringAI wrote:
Yeah, but to the best of my knowledge they don't always work. Either that or the feature you are talking about is relatively new to BYOND, since it sure didn't work at this point in time.

If you actually read that thread, I already answered how you display a specific icon state in an HTML window.
In response to Garthor
Garthor wrote:
TuringAI wrote:
Yeah, but to the best of my knowledge they don't always work. Either that or the feature you are talking about is relatively new to BYOND, since it sure didn't work at this point in time.

If you actually read that thread, I already answered how you display a specific icon state in an HTML window.

I did read the thread, but the solution provided was unacceptable, because it involved creating a new file that would not only have to be deleted manually outside the executable and the editor, but that new file would have to be distributed to everybody who needed to view the file.
In response to Garthor
Garthor wrote:
In the case where you want a specific icon_state, using the full faux-HTML tag is preferable:

src << "<IMG CLASS=icon SRC=\ref[usr.icon] ICONSTATE='[usr.icon_state]'>"


That didn't work when I tried it. Unless there's something about src output that's somehow different from usr output.
In response to TuringAI
TuringAI wrote:
Garthor wrote:
In the case where you want a specific icon_state, using the full faux-HTML tag is preferable:

src << "<IMG CLASS=icon SRC=\ref[usr.icon] ICONSTATE='[usr.icon_state]'>"

That didn't work when I tried it. Unless there's something about src output that's somehow different from usr output.

I copy-pasted that just now and it worked flawlessly. There's something wrong with how you're doing things.
In response to TuringAI
Files created using icon() are not created as separate files on your hard drive. They go into the .dyn.rsc file, and do not need to be "deleted manually". As for distributing it to everybody who needs to view it, that's something that needs to happen anyway.

Also, I'm curious: how does your solution apply to output to a BROWSER window, which seems to be what you're talking about?