I've been able to get it to display the properties correctly, but I can't get it to reliably update any of them. At first it was just simple macro errors from typos (which got fixed), incorrect roll options (which might have been fixed, as it no longer gives those errors), and then from me not remembering that html checked inputs don't pass on unchecked variables. I've since changed those to radio options, because following the guide on using json.contains was not working for some reason (mostly likely user error). I was almost at the point of scrapping the whole macro set and making one from the ground up, but then I ran into this error:
Error
at net.rptools.maptool.client.ui.htmlframe.HTMLPaneFormView.submitData(HTMLPaneFormView.java:120)
at javax.swing.text.html.FormView.actionPerformed(FormView.java:356)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6288)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4651)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4481)
at com.jidesoft.docking.b.a(Unknown Source)
at com.jidesoft.docking.DefaultDockingManager.handleEvent(Unknown Source)
at com.jidesoft.docking.DefaultDockingManager$46.eventDispatched(Unknown Source)
at java.awt.Toolkit$SelectiveAWTEventListener.eventDispatched(Toolkit.java:2366)
at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2258)
at java.awt.Toolkit.notifyAWTEventListeners(Toolkit.java:2216)
at java.awt.Component.dispatchEventImpl(Component.java:4549)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1850)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:901)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:513)
at java.awt.Component.dispatchEventImpl(Component.java:4523)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4481)
at sun.awt.X11.XWindow$1.run(XWindow.java:380)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:38)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Campaign Properties
Code: Select all
«Displayed»
*@Health:{currentWounds} / {maxWounds}
*@Move:{agility + 0}
*@Armour:{armourType} ({armourResist})
*@Weapon_1:{weapon1}{ammo1}
*@Weapon_2:{weapon2}{ammo2}
«Statistics»
strength:5
vitality:5
dexterity:5
agility:5
intellect:5
resolve:5
health.woundMultiplier:4
maxWounds:{(vitality * health.woundMultiplier) + 0}
currentWounds:{maxWounds}
fatigue:0
«Equipment»
armourType:clothes
armourResist:0
weapon1
weapon2
ammo1
ammo1current
ammo2
ammo2current
«Skills»
skills.MeleeFighting:base=0 ; edged=0 ; blunt=0 ; polearms=0 ; flexible=0 ; thrown=0 ;
skills.RangedFighting:base=0 ; archery=0 ; projectiles=0 ; rayguns=0 ; missiles=0 ; artillery=0 ;
skills.basic:Acrobatics=0 ; Athletics=0 ; Awareness=0 ; Disguise=0 ; Dodge=0 ; Drive=0 ; Endurance=0 ; FirstAid=0 ; Legerdemain=0 ; Navigation=0 ; Persuasion=0 ; Pilot=0 ; Search=0 ; Security=0 ; Stealth=0 ; Survival=0 ; Teaching=0 ; Wrangling=0 ;
skills.trained:Accounting=0 ; Astrogeology=0 ; Biology=0 ; Chemistry=0 ; Cryptography=0 ; Culture=0 ; Demolitions=0 ; Electronics=0 ; History=0 ; Law=0 ; Mechanics=0 ; Medicine=0 ; Physics=0 ; PopularCulture=0 ; Programming=0 ; Psychology=0 ; Surgery=0 ; Tactics=0 ;
openCharacterSheet
Code: Select all
[h: link = macroLinkText("openCharacterSheet@Lib:token", "none")]
[frame("CharacterSheet"): {
<html>
<head>
<link rel="onChangeSelection" type="macro" href="[r:link]">
<link rel="stylesheet" type="text/css" href="css@Lib:token"></link>
</head>
<body>
[r, macro("characterSheet@Lib:token"): getSelected()]
</body>
</html>
}]
css
Code: Select all
.odd { background-color: #FFFFFF }
.even { background-color: #EEEEAA }
th { background-color: #113311; color: #FFFFFF }
characterSheet
Code: Select all
editCharacterSheet
Code: Select all
[h: arguments = json.toStrProp(macro.args)]
[h: varsFromStrProp(arguments)]
[h: id = json.get(macro.args, "id")]
<!-- set primary attributes -->
[h: attributes = "Strength, Vitality, Dexterity, Agility, Intellect, Resolve"]
[h,foreach(attrib, attributes),code: {
[r: setProperty(attrib, attrib, id)]
}]
<!-- set skills -->
[h: base = json.get(macro.args, "MeleeFighting")]
[h,if(! json.contains(arguments, "edged")): edged = 0]
[h,if(! json.contains(arguments, "blunt")): blunt = 0]
[h,if(! json.contains(arguments, "polearms")): polearms = 0]
[h,if(! json.contains(arguments, "flexible")): flexible = 0]
[h,if(! json.contains(arguments, "thrown")): thrown = 0]
[h: skillset = strPropFromVars("base, edged, blunt, polearms, flexible, thrown", "unsuffixed")]
[h: setProperty("skills.meleeFighting", skillset, id)]
[h: base = json.get(macro.args, "RangedFighting")]
[h,if(! json.contains(arguments, "archery")): archery = 0]
[h,if(! json.contains(arguments, "projectiles")): projectiles = 0]
[h,if(! json.contains(arguments, "rayguns")): rayguns = 0]
[h,if(! json.contains(arguments, "missiles")): missiles = 0]
[h,if(! json.contains(arguments, "artillery")): artillery = 0]
[h: skillset = strPropFromVars("base, archery, projectiles, rayguns, missiles, artillery", "unsuffixed")]
[h: setProperty("skills.rangedFighting", skillset, id)]
[h: skillset = strPropFromVars("Acrobatics, Athletics, Awareness, Disguise, Dodge, Drive, Endurance, FirstAid, Legerdemain, Navigation, Persuasion, Pilot, Search, Security, Stealth, Survival, Teaching, Wrangling", "unsuffixed")]
[h: setProperty("skills.basic", skillset, id)]
[h: skillset = strPropFromVars("Accounting, Astrogeology, Biology, Chemistry, Cryptography, Culture, Demolitions, Electronics, History, Law, Mechanics, Medicine, Physics, PopularCulture, Programming, Psychology, Surgery, Tactics", "unsuffixed")]
[h: setProperty("skills.trained", skillset, id)]
Changes saved to [r: getName(id)].
[h, macro("openCharacterSheet@Lib:token"): id]
I'm really at my wits end over this, and am feeling like I won't be able to progress further in coding macros. I'd love to be able to do more with macros (and perhaps eventually full on programming), but running into problems that make me feel like a two-bit n00b script-kiddy is getting disheartening. (This is also not the only macro/macro-set giving me issues, though it is having more problems than others which I've been able to kludge into some form of functionality.)
...
Alright, I have no clue why it doesn't like me posting in the code for the characterSheet macro itself, and I've tried numerous times to get it in the post. As such I've attached the campaign file that has all of that in it.