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

selectedToken@Lib:Overlay errors on macros with leading or trailing spaces #39

Open
melek opened this issue Mar 28, 2021 · 0 comments
Open

Comments

@melek
Copy link

melek commented Mar 28, 2021

Describe the bug
Macros with leading or trailing spaces cause an error for Lib:Overlay when their containing token is selected. Since the BoT contains such a macro, several users have been running into this problem.

This seems to only happen in newer versions of MapTool,

To Reproduce
Steps to reproduce the behavior:

  1. Make any token in the framework, ensuring that Lib:Overlay is activated.
  2. Add the macro with the label " Starts with a Space" (or "Ends with a Space "), excluding the quotes.
  3. Click on the token.
  4. See error:
Argument number 1 "" to function "getMacroProps" must be an integer.
Error trace : selectedToken@Lib:Overlay <<< OverlaySelected@Lib:Overlay <<< macroLink

Expected behavior
No error should occur.

Workaround
I have found that processing macro names as JSON fixes this issue. This is how I recommended on Discord to fix this issue:

  • Select Lib:Overlay and right click and edit the selectedToken macro.
  • REPLACE Lines 128-138 with the following code (it is a bit shorter than the existing code, so you can expect that it will take fewer lines):
    [h:macros=getMacros("json")]
    [h:json=macros]
    [h,count(json.length(macros)),code:{
        [h:currentMacro=json.get(macros, roll.count)]
        [h:index=listget(getMacroIndexes(currentMacro), 0)]
        [h:props=getMacroProps(index)]
        [h:json=json.set(json,roll.count,json.fromStrProp(props))]
    }]

I'll note that if you follow that thread, at least one person had other errors after my fix (though I suspect those are unrelated to this, except that they are likely new issues due to recent macro performance changes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant