Retrieving individual variables from a list of nested arrays

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

femanon
Cave Troll
Posts: 95
Joined: Sat Jun 16, 2012 10:25 pm

Re: Retrieving individual variables from a list of nested ar

Post by femanon »

aliasmask wrote:Token Properties:
[spoiler=]

Code: Select all

stats:Strength=10;Dexterity=10;Constitution=10;Intelligence=12;Wisdom=10;Charisma=10;
*bonuses:[H: varsFromStrProp(stats)][R: "StrB "+floor((Strength-10)/2)+", DexB "+floor((Dexterity-10)/2)+", ConB "+floor((Constitution-10)/2)+", IntB "+floor((Intelligence-10)/2)+", WisB "+floor((Wisdom-10)/2)+", ChaB "+floor((Charisma-10)/2)]
[/spoiler]
This just uses the data in stats, defines them in bonuses for use in setting the value of that property. bonuses is just text that lists what the bonuses are, but if I wanted to set those values in an array, then I would do this:

[spoiler=]

Code: Select all

stats:Strength=10;Dexterity=10;Constitution=10;Intelligence=12;Wisdom=10;Charisma=10;
bonuses:[H: varsFromStrProp(stats)][R: json.toStrProp(json.set("{}","StrB",floor((Strength-10)/2),"DexB",floor((Dexterity-10)/2),"ConB",floor((Constitution-10)/2)"IntB",floor((Intelligence-10)/2)"WisB",floor((Wisdom-10)/2)"ChaB",floor((Charisma-10)/2)))]
[/spoiler]
This creates a whole new set of variables based on the property above. But, there is one major problem. It doesn't calculate the variables unless you put * in front and then mouse over token. Then with more complicated formulas, you'll have to have varsFromStrProp all the data sets on that one line and it's really REALLY easy to cause some error popups that seems to be infinite. Putting all this junk on a token instead of in the properties is the way to go.


from the top, because I dont want to make work for my gm, you haven't, a variable is not inherently a property but any string marker that stores any kind of information that is expected to change. the rest in that paragraph is correct. I am looking to do just that. it seems completely strange that you are saying I am being incomprehensible here when I'm trying to do something apperantly quite common. wolfs examples work fine so I'm going to use them.

What *I* gather from this is that the above STR property call existing properties directly, while *you* want to retrieve these variables from a nested array in another property
[spoiler=]

Code: Select all

Strength[r:STRluck + STRsac]
[/spoiler]
while STRluck and STRsac are nested somewhere in an array in another property e.g.
another property on the token, lets call it stuffARRAY which contains (for example)
Code:
[spoiler=]

Code: Select all

AbilSTR=STRluck=0 ## STRsac=0; AbilDEX=DEXluck=0 ## DEXsac=0
[/spoiler]

so to keep things simple we have two items, but lets make it a bit clearer since the example above lead to some confusion in the beginning
[spoiler=]

Code: Select all

Move:UniAB=[r:BAB+MoralU]; Fort=[r:Base+ResistU+MoraleU];
[/spoiler]
Keeping the terms the same, I want to aquire these variables which appear as property calls since I as of yet do not know how to properly call them from within nested arrays, as explained by wolf
[spoiler=]

Code: Select all

Description:ABU=BAB=3 ## MoraleU=2; SaveU=ResistU=0 ## MoraleU=3; 
[/spoiler]
From a Nested array like this, as a more complete example.

User avatar
aliasmask
Deity
Posts: 8692
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Retrieving individual variables from a list of nested ar

Post by aliasmask »

How do you want to interpret this as a nested "array"?

Code: Select all

Description:ABU=BAB=3 ## MoraleU=2; SaveU=ResistU=0 ## MoraleU=3;


I'm going to assume this is intended to be nested string properties where the format is name = value; and where ## is used as ; for nesting purposes. ; is for level 1, ## is for level 2, the nested part. If done as a json, it would look like this:

Code: Select all

Description:[R: json.set("{}","ABU",json.set("{}","BAB",3,"MoraleU",2),"SaveU",json.set("{}","ResistU",0,"MoraleU",3))]

OR

Code: Select all

