M2.3: the shared world (trees, pickups, pieces, chests, fires, doors, graves, clock on the server)
This commit is contained in:
@@ -58,6 +58,22 @@ func create_world(world_name: String, seed: int) -> String:
|
||||
})
|
||||
return id
|
||||
|
||||
## The world slot called exactly `id` (a server's world), made with `seed` if
|
||||
## it doesn't exist yet. An existing world keeps its own seed.
|
||||
func open_or_create(id: String, seed: int) -> String:
|
||||
if not read_meta(id).is_empty():
|
||||
var had := int(read_meta(id).get("seed", seed))
|
||||
if had != seed:
|
||||
print("Saves: world '%s' was made with seed %d, so it keeps it (the config says %d)" % [id, had, seed])
|
||||
return id
|
||||
DirAccess.make_dir_recursive_absolute(_dir(id))
|
||||
var now := Time.get_unix_time_from_system()
|
||||
_write_json(_dir(id).path_join("meta.json"), {
|
||||
"name": id, "seed": seed, "created": now, "last_played": now,
|
||||
"play_time": 0.0, "version": VERSION,
|
||||
})
|
||||
return id
|
||||
|
||||
func delete_world(id: String) -> void:
|
||||
var dir := _dir(id)
|
||||
var d := DirAccess.open(dir)
|
||||
|
||||
Reference in New Issue
Block a user