aboutsummaryrefslogtreecommitdiff
path: root/doc/lua_api.txt
diff options
context:
space:
mode:
authorAuke Kok <sofar@foo-projects.org>2016-03-06 12:02:21 -0800
committerest31 <MTest31@outlook.com>2016-03-09 01:45:23 +0100
commit4e59fcf5c1e40dee764317a1190dceadc3a77829 (patch)
treebe216e4eb402e8529ff7a001839077f22c74d8ac /doc/lua_api.txt
parent3ce6642a26d43fd368c24cdfc5460557258fb44f (diff)
downloadminetest-4e59fcf5c1e40dee764317a1190dceadc3a77829.tar.gz
minetest-4e59fcf5c1e40dee764317a1190dceadc3a77829.tar.bz2
minetest-4e59fcf5c1e40dee764317a1190dceadc3a77829.zip
Add consistent monotonic day counter - get_day_count()
I've written several experimental bits of code that revolve around the need for a consistent calendar, but implementing one is extremely hard in mods due to time changes and mods overriding core.get_timeofday(), which will conflict. The second part of the problem is that doing this from a mod requires constant maintenance of a settings file. An implementation in core is trivial, however, and solves all of these problems at virtually no cost: No extra branches in server steps, and a single branch when minetest.set_time_of_day(), which is entirely reasonable. We store the day_count value in env_meta.txt. The use case is obvious: This change allows mods to create an actual virtual calendar, or properly account for seasonal changes, etc.. We add a "/days" chatcommand that displays the current day count. No permissions are needed. It can only retrieve the day count, not modify it.
Diffstat (limited to 'doc/lua_api.txt')
-rw-r--r--doc/lua_api.txt2
1 files changed, 2 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 65af51578..e2ab65ddc 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1998,6 +1998,8 @@ and `minetest.auth_reload` call the authetification handler.
* `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
* `minetest.get_timeofday()`
* `minetest.get_gametime()`: returns the time, in seconds, since the world was created
+* `minetest.get_day_count()`: returns number days elapsed since world was created,
+ * accounting for time changes.
* `minetest.find_node_near(pos, radius, nodenames)`: returns pos or `nil`
* `radius`: using a maximum metric
* `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`