aboutsummaryrefslogtreecommitdiff
path: root/overrides/mesecons_queue.lua
diff options
context:
space:
mode:
authorfluxionary <25628292+fluxionary@users.noreply.github.com>2023-01-25 23:25:46 -0800
committerGitHub <noreply@github.com>2023-01-26 08:25:46 +0100
commit18155b3ebedd24fba5c3cbf109063f64f882d8a6 (patch)
tree5d5d67f8108aa963bb229ee3d282f0eb5a18ca1d /overrides/mesecons_queue.lua
parent675e1e1943598893acf3d652caca18b0193746d9 (diff)
downloadmesecons_debug-18155b3ebedd24fba5c3cbf109063f64f882d8a6.tar.gz
mesecons_debug-18155b3ebedd24fba5c3cbf109063f64f882d8a6.zip
some more updates (#9)
* 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 * update lag even when mesecons isn't active * update lag even when mesecons isn't active * tweak default settings * move hud so it doesn't interfere w/ areas * tweak default settings * put the HUD in a place which doesn't conflict w/ areas mod * ensure that actions have a valid position to avoid a crash * stylua * make sure we don't update the wrong HUD * spaces not tabs Co-authored-by: AliasAlreadyTaken <aliasalreadytaken@noreply.example.org3>
Diffstat (limited to 'overrides/mesecons_queue.lua')
-rw-r--r--overrides/mesecons_queue.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/overrides/mesecons_queue.lua b/overrides/mesecons_queue.lua
index 4375d7d..d14b30c 100644
--- a/overrides/mesecons_queue.lua
+++ b/overrides/mesecons_queue.lua
@@ -1,8 +1,10 @@
local penalty_mapblock_disabled = mesecons_debug.settings.penalty_mapblock_disabled
-mesecons_debug.settings._subscribe_for_modification("penalty_mapblock_disabled",
- function(value) penalty_mapblock_disabled = value end)
+mesecons_debug.settings._subscribe_for_modification("penalty_mapblock_disabled", function(value)
+ penalty_mapblock_disabled = value
+end)
+
+local check_pos = mesecons_debug.check_pos
--- execute()
local old_execute = mesecon.queue.execute
mesecon.queue.execute = function(self, action)
if not mesecons_debug.enabled then
@@ -11,6 +13,11 @@ mesecon.queue.execute = function(self, action)
return
end
+ if not check_pos(action.pos) then
+ mesecons_debug.log("error", "mesecons action has an invalid position and cannot be processed %s", dump(action))
+ return
+ end
+
local ctx = mesecons_debug.get_context(action.pos)
if ctx.whitelisted then
return old_execute(self, action)
@@ -22,18 +29,16 @@ mesecon.queue.execute = function(self, action)
mesecons_debug.total_micros = mesecons_debug.total_micros + micros
ctx.micros = ctx.micros + micros
- ctx.mtime = t0 -- modification time
+ ctx.mtime = t0 -- modification time
return rv
end
-
-- add_action()
local old_add_action = mesecon.queue.add_action
mesecon.queue.add_action = function(self, pos, func, params, time, overwritecheck, priority)
if not mesecons_debug.enabled then
return old_add_action(self, pos, func, params, time, overwritecheck, priority)
-
elseif not mesecons_debug.mesecons_enabled then
return
end