Check for Token Existence

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
RPTroll
TheBard
Posts: 3159
Joined: Tue Mar 21, 2006 7:26 pm
Location: Austin, Tx
Contact:

Check for Token Existence

Post by RPTroll »

Is there a way to check for token id existence that doesn't blow an error?

Is it just getting all the tokens on a map and check with a json.contains?
ImageImage ImageImageImageImage
Support RPTools by shopping
Image
Image

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

Re: Check for Token Existence

Post by aliasmask »

I use Wiki: findToken(). Works both for names and ids and returns "" if not found on current map. I also use Wiki: getImage() to find a token in the campaign, but that only works with a name.

User avatar
RPTroll
TheBard
Posts: 3159
Joined: Tue Mar 21, 2006 7:26 pm
Location: Austin, Tx
Contact:

Re: Check for Token Existence

Post by RPTroll »

Thanks. The getImage one is interesting along with the image: type tokens. I've been using state images for those sorts of things.
ImageImage ImageImageImageImage
Support RPTools by shopping
Image
Image

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

Re: Check for Token Existence

Post by aliasmask »

getImage works for any token, not just image:tokens, although I think it was originally designed for only image tokens and later changed.

Post Reply

Return to “Macros”