summaryrefslogtreecommitdiff
path: root/drive_null.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2025-08-08 20:35:56 -0500
committercheapie <no-email-for-you@example.com>2025-08-08 20:35:56 -0500
commita3bf40bf1419c7366547781b195fdbe04e8365d8 (patch)
treed771fe8af5b4fddb63f98a1bb6bc1a79b07dc20d /drive_null.lua
parent17a87534f2af05b2826618f74f4a6c82493f881b (diff)
downloadcelevator-a3bf40bf1419c7366547781b195fdbe04e8365d8.tar
celevator-a3bf40bf1419c7366547781b195fdbe04e8365d8.tar.gz
celevator-a3bf40bf1419c7366547781b195fdbe04e8365d8.tar.bz2
celevator-a3bf40bf1419c7366547781b195fdbe04e8365d8.tar.xz
celevator-a3bf40bf1419c7366547781b195fdbe04e8365d8.zip
Minor (very minor) performance improvementsHEADmain
Diffstat (limited to 'drive_null.lua')
-rw-r--r--drive_null.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/drive_null.lua b/drive_null.lua
index 1a22e22..2664d47 100644
--- a/drive_null.lua
+++ b/drive_null.lua
@@ -3,6 +3,7 @@ celevator.drives.null = {
description = "Simulation only, no movement, for testing and demonstration",
nname = "celevator:drive_null",
soundhandles = {},
+ step_enabled = true, --Not a setting, is overwritten on globalstep, true here to check for running drives on startup
}
local function update_ui(pos)
@@ -90,6 +91,7 @@ minetest.register_node("celevator:drive_null",{
})
function celevator.drives.null.step(dtime)
+ if not celevator.drives.null.step_enabled then return end
local nulldrives_running = minetest.deserialize(celevator.storage:get_string("nulldrives_running")) or {}
local save = false
for i,hash in ipairs(nulldrives_running) do
@@ -146,6 +148,7 @@ function celevator.drives.null.step(dtime)
if save then
celevator.storage:set_string("nulldrives_running",minetest.serialize(nulldrives_running))
end
+ celevator.drives.null.step_enabled = save
end
minetest.register_globalstep(celevator.drives.null.step)
@@ -163,6 +166,7 @@ function celevator.drives.null.moveto(pos,target)
end
end
if not running then
+ celevator.drives.null.step_enabled = true
table.insert(nulldrives_running,hash)
celevator.storage:set_string("nulldrives_running",minetest.serialize(nulldrives_running))
end