#Input with Icon Help

1 messages · Page 1 of 1 (latest)

latent tide
#

I'm trying to build an input() prompt using a token's icon as shown in the wiki input() function entry (screenshot 1), where the tokens' name appears to the right of the token's image in a drop-down selection list.

The wiki example input() code for acheiving what's shown in screenshot 1 is:

    "targetNum|"+imgList+"|Select Target|LIST|SELECT=0 ICON=TRUE ICONSIZE=30",

But it never mentions how the list (+imgList+) should be constructed.

I have the following:

[h: vList = listAppend(vList, getTokenImage("", vTok))]
[h: vList = listAppend(vList, getName(vTok))]

But when I use:

    "vSource|"+vList+"|Select Source Token|LIST|SELECT=0 VALUE=STRING ICON=TRUE ICONSIZE=30",

in my input() dialog, I get what's shown in the second screenshot. I'm wondering how I can make it so that the icon image and token name appear on the same line in the drop-down list?

Thanks in advance for any support!

rancid pulsar
latent tide
rancid pulsar
#

What aliasmask did, if I'm reading it right, was created table for each row / selection.

latent tide
# rancid pulsar What aliasmask did, if I'm reading it right, was created table for each row / se...

Hmm, I think that would work with trying to just show multiple images in a single label (or maybe other) input lines, but it doesn't really address how a list should be formed to include the token's name along with an image in the same element. 🙁

I'm sure it's something super simple, as it's a pretty straightforward example on the wiki, just doesn't specify how to build the imagelist string variable, other than mentioning it's a string list containing image asset IDs ("Note that the prompt section for each list contains a list of items, or a variable containing a String List (e.g., the variable imgList). In the first list, the ICON and ICONSIZE options are set, because that list contains image asset URLs for token images. ")

Just need to somehow get the input dialog to understand that a name and token's image go together for the purpose of selection in the drop-down menu.

rancid pulsar
#

Don't do two images, do one image and the text, It doesn't matter what you put in the <td> </td>
There was also a hack where you should not include the closing </html>. Can't find it now tho.

brisk crypt
#

If you want multiple selectable image on the same row then use radio.

rancid pulsar
#

I was going to say, check out this: #1371935730674302976 message

brisk crypt
latent tide
# brisk crypt

That's impressive!

I was really just wanting to recreate the example on the wiki, though. Do you know how the +imageList+ variable would need to be built to have it show just like it does in the screenshot where it shows the "P" icon and "Orc 1" as part of the same choice?

brisk crypt
#

Also...

brisk crypt
#

Oh, getVisible is good too

#

If you want to select multiple targets use check instead of radio.

#

You can try bit of code as well: #1097191721001025677 message

#

or this #archived-macros-questions-in-threads-only message

latent tide
brisk crypt
#

string list

#

if you get a json you can convert it to string list with json.toList

#

Another meme for you...

latent tide
# brisk crypt Another meme for you...

If I use JSON, same issue, as shown in screenshot.

Also, here's my full code:

[h: vTokens = getSelected()]
[h: vMap = getCurrentMapID()]
[h,if(listCount(vTokens) < 2): assert(0,"<b>ERROR:</b>  Please select at least <b>two</b> tokens (at last one that will be the <b>source</b> and one that will be the <b>destination</b> token).",0)]
[h: vList = ""]
[h,forEach(vTok,vTokens,""), code:
{
    [h: vNew = json.set("{}", "tokenName", getName(vTok), "tokImage", getTokenImage("",vTok))]
    [h: vList = json.append(vList, getTokenImage("",vTok), getName(vTok))]
}]
[h: broadcast(vList,"gm")]
[h: status=input("junk||<html><font color=red><style><b>!WARNING! !WARNING! !WARNING!</style></font></html></html>|LABEL|text=false",
    "junk||<html>Will copy <b>ALL</b> Properties to new Token!<br><br> <b>Cannot be undone!</b></style></html></html>|LABEL|text=false",
    "spacer| |<html><nbsp></html></html>|label|text=false",
    "vSource|"+vList+"|Select Source Token|LIST|SELECT=0 VALUE=STRING ICON=TRUE ICONSIZE=30 DELIMITER=JSON",
    "spacer| |<html><nbsp></html></html>|label|text=false",
    "vDest|"+vList+"|Select Destination Token|LIST|SELECT=1 VALUE=STRING ICON=TRUE ICONSIZE=30 DELIMITER=JSON",
    "spacer| |<html><nbsp></html></html>|label|text=false",
    "vConfirm|0|<html><b>Are you sure?</b></html></html>|CHECK|")]
[h:abort(status)]
[h,if(vConfirm < 1): assert(0, "Macro Aborted.",0)]
#

Bera is the token name that should be matched with the image shown in the "Source" drop-down.

#

I can just forego the images to get it functioning for now, but would be much nicer with the images included in the dropdown list. 🙁

brisk crypt
#

vList needs to be different

#

I'll write something real quick

latent tide
brisk crypt
#

Try this [h: vList = ""] [h,forEach(vTok,vTokens,""): vList = json.append(vList,strformat("%s %s",getName(vTok),getTokenImage("",vTok)))]

#

Should just be basic output with image and name

#

no formatting

latent tide
brisk crypt
#

Problem was the input looked like this {"tokenName":"Bob","tokenImg":"sldkfjskdkf"}
where it need to look like Bob aslfajsfd

brisk crypt
#

could have fix with json.get(vNew,"tokenName") instead of using getName()

latent tide
brisk crypt
#

I think someone cut/paste some of their code and didn't check example.

#

Where is it in wiki, maybe I'll fix now

#

under input()?

latent tide