Getting property from non selected token

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

Moderators: Azhrei, dorpond, trevor

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
Hypatia
Cave Troll
Posts: 27
Joined: Sun Oct 21, 2012 5:30 am

Getting property from non selected token

Post by Hypatia »

Just started doing some Macro writing( slowly learning) so don't know all the terms yet but having trouble with calling macros and returning info

I have an Inventory button on a player PC (TUKKI) token which opens a dialog with macro links to all items they have on a library token Lib:INVENTORY.
He chooses Ring of the Ram
The Ring of the Ram macro on the lib token displays a frame with the info about the ring and also a further option to the USE CHARGE global macro which needs to know the CHARGES property from the TUKKI token to run

When operated from the TUKKI player token it asks for values for CHARGES

i know that this is because the USE CHARGE macro now thinks the Library token is the current token I just don't know how to fix it.
I have looked at the documentation for switch token etc but cannot make it work without having to put the pc token name each time and I want it to run for all players

I know there is a way to do this.


Also, is there a way you can have an input that asks for a name and then runs like this
INPUT = Magic Missile
It then runs a macro called
Magic Missile @Lib:Spells
ie it automatically inserts the input into the macro command

Thank you to anyone who spends time to respond. This macro writing lark is fun.

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

Re: Getting property from non selected token

Post by aliasmask »

When it asks for a variable it just means that variable isn't currently defined. The macro should ask for charges, write that value to the current token (not lib token) then everything should be fine. Well, that's the way it should be.

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

Re: Getting property from non selected token

Post by wolph42 »

so you start from the player token, meaning that its 'known'. when the player runs the macro and the frame is opened just make sure the token name (or better: id) is passed along to the frame and when the frame is 'done' the same value is passed onto 'charge' macro. Its a bit of a hassle to keep track of it, but not undoable.

When you finally arrive at 'charge' macro just run switchtoken(whateverispassedon) and then the rest

Hypatia
Cave Troll
Posts: 27
Joined: Sun Oct 21, 2012 5:30 am

Re: Getting property from non selected token

Post by Hypatia »

Thanks for reply.
Make sure the token name (or better: id) is passed along to the frame and when the frame is 'done' the same value is passed onto 'charge' macro

Trouble is I don't know how to do this. Could you write an example of the code if possible

PLAYER TOKEN = TUKKI
Macro on TUKKI token = INVENTORY containing macro link to.."Ring of the ram" macro on...
Library token = Lib:INVENTORY
ring of the ram macro on lib token contains link to USE CHARGE global macro
USE CHARGE macro changes CHARGES property on TUKKI

I tend to learn best when I have an example and can then sort of backward engineer it

Thanks

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

Re: Getting property from non selected token

Post by wolph42 »

something like:

Code: Select all

[macro("ring of [email protected]:inventory"):token.name]
or maybe

Code: Select all

[macro("ring of [email protected]:inventory"):json.append("",token.name, other, stuff, you, want, to, pass, on)]
should work.

ring of ram then should start with:
[token = arg(0)]
the other stuff is arg(1), arg(2) etc.

Hypatia
Cave Troll
Posts: 27
Joined: Sun Oct 21, 2012 5:30 am

Re: Getting property from non selected token

Post by Hypatia »

Thanks for your reply but sadly I cannot get it to work.

The USECHARGE global macro still asks for CHARGES value.

I fear I am just not advanced enough to understand where it is going wrong. Something to fix in the future.

Is the second part of my original question possible?

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

Re: Getting property from non selected token

Post by wolph42 »

can you post teh macro that you have?
a wild guess is that you're not using Wiki: getProperty()
NPUT = Magic Missile
It then runs a macro called
Magic Missile @Lib:Spells
ie it automatically inserts the input into the macro command

Code: Select all

[abort(input(
	"macroName||Give name of macro",
	"importantValue||Give important value"
))]

[macro(macroName+"@lib:Spells"):importantValue]

Hypatia
Cave Troll
Posts: 27
Joined: Sun Oct 21, 2012 5:30 am

Re: Getting property from non selected token

Post by Hypatia »

Thank you for the Input macro name info. That works nicely.

As to my original issue.....

Ring macro on TUKKI pc token =


[frame("
Ring of the Ram
"):{
<img src='[r:tblImage("MAGIC ITEMS",20)]'><span style="color:blue">

<br><br>
<i> This magical ring has a rams head shaped gem</i><br><br>
◾ Regains 1d3 charges at dawn
<br>
</span>
<span style="background-color:aqua"><b><i><font size=5> [r: macroLink(" Use Charge", "[email protected]", "gm-self", "count=6", "impersonated")]<br></span>
</p></body></html>}]


USECHARGE2 Macro on GM=

[h:CHARGES=CHARGES-1]

[if(CHARGES<=0),code:{
[H:CHARGES=0]
};{}]

I tried the switch token function but it said I did not have permission
I tried the get Property function but could not get it to return to the Tukki token to change the properties CHARGES.

Thanks again

Post Reply

Return to “MapTool”