TokenMaker

We are always looking for new tools to create to help facilitate the table top gaming experience. Let us know if you have an idea for a new gaming tool you'd like to see. (Note: this is NOT for feature requests on existing tools!)

Moderators: dorpond, trevor, Azhrei

Post Reply
User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: TokenMaker

Post by Rumble »

In that case, it should be pretty straightforward to add in a couple macrolink calls. Also, as I said, depending on where those macrolinks go, you may be able to offload the logic for setting the "expended" state on your Lib:Blakey token, and thus have minimal changes to the Token Maker source code.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

I'm not sure if this is going to work. But it might be a problem with my understanding of "current" tokens in MT.

I just made a tweak to TM which means when you click on the link on your character sheet it now knows the power name, attack bonus and defense. The macro it calls goes off to all selected "targets" and makes an attack against their defense value. It calcs hits and misses for all. All works fine and in the chat log it prints out the name of the power the PC is using. All good. I can probably expand this so that the type of power (at-will, encounter etc) is also passed out and then have the name of the power printed in the right colours and all. Fine.

However, inside my MakePlayerAttackRoll@Lib:Blakey macro, I can't get access to the token who owns the frame that this macro link lives on. I was going to update a status on the PC to say they have used a power - as a simple short term test, but I can't get it to work.

Doing something as simple as

Code: Select all

[ME = getName()]
I always get the error:

Code: Select all

Error executing getName: there is no impersonated token
Any clues how I can access the PC token that created the frame, inside the macro that got called off the frame???
The guy in the green hat.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: TokenMaker

Post by Rumble »

That is an issue in MapTool - when a frame is created, unless you take steps to pass variables along, the current token context is lost. However there's a way around it, like so:

1. When the frame is first launched, pass to it the token name as a string (not an array!), so something like:

Code: Select all

[macro("ShowPlayerFrame@WHEREVER"):token.name]
and capture that in the frame as a variable. Then, as an additional argument in the JSON array you pass whenever a link is clicked, send that token name too.

2. In the MakePlayerAttackRoll, you pull out the token name, and you can then use that as an argument when setting the PowerTracker value, like so:

Code: Select all

<!--In Make Player Attack Roll macro, capture the token name from the arguments-->
[h:powerClicked = json.get(macro.args, 0)]
[h:contextToken = json.get(macro.args, 1)]

[h:tempPowerTrack = getProperty("PowerTracker", contextToken)]
[h:tempPowerTrack = json.set(tempPowerTrack, powerClicked, 1)]

[h:setProperty("PowerTracker", tempPowerTrack, contextToken)]

You basically just need to pass that token argument around everywhere, unfortunately. Only way I've found that it works.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Bugger. I just discovered all the changes I made this lunchtime - i.e. creating MakePlayerAttackRoll macro I didn't save. D'oh! Still should be easy enough this evening to replicate. When I do I'll post the macro content as I'm not really understanding you too well.

Basically my macro-fu is very weak so you have to take me through it step by step! :D

Cheers for the help, as ever. Feels like I'm getting there slowly!
The guy in the green hat.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Rumble wrote:That is an issue in MapTool - when a frame is created, unless you take steps to pass variables along, the current token context is lost.
Okay, that makes sense.
However there's a way around it, like so:

1. When the frame is first launched, pass to it the token name as a string (not an array!), so something like:

Code: Select all

[macro("ShowPlayerFrame@WHEREVER"):token.name]
and capture that in the frame as a variable.
Okay, my frame is launched by a token property on mouseover. So I need to change the bit where it calls the macro "DisplayStats" and add the parameters "token.name". I'm assuming that is literally "token.name", right?
Then, as an additional argument in the JSON array you pass whenever a link is clicked, send that token name too.
You're losing me here.

In the DisplayStats macro I can grab out the token.name as a macro argument, no problem. So I have a variable inside the DisplayStats macro called tokenName. Are you suggesting in the links (which are hard coded inside TokenMaker remember) I add another argument to the MakePlayerAttackRoll, something like

Code: Select all

?name=tokenName
?? I think this is what you mean.
2. In the MakePlayerAttackRoll, you pull out the token name, and you can then use that as an argument when setting the PowerTracker value, like so:

