lua: world.get_total_time + set_block_user_bits fix

This commit is contained in:
MihailRis
2024-01-22 09:52:26 +03:00
parent ff7f18fa7b
commit 31eda1abb2
6 changed files with 147 additions and 112 deletions
+7 -4
View File
@@ -489,12 +489,13 @@ void WorldFiles::writeWorldInfo(const World* world) {
versionobj.put("major", ENGINE_VERSION_MAJOR);
versionobj.put("minor", ENGINE_VERSION_MINOR);
root.put("name", world->name);
root.put("seed", world->seed);
root.put("name", world->getName());
root.put("seed", world->getSeed());
auto& timeobj = root.putMap("time");
timeobj.put("day-time", world->daytime);
timeobj.put("day-time-speed", world->daytimeSpeed);
timeobj.put("total-time", world->totalTime);
files::write_json(getWorldFile(), &root);
}
@@ -507,8 +508,9 @@ bool WorldFiles::readWorldInfo(World* world) {
}
auto root = files::read_json(file);
root->str("name", world->name);
root->num("seed", world->seed);
world->setName(root->getStr("name", world->getName()));
world->setSeed(root->getInt("seed", world->getSeed()));
auto verobj = root->map("version");
if (verobj) {
@@ -522,6 +524,7 @@ bool WorldFiles::readWorldInfo(World* world) {
if (timeobj) {
timeobj->num("day-time", world->daytime);
timeobj->num("day-time-speed", world->daytimeSpeed);
timeobj->num("total-time", world->totalTime);
}
return true;