dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

Add script-data.lua - A method for lua scripts to save data directly as json

Open Atkana opened this issue 4 years ago • 2 comments
trafficstars

This module is a resource for persistently saving lua tables directly with the json implementation. It handles either saving data globally (available anywhere) or as world data (specific to the save). World data is saved automatically whenever the world is unloaded, as well as whenever the game is saved via autosave or quicksave.

Ideally it needs somebody to go over and review a few things:

  • Does the documentation make sense? Can you understand how to use the module from it? (I'm not great at articulating things >.>)
  • Will the files save fine on every operating system (I've only checked for the OS I have - Windows 10)? I've not dabbled much in file system stuff before, and I can half-remember from somewhere that OSes can sometimes get picky about which slashes you use in file paths(?).
  • Is this an okay way of handling this?

Atkana avatar Jan 30 '21 12:01 Atkana

I guess I missed the boat to do this huh. I just converted my code for this into a class, I was gonna see about making it internal and a bit more generalized next. https://github.com/cppcooper/dfhack-scripts/blob/d07ce6688ecea340d4724646dbe319eca75006ea/dwarf-op2.lua#L543

cppcooper avatar Sep 01 '21 16:09 cppcooper

I'm going through older PRs, and this looks interesting, but I'm a little confused. What benefits does this offer over the current feature set of persist-table and json? For example, would gui/launcher or emigration benefit from using script-data instead of the existing APIs?

myk002 avatar Nov 29 '23 08:11 myk002

This looks cool, but I think it has been superseded by the dfhack.persistent API

myk002 avatar Mar 22 '24 07:03 myk002