Code: Select all

<!--In Make Player Attack Roll macro, capture the token name from the arguments-->
[h:powerClicked = json.get(macro.args, 0)]
[h:contextToken = json.get(macro.args, 1)]

[h:tempPowerTrack = getProperty("PowerTracker", contextToken)]
[h:tempPowerTrack = json.set(tempPowerTrack, powerClicked, 1)]

[h:setProperty("PowerTracker", tempPowerTrack, contextToken)]
I assume from this 'contextToken' is the name of the token? If I'm following you...
You basically just need to pass that token argument around everywhere, unfortunately. Only way I've found that it works.
That's not a problem - as long as I can figure out what is going on!!

There are quite a few places I'd like to stick extra links on the character sheet and being able to know what PC we're talking about that owns it will be a huge help. Then I can add a link on "Initiative" to roll init and add a link on "HP" to apply damage, and add a link on "Action Points" to use an AP and so on. Very handy. But at present I always end up with my FW getting confused about no impersonated tokens when I try that approach.

Cheers!!!
The guy in the green hat.

User avatar
Hawke
Great Wyrm
Posts: 2261
Joined: Sat Apr 21, 2007 12:12 am
Location: Albuquerque, NM

Re: TokenMaker

Post by Hawke »

Just curious on a quick update... are you still working towards something compatible with Veggie's framework or have you really shifted gears toward your own framework (with perhaps a Veggie foundation)?

Looks like you're cruising along, its been interesting to follow!

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Okay. Stuck. This is (a massively simplified version of) my DisplayStats macro:

Code: Select all

[H: tokenName="BOB"]
[frame("PlayerStatCard"): 
{
<h1>Braken Montanari</h1>
<p><b>Melee Basic Attack</b> (Standard action, At-Will)</p>
<a href=macro://MakePlayerAttackRoll@Lib:Blakey/all/TOKEN?AttackBonus=18&Defence=AC&Power=Melee+Basic+Attack&Name=tokenName>+18 vs AC</a>
}]
Assume that tokenName can be got from arguments passed in when called but for now I'm hard coding it to BOB.
The HTML fragment in the middle of the frame is pregenerated by TokenMaker. At the moment it's calling MakePlayerAttackRoll with 4 parameters, the last of which wants to be the tokenName variable. Trouble is as I'm inside a square bracket bit of macro code (i.e. the frame), I don't know how to actually get it to use the variable tokenName. Obviously what I have here hard codes the value "tokenName" into the argument Name when passed in. I want to do something like this:

Code: Select all

<a href=macro://MakePlayerAttackRoll@Lib:Blakey/all/TOKEN?AttackBonus=18&Defence=AC&Power=Melee+Basic+Attack&Name=} + tokenName + {>+18 vs AC</a>
but clearly that's invalid macro code.


How do I get the value of the variable into this HTML, given that the HTML is prefabricated outside MapTool?

Cheers
Blakey
The guy in the green hat.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Hawke wrote:Just curious on a quick update... are you still working towards something compatible with Veggie's framework or have you really shifted gears toward your own framework (with perhaps a Veggie foundation)?

Looks like you're cruising along, its been interesting to follow!
Hey Hawke,

One thing at a time I've decided. :D

Basically, I've got it able to create Veggie monsters, with the proviso that these monsters don't have power macros on them at all. Instead of that they have an HTML formatted stat sheet which lets you make attacks. I'm happy with that approach for monsters - it's what I already use in my game appart from the fact that I currently use James' parser to build the HTML and it's not quite the same look as my new version. I'm about to use this new version of my version of Veggie's FW for a session next week so that will be interesting.

I'm now thinking that what works for monsters could work for PCs and am trying to build a PC character sheet with the same style of links for all power attacks. That's what Rumble is helping me with. If I can get that to work to my satisfaction I've actually no need for Veggie's framework at all. All the complicated macros on Lib:Veggie that are used to build and fire off all the complex PC and monster macros will become unnecessary. I'll still use some of his excellent stuff - things like his macros for healing, for taking damage, etc. Although they may all need mods here and there. I think the potential is to generate a really clean and simple framework with the minimum amount of macros underlying it. It will require TokenMaker to generate tokens for it though.

