I'm currently using MapTool version 1.3.b87.
After doing some stuff with json objects (and getting frustrated) I decided to try fulfilling my coding needs with a simpler approach (simpler than json objects anyway) and followed one of the tutorials on the MapTool Wiki. I'm working off of the Introduction to Dialogs and Frames Tutorial. I've noticed available frameworks, but I guess I'm just a stubborn one and insist on building my own stuff, but wanted to use the tutorial as a foundation to then build on.
So I followed this tutorial almost perfectly to the letter (only changing things like the name of the Library Token I use in my campaign, and left out the traffic light bar stuff). However whenever I try to go to use the new "weapons" page of the tutorials character sheets I get an error. So I hunted through the macros, starting with the tutorials EditWeaponDialog macro. I could run that macro, and get the pop-up form correctly, I'd enter the some data into it, use the save button, and then the macro would prompt me for input for "Weapons". I could put something in the input and I would simply get the error that "setStrProp()" requires exactly 1 parameters. For reference "Weapons" is already added to the campaign properties for tokens.
I went over the EditWeaponDialog macro and found no use of the setStrProp function, so I tracked back from EditWeaponDialog macro to the macro it called, which is the AddWeapon Macro from the tutorial which does use the setStrProp function. However I can't figure out what is wrong with the macro. D:
First here is the Add Weapon Macro from my campaign:
Code: Select all
[h: num = getStrProp(macro.args, "Number")]
[h: damage = getStrProp(macro.args, "Damage")]
[h: name = getStrProp(macro.args, "Name")]
[h: bonus = getStrProp(macro.args, "Bonus")]
[h: Weapons = setStrProp(Weapons, strformat("Weapon%{num}Name"), name)]
[h: Weapons = setStrProp(Weapons, strformat("Weapon%{num}Damage"), damage)]
[h: Weapons = setStrProp(Weapons, strformat("Weapon%{num}Bonus"), bonus)]
And the EditWeaponDialog Macro from my campaign:
Code: Select all
[dialog("weaponInput"): {
[h: weaponNum = getStrProp(macro.args, "Number")]
[h: name = getStrProp(macro.args, "Name")]
[h: bonus = getStrProp(macro.args, "Bonus")]
[h: damage = getStrProp(macro.args, "Damage")]
<!-- If we do not have a weapon number grab the next one -->
[h, if(weaponNum == ""), code: {
[h,macro("NextWeaponNumber@this"): ""]
[h: weaponNum = macro.return]
}]
<html>
<head>
<title>Edit Weapon Dialog</title>
<meta name="input" content="true">
<link rel="stylesheet" type="text/css" href="EditWeapon_css@[r: getMacroLocation()]">
</head>
<body>
<form name="weaponInput" action="[r:macroLinkText('AddWeapon@Lib:CharSheet')]">
<table>
<tr>
<td>
<table>
<tr>
<th>
<label for="Name">Weapon Name</label>
</th>
<td>
<input type="text" name="Name" value="[r: name]">
</input> <br>
</td>
</tr>
<tr>
<th>
<label for="Damage">Weapon Damage</label>
</th>
<td>
<input type="text" name="Damage" value="[r: damage]">
</input> <br>
</td>
</tr>
<tr>
<th>
<label for="Bonus">Weapon Bonus</label>
</th>
<td>
<input type="text" name="Bonus" value="[r: bonus]">
</input>
</td>
</tr>
</table>
</td>
<td>
<img src='[r: getTokenImage(100)]'></img>
</td>
</tr>
</table>
<!-- hidden input with the weapon number -->
<input type="hidden" name="Number" value="[r: weaponNum]">
</input>
<input id="saveButton" type="submit" name="Save" value="Save">
</input>
</form>
</body>
</html>
}]
I've also noticed that the weapon number is increased in the "Weapons" entry on a token, but the entered data that was put into the form doesn't get added to the "Weapons" entry on the token properties.
I'm unsure what is not working here exactly. I realized it could be a number of things including such as:
1. Is there a bug in this version of MapTool or some change to the way these functions are used since the tutorial was written?
2. Is it that the token being refereed to is lost in the changes between one Macro to the next?
3. Is it that the Macro text link function isn't doing something right in terms of passing the data along to the add weapon?
4. Maybe something in the EditWeaponDialog html table stuff I'm missing?
4. Something else I've missed? *facedesk*
Thank you for all your help.