MCPcopy Create free account
hub / github.com/DFHack/dfhack / dfhack_persistent_save_data_string

Function dfhack_persistent_save_data_string

library/LuaApi.cpp:309–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307typedef PersistentDataItem (*raw_get_data_fn)(const string &, bool);
308
309static 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
328static int delete_site_data(lua_State *L, get_data_fn get_data) {
329 CoreSuspender suspend;

Calls 3

luaL_argerrorFunction · 0.85
luaL_errorFunction · 0.85
isValidMethod · 0.45

Tested by

no test coverage detected