Passing property name through Macro() and nested jsons
Posted: Mon Mar 26, 2012 5:00 pm
Being that I can't seem to stay with simple macros, and not wanting to have several macros for some weapons, I decided to try making a complex attack macro. I know the theory of what I want to do, but I can't seem to get it executed. I've been able to get several steps done, but there are two bits I can't seem to get functioning no matter how much I bash at my keyboard. I apologise for this being long, but it's proving quite tricky for me.
Issue #1: Passing a variable holding a property name through Macro() for later use:
With this I'm needing to hold the name of a property, to both gather information from and update with new values throughout the entire macro-chain. The reason I'm going this route is so that I can have token properties with weapon variables for what the characters have equipped, with a macro able to call on each weapon property but utilise the same attack macro-chain on a library token.
I'm obviously doing something wrong as the property name and values don't seem to get properly passed or accessed. I've tried having the property name in quotes as the value of the property, and I've tried passing only part of the property name to add to the other part of the property name to call on it, and neither have worked. I have been able to assign the property values and pass those along, but that leaves me without having the property name to call for updating the property's values.
Issue #2: Accessing nested json objects:
Normally I try to avoid nesting json objects or string property lists (including with each other), but it seems to be the only way to get what I'm wanting. As a quick run down, I'm wanting a list of variables holding weapon information (name, size of clip, rounds remaining, etc). One of these variables should then hold a list of firing mode/option variables, each of which holds further variables specific to that option (damage amount, damage type, rounds expended, etc). This is so that I can have variable power levels, rate of fire settings, kill/stun settings, and other such, but only display info relevant to each weapon.
Here are the properties and macros I've come closest to getting success with.
I'm pretty lost on all of this and so welcome all help in getting this working. I'm also willing to take a different approach if needed, so long as the outcome arrives at what I'm needing. I will also state now that I am thinking of changing to Dialog() instead of Input(), to avoid potential property resets in case something happens while it's up and so that characters can check again which target in the list they want (for when they run up against multiple similar opponents, like a squad of stormtroopers or hive gangers). I don't think that will change either of these options, but I suppose it's something to keep in mind should snippets of code be offered.
Issue #1: Passing a variable holding a property name through Macro() for later use:
With this I'm needing to hold the name of a property, to both gather information from and update with new values throughout the entire macro-chain. The reason I'm going this route is so that I can have token properties with weapon variables for what the characters have equipped, with a macro able to call on each weapon property but utilise the same attack macro-chain on a library token.
I'm obviously doing something wrong as the property name and values don't seem to get properly passed or accessed. I've tried having the property name in quotes as the value of the property, and I've tried passing only part of the property name to add to the other part of the property name to call on it, and neither have worked. I have been able to assign the property values and pass those along, but that leaves me without having the property name to call for updating the property's values.
Issue #2: Accessing nested json objects:
Normally I try to avoid nesting json objects or string property lists (including with each other), but it seems to be the only way to get what I'm wanting. As a quick run down, I'm wanting a list of variables holding weapon information (name, size of clip, rounds remaining, etc). One of these variables should then hold a list of firing mode/option variables, each of which holds further variables specific to that option (damage amount, damage type, rounds expended, etc). This is so that I can have variable power levels, rate of fire settings, kill/stun settings, and other such, but only display info relevant to each weapon.
Here are the properties and macros I've come closest to getting success with.
Used Campaign Properties
Code: Select all
attrib.brawn (Br):3
attrib.finesse (Fi):3
attrib.size:0
equip.weapon.two
skill.Ranged_Combat:type=broad; attrib=Fi; value=0; trained=0
skill.Rayguns:type=tech; broad.skill=skill.Ranged_Combat; value=0; trained=0
Weapon Property
Code: Select all
{"name":"blaster pistol", "tech":"rayguns", "modes":{"kill":{"damage":"9", "type":"energy", "expends":"1", "range":"200"}, "stun":{"damage":"9", "type":"fatigue", "expends":"1", "range":"20"}}, "clip.current":"50", "clip.max":"50", "reload":"2"}
Weapon Macro
Code: Select all
[h,macro("attack.macro.2@Lib:combat"): "equip.weapon.two"]
Attack Macro: attack.macro.2 on Lib:combat
Code: Select all
I'm pretty lost on all of this and so welcome all help in getting this working. I'm also willing to take a different approach if needed, so long as the outcome arrives at what I'm needing. I will also state now that I am thinking of changing to Dialog() instead of Input(), to avoid potential property resets in case something happens while it's up and so that characters can check again which target in the list they want (for when they run up against multiple similar opponents, like a squad of stormtroopers or hive gangers). I don't think that will change either of these options, but I suppose it's something to keep in mind should snippets of code be offered.