Can I nestle a command inside an image?

Ketchup
Fairly recent lurker.. first time poster here. I've two questions..

First, not sure if I am using the correct terminology here, but I have an image.. and I'd like it if the image was clickable. Clicking the image would execute the command 'go to' and move the player to a different room.

Secondly, if it is possible to do the above, how can I go about setting the correct position of the picture? I am hoping to be able position it with a more specific position than just left, right, or center.

I appreciate all those who've posted on the forum with solutions as they help more than just the OP. I've been through many many many threads already and have used the help provided in them, I just couldn't find anything regarding this.

jaynabonne
I have a solution, but I hope it's not too confusing. I'm assuming you're using the GUI editor. (If not, I can provide the corresponding code view script, but it might be easier to use the editor anyway.)

Where you want the picture to show up, add a "Print a message" script command, and then first change "message" to "expression". Then drop in something like this in the field after "expression":

"<img style='position:relative; left:100px;' onclick='sendCommand(\"go to kitchen\")' src=" + GetFileURL("9.png") + "/>"

This is only a sample. The key parts are

1) the name of the image you want to show as the GetFileURL parameter (9.png, in this example),
2) the command you want executed when clicked as the sendCommand parameter (go to kitchen, in this example), and
3) the horizontal position where you want the image to show up. The position is set to "relative" in the style so it can be positioned.

That might be a bit much, but it does work. If you have any questions or trouble, please let me know.

The Pixie
You can do this more easily, but without the option for positioning, using the text processor, though when typing it you would nestle the image in the command. Eg:

{command:go to kitchen:{img:9.png}}

Silver
I've been wondering about this too so cheers for that. It means I can make elements of my in-game UI graphical. I take it that onclick is javascript so therefore it'd be easy to add a mouseover command (if that's the correct terminology)?

Sorry, that's in response to Jay.

jaynabonne
The Pixie wrote:You can do this more easily, but without the option for positioning, using the text processor, though when typing it you would nestle the image in the command. Eg:

{command:go to kitchen:{img:9.png}}

That's cool!

jaynabonne
Silver wrote:I've been wondering about this too so cheers for that. It means I can make elements of my in-game UI graphical. I take it that onclick is javascript so therefore it'd be easy to add a mouseover command (if that's the correct terminology)?

Sorry, that's in response to Jay.

Yes, you can add a mouseover or any other HTML/JS sort of niftiness.

Silver
Cool. That's now on my ever growing todo list.

Ketchup
jaynabonne wrote:I have a solution, but I hope it's not too confusing. I'm assuming you're using the GUI editor. (If not, I can provide the corresponding code view script, but it might be easier to use the editor anyway.)

Where you want the picture to show up, add a "Print a message" script command, and then first change "message" to "expression". Then drop in something like this in the field after "expression":

"<img style='position:relative; left:100px;' onclick='sendCommand(\"go to kitchen\")' src=" + GetFileURL("9.png") + "/>"

This is only a sample. The key parts are

1) the name of the image you want to show as the GetFileURL parameter (9.png, in this example),
2) the command you want executed when clicked as the sendCommand parameter (go to kitchen, in this example), and
3) the horizontal position where you want the image to show up. The position is set to "relative" in the style so it can be positioned.

That might be a bit much, but it does work. If you have any questions or trouble, please let me know.


Whoa! Thanks so much, this is exactly what I needed. I tested it out and it works perfectly, plus I learn so much better when examples are given to me. I was able to read up a bit more on relative positions and applied some of that knowledge with this snippet. It actually made sense.

Also, the GUI editor is what I am using at the moment, but I switch back and forth from that to code view just to learn too. Maybe one day I can actually just use the code view option and write. :P

Thanks so much, jaynabonne.

Ketchup
The Pixie wrote:You can do this more easily, but without the option for positioning, using the text processor, though when typing it you would nestle the image in the command. Eg:

{command:go to kitchen:{img:9.png}}


Thanks, Pixie! I will be using this alternative as well.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums