Skip to content

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

@melek

Description

@melek

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions