Skip to content
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

'getSightType()' fails on newly created tokens. #1828

Closed
melek opened this issue May 14, 2020 · 8 comments
Closed

'getSightType()' fails on newly created tokens. #1828

melek opened this issue May 14, 2020 · 8 comments
Assignees
Labels
bug documentation needed Missing, out-of-date or bad documentation macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) tested This issue has been QA tested by someone other than the developer.

Comments

@melek
Copy link
Collaborator

melek commented May 14, 2020

Describe the bug
getSightType() fails on newly created tokens.

To Reproduce
Steps to reproduce the behavior:

  1. Open a blank campaign.
  2. Drag a token to the map.
  3. Right Click on the token and select Impersonate.
  4. In chat, type [getSightType()]. Macro won't run, See error:
    Error in body of roll.
    Statement options (if any):
    Statement Body : getSightType()
    
  5. Double-click the token to edit it, and hit 'Ok'.
  6. Repeat step 4. Now the result is Normal.

Expected behavior
getSightType() should work on new tokens without opening the token editors.

Screenshots
image

MapTool Info

  • Version: 1.5.14 and 1.7.0b2
  • Install: New alongside many other versions

Desktop (please complete the following information):

  • OS: Win10

Additional Context
This happens whether or not the new token dialog is displayed when a new token is created.

For some reason, some trusted macros which affect the tokens will fix the issue when run by GM, but not when called by the player. It might be because the macros I tried this with were called from the GM panel, which has trust issues (#1817)

@Phergus
Copy link
Contributor

Phergus commented May 14, 2020

Might be related to #1811 . Same kind of situation.

@Merudo
Copy link
Member

Merudo commented May 15, 2020

I don't understand how MapTool determines which sight type should be the default. Ideally it should be a Campaign property.

@melek
Copy link
Collaborator Author

melek commented May 15, 2020

I'm guessing that when the Edit Token dialog populates the 'Sight Type' list, it grabs the first one and sets it.

However, a campaign is still valid with no defined sight types, and getSightType should not break a whole macro in that case; in my opinion it should return an empty string.

@Phergus
Copy link
Contributor

Phergus commented May 15, 2020

However, a campaign is still valid with no defined sight types, and getSightType should not break a whole macro in that case; in my opinion it should return an empty string.

This is the important part. It should not produce an error especially one that implies that the macro script is in some way wrong.

Adding the ability to set a default Sight type would be a separate issue.

@balp
Copy link
Contributor

balp commented May 15, 2020

I think I understand what happens in this code path and like to have a go at a solution.

balp added a commit to balp/maptool that referenced this issue May 15, 2020
This commit Closes RPTools#1828 with the simple solutions just to return
an empty string when the value of getSightType() on the token is
null.
balp added a commit to balp/maptool that referenced this issue May 15, 2020
This commit Closes RPTools#1828 with the simple solutions just to return
an empty string when the value of getSightType() on the token is
null.
@balp
Copy link
Contributor

balp commented May 15, 2020

Returning an empty string.

image

@Phergus
Copy link
Contributor

Phergus commented May 15, 2020

Tested. Running getSightType() on newly added token no longer produces an error but instead returns "".

@Phergus Phergus added documentation needed Missing, out-of-date or bad documentation macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) tested This issue has been QA tested by someone other than the developer. labels May 15, 2020
@melek
Copy link
Collaborator Author

melek commented May 16, 2020

Updated the wiki:
https://lmwcs.com/rptools/wiki/getSightType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug documentation needed Missing, out-of-date or bad documentation macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) tested This issue has been QA tested by someone other than the developer.
Projects
None yet
Development

No branches or pull requests

4 participants