Bug with getMatchingProperties()?

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

Post Reply
User avatar
celestian
Dragon
Posts: 276
Joined: Mon May 17, 2010 3:29 pm

Bug with getMatchingProperties()?

Post by celestian »

Okay, can someone explain why this works:

Code: Select all

[H, token(myID): myBooks = getMatchingProperties("book\\..*")]
But this doesn't?

Code: Select all

[h: myBooks = getMatchingProperties("book\\..*", ",", myID)]
All I did was add the delim and id parameter in the second version and it doesn't work. I tried both of them in the same macro (trusted)... but only the first method worked. If it matters I am using 1.3.b91.

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

Re: Bug with getMatchingProperties()?

Post by aliasmask »

May depend on permissions and where the macro is being run from. I'm not really sure though. Seems like it should work as is. Perhaps use [.] instead of \\. Is it a lib token? If so, use getMatchingLibProperties. There may be an internal check when passing the token id.


User avatar
celestian
Dragon
Posts: 276
Joined: Mon May 17, 2010 3:29 pm

Re: Bug with getMatchingProperties()?

Post by celestian »

aliasmask wrote:May depend on permissions and where the macro is being run from. I'm not really sure though. Seems like it should work as is. Perhaps use [.] instead of \\. Is it a lib token? If so, use getMatchingLibProperties. There may be an internal check when passing the token id.
It's run from a lib token but the data it's checking is on a non-lib token (player token).
wolph42 wrote:can you share the campaign file with both macro in it, so we can test.
I've got the framework up on git, I'll get it in a working state and get a current copy. I'm in the middle of revamping something that requires me tweak a lot of the macros.

I might actually just strip this down to a tiny campaign and post. Either way I'll have to do it this evening once I get done with work.

User avatar
celestian
Dragon
Posts: 276
Joined: Mon May 17, 2010 3:29 pm

Re: Bug with getMatchingProperties()?

Post by celestian »

Actually, here is the extracted macros into campaign.

gmpTest and gmpTest-broken are the 2 macros on the single user token that runs script from Lib:Test.
Attachments
gmpTest.cmpgn
gmp test
(503.27 KiB) Downloaded 45 times

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

Re: Bug with getMatchingProperties()?

Post by wolph42 »

ok I ran a test and it rendered the error 'three parameters were given, only two are allowed' so apparently one of the 2 is not allowed, this is not conform the wiki so either the wiki is wrong or its a bug...

edit: ah wait:
Note: This parameter can only be used in a Trusted Macro.
so your macro is not trusted. Turn off (uncheck) 'allow players to edit macro' in teh macro editor.
and then it renders the error: unknown token "" so something in your parameters is off.
testing that it appears that 'macro.args' is empty.

User avatar
celestian
Dragon
Posts: 276
Joined: Mon May 17, 2010 3:29 pm

Re: Bug with getMatchingProperties()?

Post by celestian »

wolph42 wrote:ok I ran a test and it rendered the error 'three parameters were given, only two are allowed' so apparently one of the 2 is not allowed, this is not conform the wiki so either the wiki is wrong or its a bug...

edit: ah wait:
Note: This parameter can only be used in a Trusted Macro.
so your macro is not trusted. Turn off (uncheck) 'allow players to edit macro' in teh macro editor.
and then it renders the error: unknown token "" so something in your parameters is off.
testing that it appears that 'macro.args' is empty.
I unchecked it from all but the lib:test/broken macro by mistake.

Even unchecked it still doesn't work.
  Error in body of roll.       Statement options (if any): h       Statement Body : myBooks = getMatchingProperties("book\\..*", ",", myID)
Attached version as trusted on all macros.
Attachments
gmpTest.cmpgn
gmpTest 2
(503.27 KiB) Downloaded 39 times


User avatar
celestian
Dragon
Posts: 276
Joined: Mon May 17, 2010 3:29 pm

Re: Bug with getMatchingProperties()?

Post by celestian »

wolph42 wrote:read the rest of my post
I did, sorry if I don't get it.

It's the same code for both except for how I use getMatchingProperties. I followed the wiki documentation for the 3 options within.
testing that it appears that 'macro.args' is empty.
If it was then neither version would work.

I added a test to double check and the broken macro does not report invalid myID.

Code: Select all

[h: myID = getStrProp(macro.args,"myID")]
[h: assert(!(myID==''),"myID is invalid "+getMacroName()+"@"+getMacroLocation())]
No matter what I put in the 3rd parameter of getMatching*() (getSelected() for example), even running directly on the token, it fails . I even tweaked the regex as suggested down to just "book"...

Either way, I'm using the token() method. Just thought I would mention the problem.

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

Re: Bug with getMatchingProperties()?

Post by wolph42 »

Then someone needs to check a again. I'm flying off to Zurich today for the rest of the week and don't know if I will have time to have a look this week

User avatar
celestian
Dragon
Posts: 276
Joined: Mon May 17, 2010 3:29 pm

Re: Bug with getMatchingProperties()?

Post by celestian »

I've kinda run into a problem with this. Need to figure out this bug and/or me doing something wrong. Using token() works great until I need it to work across maps. I assumed it'd work on a Lib:Something but it won't.

Code: Select all

[H, token("Lib:MM"): myWeapons = getMatchingProperties("weapon\\..*")]
works great until I try and run the macro in a map w/o "Lib:MM".

Manually running the above command in a map (minus the H,) net's the same thing. Works in map, breaks in another.

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

Re: Bug with getMatchingProperties()?

Post by aliasmask »

You really should use getMatchingLibProperties for lib tokens. I'm not sure if you can be on a different map and have that work.

User avatar
celestian
Dragon
Posts: 276
Joined: Mon May 17, 2010 3:29 pm

Re: Bug with getMatchingProperties()?

Post by celestian »

aliasmask wrote:You really should use getMatchingLibProperties for lib tokens. I'm not sure if you can be on a different map and have that work.
I spend so much time fiddling around with things like this when all I had to do was look down in the "See Also" section.

getMatchingLibProperties works perfect.

Once again, I bow to your wisdom.

Post Reply

Return to “Macros”