-
Notifications
You must be signed in to change notification settings - Fork 274
Description
Describe the Bug
- In MapTool 1.17.1 and earlier, data.getStaticData() was able to access library/arbitrarydirectory/ using data.getStaticData("my.name.space", "arbitrarydirectory/testData.txt")
- In MapTool version 1.18.6, data.getStaticData() can only access library/public/ and subdirectories, but you still must specify the public/ part i.e. data.getStaticData("my.name.space", "public/testData.txt") . This seems contrary to how this function's expected operation, based on information in the second example in the Wiki: [(https://wiki.rptools.info/index.php/data.getStaticData)]
To Reproduce
My Time_tracker library has some default values in individual text files in library/property_defaults/
The text files are named currentYear, currentDay, etc... (no filename extension, but I don't think that's hugely relevant)
In the onFirstInit.mts script, I had lines such as:
Setting currentYear to default value: [r: currentYear = data.getStaticData("icarean.0001.Time_tracker", "property_defaults/currentYear")]
This is intended to initialise a library property that will be subsequently user-modifiable, and output to the chat window as confirmation of the setup process (though onFirstInit doesn't ever seem to produce such output in any version I've been working on this library with, which is 1.14.x upward).
Prior to upgrading MapTool from 1.17.1 to 1.18.6, the above line successfully set the library property currentYear, and this was able to be read back by typing the following in the chat window:
[getLibProperty("currentYear", "lib:icarean.0001.Time_tracker")]
In MapTool 1.18.6, however, the currentYear is empty. i.e. currentYear has not been successfully set in onFirstInit.
If I move the default value files into library/public/ , and change the onFirstInit line to the following:
'Setting currentYear to default value: [r: currentYear = data.getStaticData("icarean.0001.Time_tracker", "public/currentYear")]'
Now currentYear is set successfully.
Just to make sure the problem is about the subdirectories data.getStaticData() can access, rather than the use of an underscore character, I confirmed it also works in v1.18.6 to create a library/public/property_defaults/ subdirectory with those files in it, and use the following line in onFirstInit:
Setting currentYear to default value: [r: currentYear = data.getStaticData("icarean.0001.Time_tracker", "public/property_defaults/currentYear")]
But it doesn't work in v1.18.6 (where it does work in v1.17.1) to create a library/test/ subdirectory with the files in it, and use the following line in onFirstInit:
Setting currentYear to default value: [r: currentYear = data.getStaticData("icarean.0001.Time_tracker", "test/currentYear")]
Expected Behaviour
Backward compatibility with v1.17.1 and earlier. That is, as the Wiki suggests, data.getStaticData() should be able to access any specified subdirectory of library/
Screenshots
No response
MapTool Info
1.18.6
Desktop
Ubuntu 25.10
Additional Context
This error has come up simultaneous to another change in filepath behaviour in add on libraries in v1.18.6. See also this bug report: #5877
I've also made a feature request for onFirstInit to be able to output to the chat. Although that is a low priority request, perhaps that'd be an easy change while addressing these filepath compatibility issues? #5878