Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
factorio.moon-logic: minor debug=true bugfix
  • Loading branch information
mk-fg committed Sep 4, 2020
1 parent 4dfa068 commit 782589e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
8 changes: 7 additions & 1 deletion factorio/Moon_Logic/changelog.txt
@@ -1,8 +1,14 @@
---------------------------------------------------------------------------------------------------
Version: 0.0.10
Date: 2020-09-04
Bugfixes:
- Fix debug=true log not mentioning all keys if pairs() was run on inputs.

---------------------------------------------------------------------------------------------------
Version: 0.0.9
Date: 2020-09-04
Changes:
- Changed logging stuff to use log() instead of print() - guess latter doesn't actually ends up in log.
- Change logging stuff to use log() instead of print() - guess latter doesn't actually ends up in log.

---------------------------------------------------------------------------------------------------
Version: 0.0.8
Expand Down
19 changes: 13 additions & 6 deletions factorio/Moon_Logic/control.lua
Expand Up @@ -106,9 +106,11 @@ local function cn_wire_signals(e, wire_type, output)
end

local function cn_input_signal(wenv, wire_type, k)
if wenv._cache_tick == game.tick then return wenv._cache[k] end
local signals = cn_wire_signals(wenv._e, wire_type, wenv._out)
wenv._cache, wenv._cache_tick = signals, game.tick
local signals = wenv._cache
if wenv._cache_tick ~= game.tick then
signals = cn_wire_signals(wenv._e, wire_type, wenv._out)
wenv._cache, wenv._cache_tick = signals, game.tick
end
if k then signals = signals[k] end
return signals
end
Expand All @@ -124,13 +126,18 @@ local function cn_input_signal_set(wenv, k, v)
end

local function cn_input_signal_iter(wenv)
return cn_input_signal(wenv, defines.wire_type[wenv._wire])
local signals = cn_input_signal(wenv, defines.wire_type[wenv._wire])
if wenv._debug then
local sig_fmt = conf.get_wire_label(wenv._wire)..'[%s]'
for sig, v in pairs(signals) do wenv._debug[sig_fmt:format(sig)] = v or 0 end
end
return signals
end

local function cn_output_table_value(out, k) return rawget(out, k) or 0 end
local function cn_output_table_update(out, update)
-- Note: validation for sig_names/values is done when output table is used later
for sig_name, v in pairs(update) do out[sig_name] = v end
for sig, v in pairs(update) do out[sig] = v end
end


Expand Down Expand Up @@ -349,7 +356,7 @@ function run_moon_logic_tick(mlc, mlc_env, tick)
dbg('env-after :: %s', serpent.line(mlc.vars))
dbg('out-after :: %s', serpent.line(mlc_env._out)) end

local delay = tonumber(mlc.vars.delay or 1) or 1
local delay = tonumber(mlc.vars.delay) or 1
mlc.next_tick = tick + delay

for sig, v in pairs(mlc_env._out) do
Expand Down
2 changes: 1 addition & 1 deletion factorio/Moon_Logic/info.json
@@ -1,6 +1,6 @@
{
"name": "Moon_Logic",
"version": "0.0.9",
"version": "0.0.10",
"factorio_version": "1.0",
"dependencies": ["base >= 1.0"],
"title": "Moon Logic",
Expand Down

0 comments on commit 782589e

Please sign in to comment.