| 307 | typedef PersistentDataItem (*raw_get_data_fn)(const string &, bool); |
| 308 | |
| 309 | static int dfhack_persistent_save_data_string(lua_State *L, raw_get_data_fn get_data) { |
| 310 | CoreSuspender suspend; |
| 311 | |
| 312 | const char *key = lua_tostring(L, 1); |
| 313 | if (!key) |
| 314 | luaL_argerror(L, 1, "no key specified"); |
| 315 | const char *str = lua_tostring(L, 2); |
| 316 | if (!str) |
| 317 | luaL_argerror(L, 2, "no data string specified"); |
| 318 | |
| 319 | PersistentDataItem data = get_data(key, true); |
| 320 | if (!data.isValid()) |
| 321 | luaL_error(L, "unable to save data in key '%s'", key); |
| 322 | |
| 323 | data.val() = str; |
| 324 | |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | static int delete_site_data(lua_State *L, get_data_fn get_data) { |
| 329 | CoreSuspender suspend; |
no test coverage detected