aboutsummaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
authorfluxionary <25628292+fluxionary@users.noreply.github.com>2022-02-13 06:54:41 -0800
committerGitHub <noreply@github.com>2022-02-13 15:54:41 +0100
commit2651262fa3134415f349f63840c89486fabd9063 (patch)
tree3fa7f2ac228e662b4e9bc8071acc2f0650c44e65 /util.lua
parent1a41379e1d7ae69347f0e6ee6a997234f7590793 (diff)
downloadmesecons_debug-2651262fa3134415f349f63840c89486fabd9063.tar.gz
mesecons_debug-2651262fa3134415f349f63840c89486fabd9063.zip
rework mesecons debug to be more flexible (#7)
* add proper settings (untested) * more constants -> settings * normalize whitespace between code files * refactor globalsteps in order to simplify logic * minor refactoring * rename file * use mod_storage for persistent data; optimize context initialization * refactoring (moving files around) * rewrite penalty * add settings; document; allow changing while game is running * add command to update settings * update init after splitting commands into files * fix bugs; add debugging tools; too much for one commit... * fix whitelist conversion * add adjustable blinky plant to timer overrides * add some more mesecons nodes with repeating timers * resolve luacheck warnings * tweak hud * Update documentation; parameterize more things; refactor some logic for readability
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/util.lua b/util.lua
new file mode 100644
index 0000000..1e45914
--- /dev/null
+++ b/util.lua
@@ -0,0 +1,21 @@
+function mesecons_debug.get_blockpos(pos)
+ return {
+ x = math.floor(pos.x / 16),
+ y = math.floor(pos.y / 16),
+ z = math.floor(pos.z / 16)
+ }
+end
+
+function mesecons_debug.hashpos(pos)
+ return minetest.hash_node_position({
+ x = math.floor(pos.x / 16),
+ y = math.floor(pos.y / 16),
+ z = math.floor(pos.z / 16)
+ })
+end
+
+
+function mesecons_debug.wait(n)
+ local wait_until = minetest.get_us_time() + n
+ while minetest.get_us_time() < wait_until do end
+end