[Drop-In] [aliasmask]Disguise: Save/use multiple tkn images

These are tools and utilities that make it easier to run games. This includes Lib: macro tokens dropped into MapTool to manage the game, a conversion file for CharacterTool to allow use in MapTool, or just about anything else you can think of -- except graphics with macros and anything specific to a particular campaign framework. Those are already covered by the Tilesets subforum and the Links and External Resources forum.

Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by Azhrei »

aliasmask wrote:
Azhrei wrote:I'm not sure what this is asking. Images from the server are only sent to the client when the client asks for them. If the client never asks, the image is never sent.
Well, here's the scenario I envision. DM starts a server. Client 1 connects. Client 1 adds a token. Client 1 uses a saved asset value that is stored on Client 1 using Disguise. DM does not have image in his library. Client 1 sees the new token image, DM sees a red X. Client 1 drops the image from his library on to map. DM now gets the asset image transferred to him and his cache. Client 1 deletes unwanted image. Client 2 connects to server.

Does Client 2 see a red X or is the image transferred from the DMs cache?
When the client asks for the image, the server will send it. So Client 2 does not see the red X but sees the actual image.

But that's not really your question. Your question is, "If I refer to an image using an asset id does that cause a request to be sent to the server?" The answer to that question is no.

If Client 2 is referring to the image only by its asset id via an <img> tag or similar, then the client is NOT asking the server for it. The client is expecting it to already be in the cache since the client cannot know what the asset id is unless it is referenced by some part of the MT code and the MT code ensures that it's already in the local cache. (Using the asset:// prefix is a hook into the local cache subsystem that MT keeps up to date internally. If you're directly using asset ids then this scheme is subverted and Client 2 sees a red X.)

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by aliasmask »

Correct on both accounts, and that's pretty much what I figured. Thanks for clearly explaining.

On a semi-related note, is there a bug with importing maps? I received a map from another player and when I imported it, I saw mostly red X's, but looking at the .rpmap file there is an asset folder with the images. Apparently, they were not moved/copied/cached to my system on import.

PS - this is the b86

Ditto
Giant
Posts: 179
Joined: Thu Jul 28, 2011 1:06 pm

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by Ditto »

Wow .. this is pretty handy ... is it easy to switch to a frame? so you can dock it and leave it up and going?

I'm still getting used to frames, so not sure if I can easily modify that lib token to a frame or not ... :)

Any suggestions? things to be careful of in there that might break or not allow a frame?

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by aliasmask »

Ditto wrote:Wow .. this is pretty handy ... is it easy to switch to a frame? so you can dock it and leave it up and going?

I'm still getting used to frames, so not sure if I can easily modify that lib token to a frame or not ... :)

Any suggestions? things to be careful of in there that might break or not allow a frame?
Yeah, you can do a form frame instead, which is what I would do if I were to upgrade this just so I can give better image selection options. Just realize, if you switch maps with your token, it's likely the id will change. Making the token selection name based may be another change I would do (instead of using the id). I had a recent idea for a new feature and that was to include extra info like name and size of token. There's not too much to the token and macros as is, so there's lots of room for improvement. Feel free to tweak away.

Ditto
Giant
Posts: 179
Joined: Thu Jul 28, 2011 1:06 pm

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by Ditto »

aliasmask wrote: Yeah, you can do a form frame instead, which is what I would do if I were to upgrade this just so I can give better image selection options.
Yeah, I'm still trying to figure out frames ... I can't seem to build the image/drop down properly ... this is what I got, but it just isn't displaying properly .. the image keeps getting dumped outside ??

Code: Select all

[H: disguises = getProperty("h.disguise")]
[H: tokenImg = getTokenImage()]
[H, if(json.isEmpty(disguises)): disguises = "[]"]
[h: header = "<html><head><title>Disguise</title></head><body><table border='1'>" ]
[h: footer = "</table></body></html>" ]
[H: inputStr = ""]
[H, if(!json.contains(disguises,tokenImg)), code: {
   [H: disguises = json.append(disguises,tokenImg)]
   [h: inputStr = inputStr + strformat("<tr><b>Token Image added to Disguise List:</b></tr><tr><img src='%s' width=100 height=100></tr>",tokenImg) ]
};{
   [H: inputStr = inputStr + "<tr><b>Change Token Image to add to Diguise List</b></tr> " ]
}]
[H: menu = -1]