Description:[R: '{"ABU":{"BAB":3,"MoraleU":2},"SaveU":{"ResistU":0,"MoraleU":3}}']

I see that you have MoraleU for ABU and a different MoraleU for SaveU. You can save yourself trouble by not doing it that way, but by making all the variables unique. So instead:

Code: Select all

Description:abu.BAB=3;abu.moraleU=2;saveU.resistU=0;saveU.moraleU=3;
Move:[H: varsFromStrProp(Description)]UniAB=[r: abu.BAB+abu.moraleU];Fort=[r: saveU.resistU+saveU.moraleU]

Otherwise, it will be far more complex to get the nested values. This way, the nested structure is handled by the variable naming rather than creating a structure to navigate through.

femanon
Cave Troll
Posts: 95
Joined: Sat Jun 16, 2012 10:25 pm

Re: Retrieving individual variables from a list of nested ar

Post by femanon »

aliasmask wrote:How do you want to interpret this as a nested "array"?

I'm going to assume this is intended to be nested string properties where the format is name = value; and where ## is used as ; for nesting purposes. ; is for level 1, ## is for level 2, the nested part. If done as a json, it would look like this:

No, you do not need to assume, this is something I've told you. Behaving like you're coming to this conclusion as though I did nothing to facilitate that understanding is quite getting on my nerves.

I see that you have MoraleU for ABU and a different MoraleU for SaveU. You can save yourself trouble by not doing it that way, but by making all the variables unique. So instead:

Otherwise, it will be far more complex to get the nested values. This way, the nested structure is handled by the variable naming rather than creating a structure to navigate through.

Given that I changed a seemingly perfectly fine working example by Wolf SO THAT there would two identical variables associated with an array I'm having a hard time understanding why you have decided to spend the majority of your post telling me as If I'm ignorant not to do it because it's complicated. as I've said in previous posts, the REASON that I'm doing it this way is so that I do not have to create an expansive and complicated index. To make double sure you understand what I am talking about, an Index is a numbered list associated with an array of values, and is inherently chronological from start to finish. Any suggestion that i change the system entirely needs to account for how to avoid making the index overly complicated, and so far as I understand, creating that structure to properly navigate through one list to the other is the only way to avoid doing this, and is in fact the goal I've been asking about numerous times in this thread.

User avatar
wolph42
Deity
Posts: 9883
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Retrieving individual variables from a list of nested ar

Post by wolph42 »

good to hear im on the right track here. I glanced over AM and your post and although it goes completely beyond me i do notice a slight agitation in the writing. Just want to say, lets keep civil here, and keep in mind that we are trying to help you. I notice a HUGE miscommunication and that can lead to frustration, if we get offended we simply stop posting to your questions which doesn't really help.

anyway. Not that i get what you're aiming at (at least one of your goals) i want to draw you attention to the 'note to self' spoiler i created. It was a simple test but (i was slightly surprised) it appears that varsfromstrprop works in the property environment. You can use that to your advantage. Point is, i tried it directly, you'll fist need to unnest them which brings me to the next part...if every variable is unique you don't need to nest them but you can create one big strprop.

now most likely there is another goal that interferes with that and you REALLY need the nesting. Assuming you do, im inclined you simply use a json object where you nest the lot. then you can use e.g.
varsFromStrProp(json.get(propertyName, "StrVar")
or something similar as a property. This will make them all available within the property scope.

if that does not meet your second goal, please try to create a VERY simple example of what that goal is. And well take that step as well.

User avatar
aliasmask
Deity
Posts: 8692
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Retrieving individual variables from a list of nested ar

Post by aliasmask »

Sorry if you're getting annoyed with my comments to try and help you, but I'm just trying to steer you away from future problems. Since there was some confusion to the understanding, trying to say the same thing over to confirm isn't ignoring what you said, but trying to display I understand what you're looking for.

This:

Code: Select all

Description:ABU=BAB=3 ## MoraleU=2; SaveU=ResistU=0 ## MoraleU=3;


is a horrible way of creating a data structure. It's not a criticism since I don't believe you're a programmer. Just trying to steer you down the right path before you commit to a poor structure. But I can take a hint (or a sledgehammer over the head) that you don't want my help and I'll leave you to it.

Post Reply

Return to “Macros”