Describe the bug
getSightType() fails on newly created tokens.
To Reproduce
Steps to reproduce the behavior:
Impersonate.[getSightType()]. Macro won't run, See error: Error in body of roll. Statement options (if any): Statement Body : getSightType()
- Double-click the token to edit it, and hit 'Ok'.
- Repeat step 4. Now the result is
Normal.
Expected behavior
getSightType() should work on new tokens without opening the token editors.
Screenshots

MapTool Info
Desktop (please complete the following information):
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)
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.

Tested. Running getSightType() on newly added token no longer produces an error but instead returns "".
Updated the wiki:
https://lmwcs.com/rptools/wiki/getSightType
Most helpful comment
Returning an empty string.