M mods/falling_nodes/init.lua => mods/falling_nodes/init.lua +3 -10
@@ 1,16 1,9 @@
falling_nodes = {}
local modname = "falling_nodes"
-local old_abm_interval = minetest.settings:get("abm_interval")
-local old_abm_time_budget = minetest.settings:get("abm_time_budget")
--- NOTE: if the server crashes, the settings won't be restored
-minetest.register_on_shutdown(function()
- minetest.settings:set("abm_interval", old_abm_interval)
- minetest.settings:set("abm_time_budget", old_abm_time_budget)
-end)
--- TODO make them configurable
-minetest.settings:set("abm_interval", "0.1")
-minetest.settings:set("abm_time_budget", "0.9")
+
+-- NOTE: Must be first because many node values are based on the settings
+dofile(minetest.get_modpath(modname) .. "/temporary_settings.lua")
dofile(minetest.get_modpath(modname) .. "/states_of_matter.lua")
dofile(minetest.get_modpath(modname) .. "/explosions.lua")
A mods/falling_nodes/settingtypes.txt => mods/falling_nodes/settingtypes.txt +12 -0
@@ 0,0 1,12 @@
+[Simulation]
+
+# Pauses the simulation.
+# If set to true, nodes will not move or interact with each other until
+# you set this back to false and reload the world.
+falling_nodes_pause (Pause simulation) bool false
+
+[*Advanced]
+
+falling_nodes_abm_interval (ABM interval) float 0.1 0.0
+falling_nodes_abm_time_budget (ABM time budget) float 0.9 0.1 0.9
+falling_nodes_nodetimer_interval (NodeTimer interval) float 0.1 0.0
A mods/falling_nodes/temporary_settings.lua => mods/falling_nodes/temporary_settings.lua +24 -0
@@ 0,0 1,24 @@
+local s = minetest.settings
+
+-- MAYBE Create a temporary settings manager (monoid or overriding stack).
+-- It can be its own mod.
+
+local old_abm_interval = s:get("abm_interval")
+local old_abm_time_budget = s:get("abm_time_budget")
+local old_nodetimer_interval = s:get("nodetimer_interval")
+
+-- NOTE: if the server crashes, the settings won't be restored
+minetest.register_on_shutdown(function()
+ s:set("abm_interval", old_abm_interval)
+ s:set("abm_time_budget", old_abm_time_budget)
+ s:set("nodetimer_interval", old_nodetimer_interval)
+end)
+
+if s:get("falling_nodes_pause") == "true" then
+ s:set("abm_interval", "1000000")
+ s:set("nodetimer_interval", "1000000")
+else
+ s:set("abm_interval", s:get("falling_nodes_abm_interval") or 0.1)
+ s:set("abm_time_budget", s:get("falling_nodes_abm_time_budget") or 0.9)
+ s:set("nodetimer_interval", s:get("falling_nodes_nodetimer_interval") or 0.1)
+end
A settingtypes.txt => settingtypes.txt +1 -0
@@ 0,0 1,1 @@
+mods/falling_nodes/settingtypes.txt<
\ No newline at end of file