Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
factorio.moon-logic: fix wire labels in debug=true output
  • Loading branch information
mk-fg committed Sep 2, 2020
1 parent dec7baf commit 298505c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
11 changes: 11 additions & 0 deletions factorio/Moon_Logic/README.md
Expand Up @@ -23,6 +23,17 @@ Fixing/maintaining these is much easier without few thousand lines of extra comp
"Moon Logic" Combinator is because it's programmed in Lua - "moon" in portugese (as Lua itself originates in Brazil).


--------------------

## Mod Options

- Red Wire Label - Lua environment name for in-game "red" circuit network values. Changes all labels in the GUIs as well.
- Green Wire Label - same as Red Wire Label, but for Green wire.

These can be useful when playing with other mods that change colors, for labels to match those.
Note that red/green input tables are always available in the environment too, for better code/snippet compability.


--------------------

## Known Issues
Expand Down
6 changes: 6 additions & 0 deletions factorio/Moon_Logic/changelog.txt
@@ -1,3 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 0.0.5
Date: 2020-09-02
Bugfixes:
- Fix wire labels not being used in debug=true logging output.

---------------------------------------------------------------------------------------------------
Version: 0.0.4
Date: 2020-09-02
Expand Down
1 change: 1 addition & 0 deletions factorio/Moon_Logic/config.lua
Expand Up @@ -5,6 +5,7 @@ local conf = {}
-- This changes descriptions in the guis as well.
conf.red_wire_name = 'red'
conf.green_wire_name = 'green'
function conf.get_wire_label(k) return conf[k..'_wire_name'] end

-- Interval between raising global alerts on lua errors, in ticks
conf.logic_alert_interval = 10 * 60
Expand Down
6 changes: 3 additions & 3 deletions factorio/Moon_Logic/control.lua
Expand Up @@ -115,12 +115,12 @@ end

local function cn_input_signal_get(wenv, k)
local v = cn_input_signal(wenv, defines.wire_type[wenv._wire], k) or 0
if wenv._debug then wenv._debug[wenv._wire..'['..k..']'] = v end
if wenv._debug then wenv._debug[conf.get_wire_label(wenv._wire)..'['..k..']'] = v end
return v
end
local function cn_input_signal_set(wenv, k, v)
error(( 'Attempt to set value on'..
' input: %s[%s] = %s' ):format(wenv._wire, k, v), 2)
' input: %s[%s] = %s' ):format(conf.get_wire_label(wenv._wire), k, v), 2)
end

local function cn_input_signal_iter(wenv)
Expand Down Expand Up @@ -275,7 +275,7 @@ local function update_signals_in_guis()
for k, color in pairs{red={r=1,g=0.3,b=0.3}, green={r=0.3,g=1,b=0.3}} do
for sig, v in pairs(cn_wire_signals(e, defines.wire_type[k])) do
cap = gui_flow.add{ type='label', name=k..'_'..sig,
caption=('[%s] %s = %s'):format(conf[k..'_wire_name'], sig, v) }
caption=('[%s] %s = %s'):format(conf.get_wire_label(k), sig, v) }
cap.style.font_color = color
end end
cap = format_mlc_err_msg(global.combinators[uid]) or ''
Expand Down
6 changes: 3 additions & 3 deletions factorio/Moon_Logic/gui.lua
Expand Up @@ -57,11 +57,11 @@ local function help_window_toggle(pn)
' game.print(...) -- prints string as in-game console output.',
' game.log(...) -- prints to factorio log.',
' ',
'To learn signal names, connect anything with signals to this combinator,',
' and their names will be printed as colored inputs on the right of the code window.',
' ',
'Presets (buttons with numbers):',
' Save and Load - left-click, Delete - right-click, Overwrite - right then left.',
' ',
'To learn signal names, connect anything with signals to this combinator,',
'and their names will be printed as colored inputs on the right of the code window.',
' ' }
for n, line in ipairs(lines) do gui.add{
type='label', name='line_'..n, direction='horizontal', caption=line } end
Expand Down
2 changes: 1 addition & 1 deletion factorio/Moon_Logic/info.json
@@ -1,6 +1,6 @@
{
"name": "Moon_Logic",
"version": "0.0.4",
"version": "0.0.5",
"factorio_version": "1.0",
"dependencies": ["base >= 1.0"],
"title": "Moon Logic",
Expand Down

0 comments on commit 298505c

Please sign in to comment.