[h: inputStr = inputStr + "<tr>" ]
[h: inputStr = inputStr + "<input type='radio' name='group1' value='0' checked='checked'>Change Image</input><br>") ]
[h: inputStr = inputStr + "<input type='radio' name='group1' value='1'>Delete Image</input>") ]
[h: inputStr = inputStr + "</tr>" ]

[h: inputStr = inputStr + "<tr><select name='image'>" ]
[h, foreach ( item, disguises ), CODE: {
   [h: inputStr = inputStr + strformat("<option value='%s'><img src='%s' width=100 height=100></option>", item, item) ]
}]
[h: inputStr = inputStr + "</select></tr>" ]

[frame("Disguise"): { [r: header + inputStr + footer ] } ]
Just realize, if you switch maps with your token, it's likely the id will change.
Ok .. I think I understand what you meant .. :?
Not really sure what to do about it, or how to "fix" that ... but I suppose I'll worry about that later .. 1 step at a time :)
Making the token selection name based may be another change I would do (instead of using the id). I had a recent idea for a new feature and that was to include extra info like name and size of token. There's not too much to the token and macros as is, so there's lots of room for improvement. Feel free to tweak away.
Trying ... not having much success :(

Ditto
Giant
Posts: 179
Joined: Thu Jul 28, 2011 1:06 pm

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by Ditto »

Ok .. based on many searches and lots of trials, it appears doing the image in the drop down in a frame/form isn't going to happen ...
Unless somebody has a nice solution?

Ok .. so I changed it to a list of option buttons (I tried image buttons, but they ended up too big, since we can't control image size) ...

The frame/form looks fine, however, not I'm running into problems with getting the macro/action to fire when you click a button ... I've gone over all the frame/form tutorials around ... and I just can't see what I'm doing that won't fire it ... I've tried to break down the code to see where it's failing, but from what I can tell, nothing is failing ... it's just not firing ...

So .. starting with your lib:disguise.
I added a new macro button on it, named "CreateImage".
And added this line into it ... simply to identify that "yes, it fired" ...

Code: Select all

[h: chk = input("Checkpoint: Change") ]
I then dropped this code in a macro on my token (for testing for now ... once I get it working, I'll drop it into the Disguise token ...).

Code: Select all

[h: processorLink = macroLinkText('ChangeImage@lib:disguise', 'all')]

[H: disguises = getProperty("h.disguise")]
[H: tokenImg = getTokenImage()]
[H, if(json.isEmpty(disguises)): disguises = "[]"]
[h: header = "<html><head><title>Disguise</title></head><body><form name='disguise' action='[r:processorLink]' method='json'>" ]
[h: footer = "</form></body></html>" ]
[h: buttons = "<input type='submit' name='Change' value='Change Image'> </input>" ]
[h: buttons = buttons + "<input type='submit' name='Remove' value='Remove Image'> </input>" ]

[H: inputStr = "<table border='0'>"]
[H, if(!json.contains(disguises,tokenImg)), code: {
   [H: disguises = json.append(disguises,tokenImg)]
   [h: inputStr = inputStr + strformat("<tr><b>Token Image added to Disguise List:</b></tr><tr><img src='%s' width=50 height=50></tr>",tokenImg) ]
};{
   [H: inputStr = inputStr + "<tr><b>Change Token Image to add to Diguise List</b></tr> " ]
}]
[H: menu = -1]

[h: inputStr = inputStr + "<tr>" ]
[h, foreach ( item, disguises ), CODE: {
   [h, if (tokenImg == item): ls = " checked='checked'"; ls = "" ]
   [h: inputStr = inputStr + strformat("<input type='radio' value='%s' %s><img src='%s' width=50 height=50></input><br>", item, ls, item) ]
}]
[h: inputStr = inputStr + "</tr></table>" ]

[frame("Disguise"): { [r: header + inputStr + buttons + footer ] } ]
so then I click on that test button, it brings up the frame no problem .. it sees new images, it lists them .. perfectly ... so I click "Change Image" ... nothing.

if I run [r: macroLinkText("ChangeImage@lib:disguise", "all") ]
I get this back:
macro://ChangeImage@lib:disguise/all/Impersonated?

Which looks correct.
If I run [r: macroLink ( "test", "ChangeImage@lib:disguise", "all") ]
it creates a link .. when I click it ... input box comes up as expected ...

so why isn't the form picking it up? I'm soooo confused ... :?

I tried to reduce it to a smaller script .. and I got this ... it also doesn't fire:

Code: Select all

[h: processorLink = macroLinkText('ChangeImage@lib:disguise', 'all')]

[h: xx = '<form name="disguise" action="[r:processorLink]" method="json">
Character name: <input type="text" name="charName"><br>
Strength: <input type="text" name="str">
<input type="submit" name="Change" value="Change Image"> </input>
</form>' ]

[frame("test"): { [r: xx ] } ]
What am I missing? is it a privilege thing? ie macro on the lib:token is supposed to have some setting? I just don't get it ... :?

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by wolph42 »

I'm currenty mobile and cant check, though I too don't see it. Couple of remarks. DDB with images can't indeed be done in storm but it can be done in Wiki: Input().
Also you can control the size of an image in a form. Don't know how of the top of my head. But its possible.

Ditto
Giant
Posts: 179
Joined: Thu Jul 28, 2011 1:06 pm

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by Ditto »

Ok, got it working on a frame .. (thanks for the tips, CoveredInFish: http://forums.rptools.net/viewtopic.php?f=20&t=19762)

So yeah, Wolph ... not sure if you wanted to massage it a bit more - as it was originally your design .. but I really slapped it into a frame with miminal changes ... (Sorry, just didn't have the time to put much more into at this time).

I kept your original code intact on the same lib ... just added some buttons for the frame functionality:

1) "Use Disguise Frame" button added - user should add this to Campaign panel (or individual token).
2) "DisguiseFrame" button added - this is used to load/reload the frame.
3) "ChangeImage" button added - this is used to react to the button clicks, Change, Remove or Add.

Obviously the benefits of this sitting in a frame should be obvious .. you just open it, dock it .. and then flip images when you need ... no need to keep re-opening the dialogue :P

Cheers!
Attachments
lib-disguise.rptok
Lib:disguise with dockable frame option.
(44.1 KiB) Downloaded 123 times

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by wolph42 »

So yeah, Wolph ... not sure if you wanted to massage it a bit more - as it was originally your design .. but I really slapped it into a frame with miminal changes ... (Sorry, just didn't have the time to put much more into at this time).

I kept your original code intact on the same lib ... just added some buttons for the frame functionality:
Maybe the words came out wrong but this disguise tool is certainly not my work, its alias's

Ditto
Giant
Posts: 179
Joined: Thu Jul 28, 2011 1:06 pm

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by Ditto »

wolph42 wrote:
So yeah, Wolph ... not sure if you wanted to massage it a bit more - as it was originally your design .. but I really slapped it into a frame with miminal changes ... (Sorry, just didn't have the time to put much more into at this time).

I kept your original code intact on the same lib ... just added some buttons for the frame functionality:
Maybe the words came out wrong but this disguise tool is certainly not my work, its alias's
No, you're right, my bad ... with both you and Alias responding, somehow I got the names flipped .. :)
Sorry Alias!! Didn't mean to give somebody else credit! :oops:

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by aliasmask »

No worries. I like to steal other people's work here and call it my own anyway ;) ... so fair's fair.

I'm working on a complete rewrite of Plothos's message manager. Adding some more functionality and adding some bells and whistles to it.

Getting rid of the user entering the message id and instead I'm adding a grouping option with tabs. I'm using an image library of small icons for function buttons. Going to be able to sort by date and name, hide messages (archive?), send messages and allow others to save it in to their own message manager. I'm doing just some small things now, but eventually I'll have a lib:player token that handles player specific variables. Right now, it's token-centric. I still haven't taken a look at your mod, but I'll get to it eventually. I know if I do look at it, I'll probably get distracted from what I'm doing now :)

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by lmarkus001 »

I am considering this mod to the Disguise library inside my framework. What this does is provide a second pull-down list that is populated from the images in the Polymorph table. If you select from one of those, that gets added to your personal list of images...

EDIT: Updated. Now gives 3 picklists, each on a separate tab. All images that have been referenced for disguise (the original list), all visible tokens, all images in the Polymorph table. Plus, if the token's handout image is null, it will be set to the token image (thereby creating a "backup").

EDIT 2: Further Updates. Now will detect if table "Polymorph" exists and if it does not it will function correctly. You can use any table assuming row 0 contains the count of images, and the images are using consecutive numbers in the table. To do this you can pass a second parameter to the disguise call that contains the table name (if no parameter, then it assumes table name Polymorph).
PF Framework Variant

Code: Select all

[H, IF(argCount() > 1): tTableName = arg(1); tTableName = "Polymorph" ]
[H: disguises = getProperty("h.disguise")]
[H: tokenImg = getTokenImage()]
[H: tokenHandImg = getTokenHandout() ]
[H, IF( tokenHandImg == "" ): setTokenHandout(tokenImg); "" ]
[H, if(json.isEmpty(disguises)): disguises = "[]"]

[H: jTables = json.get(getInfo("campaign"),"tables") ]
[H: hasTable = json.contains(jTables,tTableName) ]
[H: jAll = "[]"]
[H, IF(hasTable): cntAll = table(tTableName, 0); cntAll = 0]
[H, IF(hasTable), FOR(i,1,cntAll+1): jAll = json.append(jALL, tableimage(tTableName, i))]

[H: jVis = "[]"]
[H: tTokens = getVisibleTokens("json")]
[H, FOREACH( tok, tTokens ),CODE: {
   [TOKEN(tok): jVis = json.append(jVis, getTokenImage()) ]
}]
[H: image2 = "" ]
[H: image3 = "" ]

[H: inputStr = "" ]
[H: inputStr = json.append( inputStr, "tab0 | Token Images | | TAB" ) ]
[H, if(!json.contains(disguises,tokenImg)), code: {
   [H: disguises = json.append(disguises,tokenImg)]
   [H: inputStr = json.append(inputStr,"label|<html><b>Token Image added to Disguise List:</b></html>||LABEL|SPAN=TRUE",
      strformat("Token Image Added|<html><img src='%s' width=100 height=100></html>||LABEL|SPAN=TRUE",tokenImg))]
};{
   [H: inputStr = json.append(inputStr,"label|<html><b>Change Token Image to add to Diguise List</b></html>||LABEL|SPAN=TRUE")]
}]
[H: menu = -1]
[H, if(json.length(disguises) > 1): inputStr = json.append(inputStr,
   strformat("Menu|Change Image, Delete Image||RADIO|SPAN=TRUE SELECT=%{menu}"))]
[H: inputStr = json.append(inputStr,strformat("image|%s||LIST|ICON=TRUE SPAN=TRUE ICONSIZE=100 VALUE=STRING",json.toList(disguises)),
   'label|<html><br><font color=red><i><b>Hit "Cancel" to close...</b></i></font></html>||LABEL|SPAN=TRUE',
   "tab1 | Visible Map Images | | TAB",
   strformat("image2|%s||LIST|ICON=TRUE SPAN=TRUE VALUE=STRING",(" ,"+json.toList(jVis))),
   'label|<html><br><font color=red><i><b>Hit "Cancel" to close...</b></i></font></html>||LABEL|SPAN=TRUE'
)]
[H, IF(hasTable): inputStr = json.append(inputStr, "tab2 | " + tTableName + " Table Images | | TAB",
   strformat("image3|%s||LIST|ICON=TRUE SPAN=TRUE VALUE=STRING",(" ,"+json.toList(jAll))),
   'label|<html><br><font color=red><i><b>Hit "Cancel" to close...</b></i></font></html>||LABEL|SPAN=TRUE');
""]
[H: hasInput = input(json.toList(inputStr,"##"))]
[H, if(hasInput), code: {
   [H, IF( image2 != "" ): image = image2; "" ]
   [H, IF( image3 != "" ): image = image3; "" ]
   [H, if(menu == 0 || image2 != "" || image3 != "" ): setTokenImage(image)]
   [H, if(menu == 1): disguises = json.difference(disguises,json.append("",image))]
   [H, if(!json.isEmpty(disguises)): setProperty("h.disguise",json.difference(disguises,json.append("","")))]
   [H, macro("Disguise@"+getMacroLocation()): ""]
};{
   [H, if(!json.isEmpty(disguises)): setProperty("h.disguise",json.difference(disguises,json.append("","")))]
}] 
Last edited by lmarkus001 on Thu Sep 29, 2011 10:13 am, edited 3 times in total.

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by aliasmask »

That's fine. I would probably make it another tab though. Also, it would be interesting if you had a 3rd tab for visible tokens on current map. Something I didn't do, because I couldn't before, but I would now, is set the handout image to the first and original image of token so it never "gets lost" or at least have that as an option.

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by lmarkus001 »

In my framework, I provide the option for the Handout to be your DEAD image. I also require any token that uses the dead image (or the Polymorph macro) to have an image:name token in the campaign file so their primary image is never lost.

I do like the addendum of mimicking any token on the current map as that is likely to be a common activity.

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: [aliasmask] Disguise: Save and use multiple images for t

Post by lmarkus001 »

Ok, updated my post above with updated code per your suggestions!

Post Reply

Return to “Drop-In Macro Resources”