Tutorial: Macro Dialogs and Frames

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

running:
[h: macro("GetWeapon@Lib:ENVIRONMENT"): 1] [macro.return]

gives me

Could not execute the command: line 1:35: unexpected char: ':'

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Tutorial: Macro Dialogs and Frames

Post by Craig »

n3phrit wrote:running:
[h: macro("GetWeapon@Lib:ENVIRONMENT"): 1] [macro.return]

gives me

Could not execute the command: line 1:35: unexpected char: ':'
yeah my bad, you have to use , between multiple options to [], so in this case

Code: Select all

[h, macro("GetWeapon@Lib:ENVIRONMENT"): 1] [macro.return]

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

after creating ViewWeapons macro on Token, I am getting this result:

Could not execute the command:    Error processing COUNT option: "" is not a number.       Statement options (if any): h,c(maxNum), code       Statement body: { [h: wnum = roll.count+1] [h: name = getStrProp(Weapons, strformat("Weapon%{wnum}Name"))] [if(name != ""): wnumList = listAppend(string(wnumList), string(wnum)) ] }

I am pretty sure, that there is more than one error in your tutorial, can you check it please? I found it difficult to went through. Since GetWeapon macro it started to be messed up.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Tutorial: Macro Dialogs and Frames

Post by Craig »

n3phrit wrote:after creating ViewWeapons macro on Token, I am getting this result:

Could not execute the command:    Error processing COUNT option: "" is not a number.       Statement options (if any): h,c(maxNum), code       Statement body: { [h: wnum = roll.count+1] [h: name = getStrProp(Weapons, strformat("Weapon%{wnum}Name"))] [if(name != ""): wnumList = listAppend(string(wnumList), string(wnum)) ] }

I am pretty sure, that there is more than one error in your tutorial, can you check it please? I found it difficult to went through. Since GetWeapon macro it started to be messed up.
What does the Weapons property hold you may have something funny in it?
The tutorial leaves out some error checking because I wanted to get to show how dialogs and stuff were done mostly.

you can also download a premade campaign with all the source for the macros, check the earlier posts for the link.

There are some weird things that may or may not happen on some of the dialogs depending on your java set up, I am looking at trying to fix that but its a patch to maptools not a change to the macros.

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

I went step by step and created some weapons with AddWeapon macro, so Weapon property holds now this:

Weapon1Name=LongSword ; Weapon1Damage=1d8 ; Weapon1Bonus=0 ; Weapon2Name=Hammer ; Weapon2Damage=1d8 ; Weapon2Bonus=0 ;

edit: I wanted to write it all by myself, so I can learn it better, in fact after this I started to understand a lot about macros (I used MT 1.3.39 last time) and am trying to catch up with all those changes...

