Using Handouts

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

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

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Using Handouts

Post by Oryan77 »

I've searched the forums but didn't notice anything like this.

I'm trying to come up with a good way to show handouts to my players on my VTT setup. It doesn't need to be anything real complicated. I just want to maybe click a macro, get a list of images that I previously setup with the macro, select an image, and then the image pops up on the screen for everyone to see exactly like it does when you right-click and select "Show Handout" on a token.

I've tried out Lindsay's Generic Tools Handout macro, and although the idea is a good one, it's not very user friendly and a bit clunky.

I also like how the Handout image is handled on tokens when you Show Handout. It's nice how it appears on screen and can be dragged around and resized.

So I'm wondering if anyone has already made something like this, or could do it for me if it isn't much trouble?

Ideally, I would like to be able to add/remove pictures to a list and have a macro show me that list, select from it, and the image appears just like when selecting "Show Handout" on a token. If that's too much trouble, I could even just create tokens and attach a picture as a Handout on each token. I could keep those tokens all on 1 map and when I'm on a different map, I could use a macro or macros that refer to those tokens and run the "Show Handout" option. I just don't know how to set something like that up and I'm terrible at trying to use the wiki and do it myself.

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Using Handouts

Post by CoveredInFish »

The "show handout" option shows the image in a way that is not 100% reproducible by macro.

So first you have to decide to do this completly by macro but with less similarities to the show handout-method

or

use the show handout method and just have some macros help you organize that. BTW you dont have to keep them on a separate map, IIRC having them on the Hidden layer will work fine (or not?).

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Using Handouts

Post by Oryan77 »

My idea is to just put tokens on the Base map, add a handout image to each of them, and then make a campaign macro for each token that will activate the 'Show Handout' function for that token on the Base map. Or would the token have to be on the current map in order for the image to load?

If someone made me a macro like that, how different would the result be from the normal Show Handout option from the tokens pulldown menu? Maybe it is something I can live with.

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

Re: Using Handouts

Post by wolph42 »

Oryan77 wrote:My idea is to just put tokens on the Base map, add a handout image to each of them, and then make a campaign macro for each token that will activate the 'Show Handout' function for that token on the Base map. Or would the token have to be on the current map in order for the image to load?

If someone made me a macro like that, how different would the result be from the normal Show Handout option from the tokens pulldown menu? Maybe it is something I can live with.
it has to be on the same map, unless you add the prefix "image:" (similar to "lib:") to the token name. I know that that particular image is then available on all maps, I'm not sure however if that's also the case for handouts. I've got very limited intell on handouts as I don't use them (at least not for what they were originally intended).

the_meek
Cave Troll
Posts: 99
Joined: Fri Aug 01, 2008 9:18 am

Re: Using Handouts

Post by the_meek »

I put together something almost exactly like you're describing a while ago. I just added the broadcast so it takes up less chat real-estate. You'll need an "ImageList" property and these four macros on a library token:

AddImages:

Code: Select all

[H: Flag = json.isEmpty(getLibProperty("ImageList"))]
[H, IF(Flag):	setLibProperty("ImageList", getSelectedNames("json"));
	setLibProperty("ImageList", json.merge(getLibProperty("ImageList"), getSelectedNames("json")))]
Selected images added to image list.
RemoveImage:

Code: Select all

[H: Images = getLibProperty("ImageList")]
[H: CheckString = listAppend("", "nulVar | Check to remove: |  | LABEL | SPAN=TRUE", "##")]
[H, FOREACH(Image, Images, ""): CheckString = listAppend(CheckString, "Image" + roll.count + " | 0 | " + Image + " | CHECK", "##")]
[H: abort(input(CheckString))]
[H, FOREACH(Image, Images, ""), IF(eval("Image" + roll.count)): Images = json.remove(Images, roll.count)]
[H: setLibProperty("ImageList", Images)]
Images removed.
SendLink:

Code: Select all

[H: abort(input("Image | " + json.toList(getLibProperty("ImageList")) + " | Select image | LIST | VALUE=STRING"))]
[R: broadcast(macroLink("Click to view " + Image + "...", "ViewImage@" + getMacroLocation(), "none", Image))]
ViewImage:

Code: Select all

[dialog("ImageViewer"): {	<html><image src="[R: getImage(macro.args)]">	}]
The images you'll want to send will need the "image:" prefix on their token name and can be on any map, as was mentioned. I'd set a shortcut key to AddImages so you can select tokens and call it easily.

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Using Handouts

Post by Oryan77 »

the_meek wrote:I put together something almost exactly like you're describing a while ago.
Cool! I tried setting this up but I'm having some problems. I barely know anything about creating code. I hope I followed your instructions correctly, but I may be missing something.

I think I have the add and remove macros working since it says an image was added and the remove macro lets me choose that token name and remove it from the list.

But when I hit the SendLink macro, it says "You do not have permission to call the "broadcast" function."

When I hit the ViewImage macro, it says "Error executing "getImage": the token name or id "" is unknown."

When I create the ImageList property in my campaign property, is that what I name the property? If so, what do I add in the actual property box?

I named the lib: token "lib:Handouts" and the image: token "image:testpic". Is that ok, or was I supposed to use a specific name?

Sorry, I just can't figure this out on my own. I even looked at the wiki link. I'm terrible at this kind of stuff.

the_meek
Cave Troll
Posts: 99
Joined: Fri Aug 01, 2008 9:18 am

Re: Using Handouts

Post by the_meek »

If you're running the SendLink macro directly from the token, you'll have to get rid of the broadcast function, because it can only be run from a Trusted_Macro. You can either call the macro from some other macro (like a campaign macro) like this:

Code: Select all

[MACRO("SendLink@lib:Handouts"): ""]
or get rid of the broadcast function, making the SendLink macro this:

Code: Select all

[H: abort(input("Image | " + json.toList(getLibProperty("ImageList")) + " | Select image | LIST | VALUE=STRING"))]
[R: macroLink("Click to view " + Image + "...", "ViewImage@" + getMacroLocation(), "none", Image)]
The property name for the library is ImageList, yes. You can leave it blank. The add/remove macros store the names of the images in this property when you run those macros. Your token names should be fine.

ViewImage is the macro that the link that SendLink sends to chat calls. It will give an error if you click on it because it needs the argument from SendLink (the "Image" variable).

Let me know how that works out for you.

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Using Handouts

Post by Oryan77 »

Ah, I read the Trusted Macro link you gave and figured out that I needed to uncheck the 'allow players to edit macros' box in order to get the broadcast code to work.
the_meek wrote:ViewImage is the macro that the link that SendLink sends to chat calls. It will give an error if you click on it because it needs the argument from SendLink (the "Image" variable).
So I got the SendLink macro to work, I can click the link in the chat and view the image. But I'm not sure what you mean about getting the ViewImage macro to work. It still gives the same error. Am I supposed to manually add the token name in the ViewImage macro or something?

Also, this isn't a big deal or anything, but I was wondering if there was code I could add so that when the image window appears, it will be sized to fit the image rather than requiring me to resize it? If so, is there also a way to get the image to load without the window frame surrounding it? Sort of like how the Show Handout feature does? I assume these might be the limitations that Wolph was talking about, but I wanted to ask.

the_meek
Cave Troll
Posts: 99
Joined: Fri Aug 01, 2008 9:18 am

Re: Using Handouts

Post by the_meek »

You don't actually do anything with the ViewImage macro. That gets called by the link in chat. It's what brings up the dialog with the image in it when you click the link in chat. It sounds like you have it working as intended.

As far as I know, there's no way to get the size of an image in MapTool, so there's really no way to automatically set the size of the dialog to that of the image. With more complicated macros, you could set the size of each image you want to pull up later, but you'd have to add the images one at a time, and I was just looking for a quick and dirty way of doing this.

I guess you could only use images that are the same aspect ratio and hard code the sizes of the dialog and image, but that's not a great solution. Plus, if you want something that's not the same aspect ratio, it's going to be distorted.

The dialog article says you can remove the frame of the dialog with "noframe=1". That would look like this:

Code: Select all

[dialog("ImageViewer", "noframe=1;"): {   <html><image src="[R: getImage(macro.args)]">   }]
The problem is that you don't seem to be able to resize the dialog without the frame, so you're back to having to deal with the size. The spot I added "noframe=1" is also where you'd set the width and height (separated by semicolons), in case you feel like messing with it.

As an aside, if you want to get rid of the close button at the bottom (can still use Escape or the X to close the dialog), use "input=1" in that same section, like this:

Code: Select all

[dialog("ImageViewer", "input=1;"): {   <html><image src="[R: getImage(macro.args)]">   }]

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Using Handouts

Post by Oryan77 »

Interesting. I'm going to try that out and play with it.

I thought the ViewImage macro was actually going to allow me to pull up the image by clicking on that macro. So if that is not what it does, is there another macro I can use that will load the image rather than me being required to click the link in the chat. So basically, a macro that thinks I clicked the link in the chat. :P

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

Re: Using Handouts

Post by Azhrei »

the_meek wrote:I guess you could only use images that are the same aspect ratio and hard code the sizes of the dialog and image, but that's not a great solution. Plus, if you want something that's not the same aspect ratio, it's going to be distorted.
Or specify only one of width or height and the other will default to be whatever is correct in order for the aspect ratio to be maintained. :)

the_meek
Cave Troll
Posts: 99
Joined: Fri Aug 01, 2008 9:18 am

Re: Using Handouts

Post by the_meek »

Smashing a couple of those macros together gets you:

Code: Select all

[H: abort(input("Image | " + json.toList(getLibProperty("ImageList")) + " | Select image | LIST | VALUE=STRING"))]
[dialog("ImageViewer"): {   <html><image src="[R: Image]">   }]
That should give you the input to choose the image, then the dialog with the image in it.

If you don't want the input at the beginning, and only want to show one image with the macro, you don't even need all of these macros. You'd just need one with the image name hardcoded:

Code: Select all

[dialog("ImageViewer"): {   <html><image src="[R: getImage('image:something')]">   }]
Where "image:something" is the name of the image token.

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Using Handouts

Post by Oryan77 »

When I used the first code (smashed code), it pops up the window with a red x. I'm not sure what I'm doing wrong. Any idea?

I did get the 2nd code to work, which is a nice option to have just in case. But I like your original setup of being able to add lots of images and select one of them to view. :D
Azhrei wrote:Or specify only one of width or height and the other will default to be whatever is correct in order for the aspect ratio to be maintained. :)
Good to know. I think that will allow me to do exactly what I've been trying to do once I get this setup working.

the_meek
Cave Troll
Posts: 99
Joined: Fri Aug 01, 2008 9:18 am

Re: Using Handouts

Post by the_meek »

My mistake. I took the getImage call out.

Code: Select all

[H: abort(input("Image | " + json.toList(getLibProperty("ImageList")) + " | Select image | LIST | VALUE=STRING"))]
[dialog("ImageViewer"): {   <html><image src="[R: getImage(Image)]">   }]
Azhrei, I actually never knew you could do that. I've always specified both, and assumed not specifying one would use the image's actual dimension. Neat.

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Using Handouts

Post by Oryan77 »

Ok, that worked!

The only thing now is that I still see a frame around the image. I can get the close button to go away, but not the entire frame.

Is this all the code that should be in the ViewImage macro? Or have I done something wrong?

Code: Select all

[dialog("ImageViewer", "noframe=1;"): {   <html><image src="[R: getImage(macro.args)]">   }]

[dialog("ImageViewer", "input=1;"): {   <html><image src="[R: getImage(macro.args)]">   }]
Also, say I wanted to set the image height to always be 800 pixels (and default the width as mentioned). How do I implement that into the code?

Post Reply

Return to “Macros”