b90 breaking some macros

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
Barlie
Kobold
Posts: 17
Joined: Wed Nov 07, 2012 2:41 pm

b90 breaking some macros

Post by Barlie »

I'm not entirely sure where this thread should go, but since the macro worked before, I figure it might be better treated as a bug than macro help.

I downloaded and installed the b90 beta build. For some reason, the initiative macros I got working in b89 do not work in the b90 build. Here's my macro for npc initiative:

Code: Select all

[h: i = getInitiativeRound()]
[h: removeAllFromInitiative()]
[h, if (i >0): setInitiativeRound(i+1); setInitiativeRound(1)]

[h, code:{
[jsonNPC = getNPC("json")]
[jsonInit = '[]']
}]

[h, foreach(id, jsonNPC), code:{
[jsonInsert = json.set('{}', "id", id, "init", d10)]
[jsonInit = json.append(jsonInit, jsonInsert)]
}]

[h: jsonInit = json.sort(jsonInit, "ascending", "init")]

[h, foreach(item, jsonInit), code:{
[current = json.get(item, "id")]
[value = json.get(item, "init")]
[switchToken(current)]
[addToInitiative()]
[setInitiative(value)]
}]
The error message I get is

Code: Select all

net.rptools.parser.ParserException: Unknown JSON type "init" in function "json.sort"
I'm using "init" inside the json.sort function as the key to be used for sorting. What's happening?

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: b90 breaking some macros

Post by aliasmask »

I think this is why: http://forums.rptools.net/viewtopic.php ... 62#p250959

I don't think there is an easy work around, but it would involve a couple of loops and rewriting the structure. Bubble sort is one algorithm.

Barlie
Kobold
Posts: 17
Joined: Wed Nov 07, 2012 2:41 pm

Re: b90 breaking some macros

Post by Barlie »

aliasmask wrote:I think this is why: http://forums.rptools.net/viewtopic.php ... 62#p250959

I don't think there is an easy work around, but it would involve a couple of loops and rewriting the structure. Bubble sort is one algorithm.
Sadly I'm not seeing a sort function for string properties. I *think* I'm seeing a way to rewrite these, as you say, by using a couple of loops to sort a string list of token ids according to a sorted string list of initiatives. But if this bug is going to get sorted out (see what I did there?) anyway, I'll probably just keep writing macros in b89 and switch over once its fixed.

User avatar
metatheurgist
Dragon
Posts: 364
Joined: Mon Oct 26, 2009 5:51 am

Re: b90 breaking some macros

Post by metatheurgist »

Maybe an override of json.sort() using the following functions might work as a temp fix?

json.toList()
listSort()
json.fromList()

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

Re: b90 breaking some macros

Post by wolph42 »

metatheurgist wrote:Maybe an override of json.sort() using the following functions might work as a temp fix?

json.toList()
listSort()
json.fromList()
no thats not gonna work due to the key value pair in the array which is sorted by its key. As AM says, there really aint a simple solution to this. Which makes this a big issue.


Post Reply

Return to “MapTool”