append??!?

If you have searched the other User Creations subforums and an answer to your question has not been found, please post here!

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
blakdeth19
Cave Troll
Posts: 30
Joined: Sat Jan 03, 2015 11:05 am

append??!?

Post by blakdeth19 »

can someone please tell em why this code here:

[h:targetName = listGet(tokenList,Target)]
[h: items= getProperty("items", targetname)]

[h: json.append(getProperty("Items"), items))]

does not append the list but replaces it?..
it takes items from one token, and is suppose to add them to your items

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: append??!?

Post by wolph42 »

couple of mistakes there.
1. you don't assign the result of the append action to anything so it is lost. e.g.

Code: Select all

[h:items = 5]
[h:1 + items]
what do you expect to be the result??

Next I'm guessing that you are addressing properties directly in the macro and using the same property name in the code for other values. Big screw up! E.g. lets say you have the property 'items' on a token with the value 10. Then you do:

Code: Select all

[items = 5]
[items =  items + items]
well actually you do

Code: Select all

[items = 5]
[items + items]
so im guessing this is what you want:

Code: Select all

[h:targetName	= listGet(tokenList,Target)]
[h:tmpItems		= getProperty("items", targetname)]
[h:items		= json.append(getProperty("Items"), tmpItems))]
or faster:

Code: Select all

[h:targetName	= listGet(tokenList,Target)]
[h:items		= json.append(getProperty("Items"), getProperty("items", targetname)))]

blakdeth19
Cave Troll
Posts: 30
Joined: Sat Jan 03, 2015 11:05 am

Re: append??!?

Post by blakdeth19 »

thanks for the tips! i figured it out though, it was still using the data from the selected token
and not the impersonated token, so i used switch token to get impersonated

and to be safe i changed the names so there was no conflicting names

Post Reply

Return to “Requests for HELLLLP!”