File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -241,12 +241,15 @@ Reading and writing files and other persistent state
241241There are several locations and APIs that a mod might need to read or store
242242data:
243243
244- Global state that is not world-specific should be stored in a file in the
245- :file: `dfhack-config/ ` directory. JSON is a convenient format for this, and
246- DFHack provides facilities for reading and writing JSON data. For example::
244+ Global state that is not world-specific should be stored in the directory
245+ returned by the ``scriptmanager.getModStatePath() `` function. JSON is a
246+ convenient format for this kind of stored state, and DFHack provides facilities
247+ for reading and writing JSON data. For example::
247248
248249 local json = require('json')
249- config = config or json.open('dfhack-config/mymodname.json')
250+ local scriptmanager = require('script-manager')
251+ local path = scriptmanager.getModStatePath('mymodname')
252+ config = config or json.open(path .. 'settings.json')
250253
251254 -- modify state in the config.data table and persist it when it changes with
252255 -- config:write()
@@ -326,7 +329,7 @@ mod data and the ``json`` (or any other file I/O) API as needed. For example::
326329 local GLOBAL_KEY = 'mymodname'
327330
328331 local function read_bulk_data_db()
329- local mod_path = scriptmanager.getModStatePath (GLOBAL_KEY)
332+ local mod_source_path = scriptmanager.getModSourcePath (GLOBAL_KEY)
330333 -- read data from files in the mod directory
331334 return ...
332335 end
You can’t perform that action at this time.
0 commit comments