edit2: definitely need reference manual for macros: at least all functions with syntax, i am really confused about using [h: [h, [c [r and so on...

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Tutorial: Macro Dialogs and Frames

Post by Craig »

n3phrit wrote:I went step by step and created some weapons with AddWeapon macro, so Weapon property holds now this:

Weapon1Name=LongSword ; Weapon1Damage=1d8 ; Weapon1Bonus=0 ; Weapon2Name=Hammer ; Weapon2Damage=1d8 ; Weapon2Bonus=0 ;

edit: I wanted to write it all by myself, so I can learn it better, in fact after this I started to understand a lot about macros (I used MT 1.3.39 last time) and am trying to catch up with all those changes...

edit2: definitely need reference manual for macros: at least all functions with syntax, i am really confused about using [h: [h, [c [r and so on...
Ok I found the problem.
The example calling the AddWeapon is just to test it to make sure the weapon was getting added. But for everything to work correctly together you can not add a weapon with out using the the NextWeaponNumber macro to generate a number to pass to it (this is what the dialog does, calls NextWeaponNumber, then uses that number in the call to AddWeapon.

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

Re: Tutorial: Macro Dialogs and Frames

Post by Rumble »

Craig, n3phrit: the error seems to be that the part of the macro that sets MaxNum equal to the value of getStrProp(Weapons,"NumWeapons") results in MaxNum being a string - and therefore, COUNT() bails out because it can't work with strings.

If you do something like maxNum=countStrProp(Weapons)/3 (assuming that each weapon has 3 properties) it works fine.

I've tried using number() to "cast" the value of maxNum as a number rather than a string, but I've never made number() work in any application I've tried - I'm not sure it actually works yet.


Edit: or, perhaps, the other thing you just said.

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

...can not add a weapon with out using the the NextWeaponNumber macro to generate a number to pass to it ...
Yeah, I know, I passed variable to the macro the same way as the dialog would do. that is certainly not an issue. I think that dragon is right about his observation, but unfortunatelly, i am not that familiar with macro syntax and different functions to judge.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Tutorial: Macro Dialogs and Frames

Post by Craig »

n3phrit wrote:
...can not add a weapon with out using the the NextWeaponNumber macro to generate a number to pass to it ...
Yeah, I know, I passed variable to the macro the same way as the dialog would do. that is certainly not an issue. I think that dragon is right about his observation, but unfortunatelly, i am not that familiar with macro syntax and different functions to judge.
Strange if you call the NextWeaponNumber macro you shold have a NumWeapons= in your Weapons property.

The line

Code: Select all

 
[h,if(isPropertyEmpty("Weapons")): Weapons = "NumWeapons=0;"]
Ensures that if the Weapons property is empty it will be set to NumWeapons=0.

The reason I dont have something like

Code: Select all

maxNum=countStrProp(Weapons)/3
is because weapons can be deleted, so I may have weapons 1, 3, 6 (2, 4, and 5 were deleted). So the above would give me 3 where my highest number is really 6.
Last edited by Craig on Tue Dec 16, 2008 2:32 pm, edited 1 time in total.

User avatar
PyroMancer2k
Dragon
Posts: 925
Joined: Thu Sep 11, 2008 2:04 pm

Re: Tutorial: Macro Dialogs and Frames

Post by PyroMancer2k »

Craig wrote: The reason I dont have something like
[count]
maxNum=countStrProp(Weapons)/3
[/count]
is because weapons can be deleted, so I may have weapons 1, 3, 6 (2, 4, and 5 were deleted). So the above would give me 3 where my highest number is really 6.
I figure you were just in a hurry to get things up to show off the Dialog/Frame setup so I never really was too concerned with how you had done your equipment setup since I had my own already. :)

For those that interesting in modifying your setup though I had a similar concern with weapon numbers when I made my inventory macros. That is what happens when you delete a weapon you don't want it just shuffling through empty #s seeing if the weapon is still there. So to fix this where you don't have weapon 1, 3, 6 and the others missing cause they were delete. As well as having the only way the macro can figure out which ones are still there is do the loop 6 times is to simply renumber them all.

That is say you have 1, 2, 3, 4 and person wants to delete weapon 2. So you set a loop to do the following. In very basic terminology.

Code: Select all

for(x=2 ; x < 4 ; i++)
x=x+1
delete 4
So basically it copies each weapon into the spot before it then deletes the one on the end. Of course the exact code would depend on your setup. But this is how I handle it since I hold all my equipment in a strProp too. That way it doesn't go threw a bunch of empty numbers looking for which weapons are still around.

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: Tutorial: Macro Dialogs and Frames

Post by jfrazierjr »

Holy cow Batman! I just realized that this would be an EXCELLENT way to add statblocks for creatures in a formatted way into Maptool. Especially using the unpinned frame feature, you could keep a copy up for each monster from the beginning of the combat until the end and only look at it when you hover over the "tab" of the frame. All that's needed is to create the macro with the creatures statblock HTMLized and poof.... instant reference.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
PyroMancer2k
Dragon
Posts: 925
Joined: Thu Sep 11, 2008 2:04 pm

Re: Tutorial: Macro Dialogs and Frames

Post by PyroMancer2k »

jfrazierjr wrote:Holy cow Batman! I just realized that this would be an EXCELLENT way to add statblocks for creatures in a formatted way into Maptool. Especially using the unpinned frame feature, you could keep a copy up for each monster from the beginning of the combat until the end and only look at it when you hover over the "tab" of the frame. All that's needed is to create the macro with the creatures statblock HTMLized and poof.... instant reference.
When dialog boxes first came out I considered making an HTML stat card as a sort of charsheet sheet for the monsters. I just had a small problem. I don't know HTML. Though I'm learning :).

Then with the showing off of the HTML tooltips I thought it would be cool to do the tooltip stat card on the tokens in the tracking display.

Image

Now it would be really cool to see those stat cards when you mouse over their pics.

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: Tutorial: Macro Dialogs and Frames

Post by jfrazierjr »

PyroMancer2k wrote:
jfrazierjr wrote:Holy cow Batman! I just realized that this would be an EXCELLENT way to add statblocks for creatures in a formatted way into Maptool. Especially using the unpinned frame feature, you could keep a copy up for each monster from the beginning of the combat until the end and only look at it when you hover over the "tab" of the frame. All that's needed is to create the macro with the creatures statblock HTMLized and poof.... instant reference.
When dialog boxes first came out I considered making an HTML stat card as a sort of charsheet sheet for the monsters. I just had a small problem. I don't know HTML. Though I'm learning :).

Then with the showing off of the HTML tooltips I thought it would be cool to do the tooltip stat card on the tokens in the tracking display.

Image

Now it would be really cool to see those stat cards when you mouse over their pics.

I just found (from a post on the Cartographers Guild) a link to a tool that will do a lot of the work for you. http://www.asmor.com/programs/monstermaker/index.php. Now... there are some cavaets here. 1) the css is separate from the html that is generated, so you would have to modify the html to point to a web site hosted link to the css file OR embed the css into a libtoken with the new command for css (not sure what that is at the moment) 2) the icons won't work unless the users have the font installed. 3) not sure of the creators licensing terms.....

However, this should get you a start and if you decided to try to build up the html in a css stylized way (you can always embedd the css commands inline as part of the html markup using the style="" attribute) and have questions, I will be more than glad to help out and you can use these are references if you download the tool. A workaround to the font issue is to create high resolution png images of the appropriate "icons", host them on a website somewhere, and use the normal html img tags to make them show in the html as static images instead of a "font" character.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

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

Re: Tutorial: Macro Dialogs and Frames

Post by Azhrei »

The monster maker is interesting. But can the user provide an HTML template for the program to use? If so, the user could provide an XML template instead.

And that XML template could be the same format as the content.xml that MapTool uses for tokens. Can you tell where I'm going with this? ;)

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: Tutorial: Macro Dialogs and Frames

Post by jfrazierjr »

Azhrei wrote:The monster maker is interesting. But can the user provide an HTML template for the program to use? If so, the user could provide an XML template instead.

And that XML template could be the same format as the content.xml that MapTool uses for tokens. Can you tell where I'm going with this? ;)
Well.. the author seems to be pretty responsive as he added an export mode for wiki markup, so it's worth a shot to contact him. Also, it might not hurt that it seems one of our regulars, Daelkyr, may have made the fonts used to show the "attack type" icons for each power. For that matter, it might not hurt asking him if he would also make a way to build the export html file with a link to the css instead of expecting it in the same directory and likewise for the fonts to allow image use via img tags.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

Post Reply

Return to “Documentation Requests/Discussion”