P4 hazards: food spoilage with rot speed setting, smoking rack and salt, food poisoning, harsher blizzards, hard winters with lake ice, lightning on trees, snow on roofs (protocol 11)

This commit is contained in:
Paul Bailey
2026-11-05 11:49:13 +00:00
parent 657c3140fe
commit 3389ec9a21
27 changed files with 1541 additions and 56 deletions

View File

@@ -40,7 +40,9 @@ func list_worlds() -> Array:
out.sort_custom(func(a, b): return float(a.get("last_played", 0)) > float(b.get("last_played", 0)))
return out
func create_world(world_name: String, seed: int) -> String:
## `options` are the world's own settings, kept in meta.json (P4: "rot",
## how fast food spoils: "normal", "slow" or "off").
func create_world(world_name: String, seed: int, options: Dictionary = {}) -> String:
DirAccess.make_dir_recursive_absolute(root_dir)
var base := world_name.to_lower().replace(" ", "_").validate_filename()
if base.is_empty():
@@ -52,10 +54,13 @@ func create_world(world_name: String, seed: int) -> String:
n += 1
DirAccess.make_dir_recursive_absolute(_dir(id))
var now := Time.get_unix_time_from_system()
_write_json(_dir(id).path_join("meta.json"), {
var meta := {
"name": world_name, "seed": seed, "created": now, "last_played": now,
"play_time": 0.0, "version": VERSION,
})
}
for k in options:
meta[k] = options[k]
_write_json(_dir(id).path_join("meta.json"), meta)
return id
## The world slot called exactly `id` (a server's world), made with `seed` if