-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getLibMap(libTokenName) and/or getMap(tokenName) function #1142
Comments
The function |
Seems like it should be just one function. Perhaps by extending the |
|
findToken() would be complimentary for sure. Yes, empty string for no results. |
So essentially you want something like this:
I'm not against having a single function that does the same thing in one call. Just looking for current functions that could be extended to do the same thing. |
Basically. Now with the findToken(id,map) option, you don't have to actually change maps to use findToken like you did before. I just thought it was strange there was no simple way to know which map my lib token was on even when running a macro from that token. An example use case is this:
I have to set a property on the token to know which map it's on. This function searches for macros only on that lib token, but I could be on a different map when running the macro. |
That's the problem with no actual design before willy nilly throwing in macro functions. Why doesn't Being able to locate the map(s) a token is on by name or ID seems like an obvious function to have even if I've never needed it. |
I usually use findToken() to validate a token is on the current map. The is mostly for custom frames holding persistent data. For example, I have a custom chat that allows you to "impersonate" a token even if that token is on another map. I save the relevant token info and update it if the token is on the current map. There may be the same token on multiple maps with the same name, but the id may be (is always?) different. |
Yeah It reminds me of the infamous "Find Traps" spell in D&D 5e, which doesn't actually find or locate traps, it just tells you whether a trap is present within 120 feet of you at the time of the casting. |
Instead of We could add the usual |
getTokenMap() fits better with the existing naming convention. |
Tentatively put on 1.5.11 in case someone wants to jump on this quickly. |
- Add function getTokenMap(identifier, delim), that returns the list of maps containing the token corresponding to the identifier - Close RPTools#1142
PR #1168 adds the feature. |
Documentation: https://lmwcs.com/rptools/wiki/getTokenMap |
Tested. Working as documented. |
Now that we have all these neat functions that can utilize the map location, now all we need is a way to know which map a token is on. lib:tokens are unique so that function should only have one result, but if possible having a
getMap(tokenName): array of maps
would be optimal.Currently, if I want to know which map my library token is on I set a property on the lib token. You can't use default values for library token properties, and setting properties during onCampaignLoad isn't supported (duplicate token thing, but can be worked around), so this should to be done manually in the token props. The other method to find a token on a map is to loop through all the maps and use findToken.
So, getLibMap() and getMap() would be very helpful and more convenient to have. If getMap() is too complicated or time consuming then I'll settle for just getLibMap().
The text was updated successfully, but these errors were encountered: