Maptool: 'getSightType()' fails on newly created tokens.

Created on 14 May 2020  路  8Comments  路  Source: RPTools/maptool

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()
  1. Double-click the token to edit it, and hit 'Ok'.
  2. 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)

bug documentation needed macro changes tested

Most helpful comment

Returning an empty string.

image

All 8 comments

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

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

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.

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.

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

Returning an empty string.

image

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

Was this page helpful?
0 / 5 - 0 ratings