maptool icon indicating copy to clipboard operation
maptool copied to clipboard

[Feature]: Addon-Properties - manual Variable types

Open Lector opened this issue 7 months ago • 0 comments

Describe the Problem

As an addon developer, I want to be able to specify the data type of the properties that I share in my addon, so that I can avoid unexpected errors or limitations when using setLibProperty or getLibProperty functions.

Currently, the data type of the properties is inferred from the first value that is set, which can cause problems if the value changes later to a different type. For example, if I set a property to 0, it becomes an integer, and I cannot set it to a string later. This can break some features that rely on list or string manipulation.

The Solution you'd like

I would like the datatype of the internal values stored in the addon to automatically change when an integer is written to a string and vice versa.

Alternatives that you've considered.

If you have good reasons to not make the datatypes of the internal variables as dynamic as the variables in the MT script languages are I propose to add at least a way to predefine the data type of the properties. This could be possible in the prop_file_map.txt file.

Additional Context

Here is one example of a problem that might come up with how it currently works: https://github.com/RPTools/maptool/issues/4601

TLDR: If you want a Property of type string and write a "1" it locks to an integer and ignores any strings that come in via setLibProperty.

Lector avatar Jan 03 '24 13:01 Lector