As far as getting TM to make tokens for other frameworks, this could potentially be REALLY difficult. If you look at the sort of things you have to set up for a PC for Veggie's FW for example, including all the defense values, there are tonnes of things to set up. I'm not even sure if they are all in the save files! I've not looked at what needs setting up for monsters but I know that creating power macros for PCs or monsters is a complex business and I am not sure how easy it will be for TokenMaker to do all that work.

Anyway, once I'm up and running completely on TM with my FW I'll have a look at what it might take to support other FWs. At that stage I'll definitely make TM available for people to use with my FW and also release the code in case a Java programmer who uses Veggie's FW wants to extend TokenMaker to support Veggie. Likewise Rumble, DeviantNull, etc.

Cheers!
Blakey
The guy in the green hat.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Hmm, found a potentially serious flaw in my plans for PCs being able to attack monsters by clicking links: This means the players need to be able to SELECT the monster tokens they want to attack. However in usual situations you don't let PC select monsters - otherwise they get access to all their stats and info, etc, etc, etc.

So how can I enable a player to 'select' a bunch of targets when he wants to use a power on them?
The guy in the green hat.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: TokenMaker

Post by Rumble »

Okay. You have the general idea just fine - and what you're saying is precisely right. However, I did not really process completely the fact that you're manually assembling the macro link in that fashion. I'd assumed that you would embed literal macro code into the HTML variable, but that might be impossible (I don't know). In other words, I assumed instead of:

Code: Select all

[H: tokenName="BOB"]
[frame("PlayerStatCard"): 
{
<h1>Braken Montanari</h1>
<p><b>Melee Basic Attack</b> (Standard action, At-Will)</p>
<a href=macro://MakePlayerAttackRoll@Lib:Blakey/all/TOKEN?AttackBonus=18&Defence=AC&Power=Melee+Basic+Attack&Name=tokenName>+18 vs AC</a>
}]
you could do something like this (embedding literal macro code in there rather than the pregenerated macro HREF):

Code: Select all

[H: tokenName="BOB"]
[frame("PlayerStatCard"): 
{
<h1>Braken Montanari</h1>
<p><b>Melee Basic Attack</b> (Standard action, At-Will)</p>
[r:macroLink("+18 vs AC", "MakePlayerAttackRoll@Lib:Blakey", "all", json.append("[]", 18, "AC", "Melee Basic Attack", tokenName), tokenName)]
}]
The macrolink call there is what generates links in the format you're manually assembling in TokenMaker. I don't know if that's possible in Java. Never tried; you'll probably have to do some escaping.


As for the selection thing - it is possible in the latest version of maptool to select tokens you don't own, and players will not see any information they shouldn't see.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Rumble wrote:In other words, I assumed instead of:

Code: Select all

[H: tokenName="BOB"]
[frame("PlayerStatCard"): 
{
<h1>Braken Montanari</h1>
<p><b>Melee Basic Attack</b> (Standard action, At-Will)</p>
<a href=macro://MakePlayerAttackRoll@Lib:Blakey/all/TOKEN?AttackBonus=18&Defence=AC&Power=Melee+Basic+Attack&Name=tokenName>+18 vs AC</a>
}]
you could do something like this (embedding literal macro code in there rather than the pregenerated macro HREF):

Code: Select all

[H: tokenName="BOB"]
[frame("PlayerStatCard"): 
{
<h1>Braken Montanari</h1>
<p><b>Melee Basic Attack</b> (Standard action, At-Will)</p>
[r:macroLink("+18 vs AC", "MakePlayerAttackRoll@Lib:Blakey", "all", json.append("[]", 18, "AC", "Melee Basic Attack", tokenName), tokenName)]
}]
Hmmm, I'm going to test this out but I don't think that will work. The reason I think it won't is that you have put an open square brackets (for the macrolink call) inside another open square brackets (the frame call). I didn't think that was possible. If it is then I could use something like:

Code: Select all

[H: tokenName="BOB"]

[frame("PlayerStatCard"):  {

    <h1>Braken Montanari</h1>
    <p><b>Melee Basic Attack</b> (Standard action, At-Will)</p>
    <a href=macro://MakePlayerAttackRoll@Lib:Blakey/all/TOKEN?AttackBonus=18&Defence=AC&Power=Melee+Basic+Attack&Name=
   [tokenName]
    >+18 vs AC</a>

}]
And I don't think the above is valid macro language - although I'm off to test it now...
As for the selection thing - it is possible in the latest version of maptool to select tokens you don't own, and players will not see any information they shouldn't see.
Excellent. Just downloaded and tested version 70 and it certainly does allow me to select monsters for targetting but not get any info they shouldn't have. Perfect!
The guy in the green hat.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Blakey wrote: Hmmm, I'm going to test this out but I don't think that will work. The reason I think it won't is that you have put an open square brackets (for the macrolink call) inside another open square brackets (the frame call). I didn't think that was possible. If it is then I could use something like:

Code: Select all

[H: tokenName="BOB"]

[frame("PlayerStatCard"):  {

    <h1>Braken Montanari</h1>
    <p><b>Melee Basic Attack</b> (Standard action, At-Will)</p>
    <a href=macro://MakePlayerAttackRoll@Lib:Blakey/all/TOKEN?AttackBonus=18&Defence=AC&Power=Melee+Basic+Attack&Name=
   [tokenName]
    >+18 vs AC</a>

}]
And I don't think the above is valid macro language - although I'm off to test it now...
Well gobble my hat, it works. That is excellent, excellent news. I can now tie all the macros I stick on the frames to the token who "owns" the frame which really opens up doors to the new framework.

I'm going to move on by adding extra macros to the monster frame and finishing off monsters before I get back to working on the player character sheet again, but I think with this bit of knowledge I can possibly really progress with an interactive character sheet. Wahay!

Thanks heaps for your help Rumble!!

Blakey
The guy in the green hat.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Next issue I'm having (perhaps I should stick these in the Macros forum?) is this:

I have a link on my frame which calls a macro and passes in the name of the monster who owns the frame as a parameter. The idea of this macro is that it rolls init for the monster. It looks like this (again cut down):

Code: Select all

[R: MyName= getStrProp(macro.args, "Name")]
[H: addToInitiative()]
But that doesn't work. The name is parsed out fine but there is no way to tell "addToInitiative()" that I want to add a specifically named token to Initiative.

I've tried using the TOKEN() roll option to impersonate 'MyName' but so far that doesn't work either.

What do I need to do to enable running macro functions inside a macro against the token called 'MyName'? It really seems TOKEN is the way to go here but it doesn't seem to work at all.

My macro is trusted (I think) - at least it's not editable by the players.

Help!
Blakey
The guy in the green hat.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: TokenMaker

Post by Rumble »

Blakey wrote:Next issue I'm having (perhaps I should stick these in the Macros forum?) is this:

I have a link on my frame which calls a macro and passes in the name of the monster who owns the frame as a parameter. The idea of this macro is that it rolls init for the monster. It looks like this (again cut down):

Code: Select all

[R: MyName= getStrProp(macro.args, "Name")]
[H: addToInitiative()]
But that doesn't work. The name is parsed out fine but there is no way to tell "addToInitiative()" that I want to add a specifically named token to Initiative.

I've tried using the TOKEN() roll option to impersonate 'MyName' but so far that doesn't work either.

What do I need to do to enable running macro functions inside a macro against the token called 'MyName'? It really seems TOKEN is the way to go here but it doesn't seem to work at all.

My macro is trusted (I think) - at least it's not editable by the players.

Help!
Blakey

You're using:

Code: Select all

[h,token(MyName): addToInitiative()]
(no quotes around MyName)? I'm surprised that doesn't work.

User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

Re: TokenMaker

Post by Blakey »

Yup. Macro looks like this:

Code: Select all

[MyName= getStrProp(macro.args, "Name")]
[h,token(MyName): addToInitiative()]
Result when clicking it is:

"Error executing initiative function, there is no impersonated token."

:( :( :(
The guy in the green hat.

Post Reply

Return to “Ideas for New Applications”