RPTools.net

Discussion and Support

Skip to content

It is currently Sun May 26, 2013 1:28 am 






Reply to topic  [ 3 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Cave Troll
 
Joined: Mon Dec 05, 2011 10:58 am
Posts: 28
Location: Dreamwatch of Time
 Post subject: Passing property name through Macro() and nested jsons
PostPosted: Mon Mar 26, 2012 4: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.
Code:
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


Code:
{"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"} 


Code:
[h,macro("attack.macro.2@Lib:combat"): "equip.weapon.two"] 


Code:



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.

_________________
Kill them all, and let the Game Master grant the exp.

ImageImage


Top
 Profile  
 
User avatar  Offline
Cave Troll
 
Joined: Mon Dec 05, 2011 10:58 am
Posts: 28
Location: Dreamwatch of Time
 Post subject: Re: Passing property name through Macro() and nested jsons
PostPosted: Wed Apr 11, 2012 6:30 pm 
Complaint: Tendinitis makes it hard to make macros, or do much on a computer in general, especially when untreated for a couple weeks.

Realisation: It would seem that using varsFromStrProp() with json.toStrProp() affects json objects nested in the json object they are applied to. It would seem this is what was causing the problem I was having with nested json objects. This unfortunately requires more code to assign the needed variables, but shouldn't be an issue as long as the number of contained variables is not über long.

_________________
Kill them all, and let the Game Master grant the exp.

ImageImage


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 5497
Location: Netherlands
 Post subject: Re: Passing property name through Macro() and nested jsons
PostPosted: Fri Apr 13, 2012 5:41 am 
issue 1:

don't use "" that way you're passing that string as a value instead of the value of the variable. However moreover I would strongly advise you to use user defined functions. Dig the wiki thourgh to see how they work, but they are
1. a lot easier to work with
2. faster

2. neste json objects aren't *that* hard, however your structure isn't very usefull its better to use the weapon name as key so:
Code:

WEAPONS 
= {blaster pistol: {"name":"", "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"} , "another pistol":{...}}
 

This way you can store a property either on the token or on a lib:token 'Weapons' and retrieve lets say the 'blaster pistol\modes\kill\range' as follows:
Code:
wpnLib = getLibProperty("Weapons", "lib:Token")
wpn = json.get(wpnLib, "blaster pistol")
mode = json.get(wpn, "modes")
kill = json.get(mode, "kill")
range = json.get(kill, "range") 

you can embed all these into one line
or
you get IRC lindsays toolbox which contains json.pget and json.pset in whic case this becomes:
Code:
range = json.pget(wpnLib, "blaster pistol/modes/kill/range") 

_________________
My stuff
Excel Tools: Table editor and Illumination Generator
MT Tools: Dungeon Builder Tool, Bag of Tricks: Teleport pads, Pits, Traps and Warded Areas and onMouseOverEvent
Framework: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade and Only War
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow

My dropbox referral. If you use this then both you and me get 500Mb extra space. 2.5Gb total.


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 3 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 4 users online :: 3 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: booga, Google [Bot], Mezillious and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman