Accessing a Lib token from another map

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
Irrlicht
Dragon
Posts: 426
Joined: Mon Feb 09, 2009 10:53 am

Accessing a Lib token from another map

Post by Irrlicht »

I have a Lib:Casting token for spells that works like this: it has a "Spell Selector" macro and a group of other macros (one for each spell) called "Spells". A PC token has a "Spellcasting" macro that calls the Spell Selector, which in turn gets the list of spells it has on the "Spells" group, opens an input window for the player to choose, and once the choice is made, it runs the specific macro for that spell, with some variables passed from the PC token (like its relevant ability score modifiers and caster level) passed to the final spell macro.

It works fine, as long as the PC token and the Lib:Casting token are on the same map.
The problem is when they are on different maps, because for some reason the PC macro ("Spellcasting") can't seem to be able to access the Lib.

Now, with the hope I don't need to copy all the code I used here (cleaning it of the additional chunks would be a pain), what would be the best way to have easy access throughout maps, without having to always move the Lib:Casting library on the current map?

As far as I can tell, the error is produced by the fact that in the "Spell Selector" macro I use switchToken() to set the Lib as the current token, so that I can get the "Spells" macro group.
To get that group without switching the current token, I'd need the Lib's ID... but to get the ID I need to set it as the current token, so it seems like aloophole...
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Accessing a Lib token from another map

Post by aliasmask »

Use Wiki: getLibProperty() and specify the library name. You don't need to switch to the token.

User avatar
Irrlicht
Dragon
Posts: 426
Joined: Mon Feb 09, 2009 10:53 am

Re: Accessing a Lib token from another map

Post by Irrlicht »

Uhm, but how do I get a macro group the Lib has? It isn't a property.

EDIT
Also, just now I tried a "dirty" workaround: I got the Lib's ID with a simple "[r: getSelected()]" macro, copied it and used it on another tokens' macro to try to get the list of macros:

[r: getMacroGroup("Spells", "C0A800028A9EAF54EF02000040A80002")]

But it doesn't work.
Rather, it returns the group with the same name from the token that is running the macro (I created the "Spells" group in that token with a macro in it just to test my tinkering), despite the target ID being specified in getMacroGroup().
Wiki says getMacroGroup() should have a delimiter specified before the ID, but if you specify it ([r: getMacroGroup("Spells", ",", "C0A800028A9EAF54EF02000040A80002")]) it only gives an error.
Looks like getMacroGroup() will work only if the target token is on the same map.
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Accessing a Lib token from another map

Post by aliasmask »

You can access properties but not token specific things like a macro group. In order to do that you have to change your current map to the map the library is on then switch the map back. This in most cases will cause the screen to flicker rather than fully load either map.

I'm not sure why you would want to get the macro groups on the token but you can store that info in to a property if it's important.

User avatar
Irrlicht
Dragon
Posts: 426
Joined: Mon Feb 09, 2009 10:53 am

Re: Accessing a Lib token from another map

Post by Irrlicht »

Well, because that Lib token acts as a spell repository containing every spell. The selector macro writes up the list and then calls the proper spell macro. The macro on a PC token calls the selector to do that.

Anyway, alright, I'll see if I can work it around with properties, thanks.
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Accessing a Lib token from another map

Post by aliasmask »

Does your spell repository just list the details of the spell or does it do other things like select targets and do damage?

User avatar
Irrlicht
Dragon
Posts: 426
Joined: Mon Feb 09, 2009 10:53 am

Re: Accessing a Lib token from another map

Post by Irrlicht »

Each macro rolls damage, calculates max range, rolls to hit, etc., using the properties of the original token (the caster level, the spellcasting ability modifier, base attack bonus, etc.).

Certain spells are just text, but they're the rare ones with no variable at all (fixed range, fixed duration, no rolls in its effects, etc., like maybe the Know Direction spell).
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."

Post Reply

Return to “Macros”