mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-08 20:08:00 -06:00
Experimental 1.2.2 (#21)
---------------------------------------------------------------------------------------------------
Version: 1.2.2
Date: 2022-12-29
Features:
- Added a station combinator setting to enable or disable the inactivity condition in a train's orders, disabled by default (but not in <=1.2.1 worlds)
- Added a depot combinator setting to enable depot bypass, enabled by default
- Added a depot combinator setting to force trains to park at the same depot, enabled by default
- Added network "each" for depots
- Added a map setting to modify the default locked slots per cargo wagon value
- Added a map setting to modify the default priority value
- Added a map setting to allow trains with cargo at depots, disabled by default
Changes:
- Inverted the sign of combinator outputs, a map setting has been added to maintain backwards compatibility with <=1.2.1 worlds
- Overhauled the wagon control combinator algorithm to spread items out between cargo wagons
- Trains with cargo held in the depot now check if they have been emptied and reset when they have
- Cargo capacity is now prioritized over distance when choosing trains
- Increased the default request threshold to 2000
- Improved English localization
Bugfixes:
- Fixed a bug where trains with cargo sometimes weren't getting held at depots
- Fixed a crash caused by changing a station combinator to the "each" network during a bad tick
- Fixed a crash when changing a refueler away from network each
- Multiple rare bugs and crashes relating to wagon control combinators are fixed
- Fixed a bug with refueler direct orders not being applied after moving through a space elevator
- Fixed a bug where filtered slots sometimes weren't being removed
---------------------------------------------------------------------------------------------------
This commit is contained in:
@@ -26,25 +26,37 @@ STATUS_NAMES[defines.entity_status.disabled_by_script] = "entity-status.disabled
|
||||
STATUS_NAMES[defines.entity_status.marked_for_deconstruction] = "entity-status.marked-for-deconstruction"
|
||||
STATUS_NAMES_DEFAULT = "entity-status.disabled"
|
||||
|
||||
|
||||
local bit_extract = bit32.extract
|
||||
local function setting(bits, n)
|
||||
return bit_extract(bits, n) > 0
|
||||
end
|
||||
local function setting_flip(bits, n)
|
||||
return bit_extract(bits, n) == 0
|
||||
end
|
||||
|
||||
|
||||
---@param main_window LuaGuiElement
|
||||
---@param selected_index int
|
||||
local function set_visibility(main_window, selected_index)
|
||||
local uses_network = selected_index == 1 or selected_index == 2 or selected_index == 3
|
||||
local uses_allow_list = selected_index == 1 or selected_index == 3
|
||||
local is_station = selected_index == 1
|
||||
local is_depot = selected_index == 2
|
||||
local uses_network = is_station or is_depot or selected_index == 3
|
||||
local uses_allow_list = is_station or selected_index == 3
|
||||
|
||||
local vflow = main_window.frame.vflow--[[@as LuaGuiElement]]
|
||||
local top_flow = vflow.top--[[@as LuaGuiElement]]
|
||||
local bottom_flow = vflow.bottom--[[@as LuaGuiElement]]
|
||||
local right_flow = bottom_flow.right--[[@as LuaGuiElement]]
|
||||
local first_settings = bottom_flow.first--[[@as LuaGuiElement]]
|
||||
local depot_settings = bottom_flow.depot--[[@as LuaGuiElement]]
|
||||
|
||||
top_flow.is_pr_switch.visible = is_station
|
||||
vflow.network_label.visible = uses_network
|
||||
bottom_flow.network.visible = uses_network
|
||||
right_flow.allow_list.visible = uses_allow_list
|
||||
--right_flow.allow_list_label.visible = uses_allow_list
|
||||
right_flow.is_stack.visible = is_station
|
||||
--right_flow.is_stack_label.visible = is_station
|
||||
first_settings.allow_list.visible = uses_allow_list
|
||||
first_settings.is_stack.visible = is_station
|
||||
bottom_flow.enable_inactive.visible = is_station
|
||||
depot_settings.visible = is_depot
|
||||
end
|
||||
|
||||
---@param comb LuaEntity
|
||||
@@ -53,7 +65,7 @@ function gui_opened(comb, player)
|
||||
combinator_update(global, comb, true)
|
||||
|
||||
local rootgui = player.gui.screen
|
||||
local selected_index, signal, switch_state, allow_list, is_stack = get_comb_gui_settings(comb)
|
||||
local selected_index, signal, switch_state, bits = get_comb_gui_settings(comb)
|
||||
|
||||
local window = flib_gui.build(rootgui, {
|
||||
{type="frame", direction="vertical", ref={"main_window"}, name=COMBINATOR_NAME, children={
|
||||
@@ -69,8 +81,8 @@ function gui_opened(comb, player)
|
||||
{type="flow", name="vflow", direction="vertical", style_mods={horizontal_align="left"}, children={
|
||||
--status
|
||||
{type="flow", style="status_flow", direction="horizontal", style_mods={vertical_align="center", horizontally_stretchable=true, bottom_padding=4}, children={
|
||||
{type="sprite", sprite=STATUS_SPRITES[comb.status] or STATUS_SPRITES_DEFAULT, style="status_image", ref={"status_icon"}, style_mods={stretch_image_to_widget_size=true}},
|
||||
{type="label", caption={STATUS_NAMES[comb.status] or STATUS_NAMES_DEFAULT}, ref={"status_label"}}
|
||||
{type="sprite", sprite=STATUS_SPRITES[comb.status] or STATUS_SPRITES_DEFAULT, style="status_image", style_mods={stretch_image_to_widget_size=true}},
|
||||
{type="label", caption={STATUS_NAMES[comb.status] or STATUS_NAMES_DEFAULT}}
|
||||
}},
|
||||
--preview
|
||||
{type="frame", style="deep_frame_in_shallow_frame", style_mods={minimal_width=0, horizontally_stretchable=true, padding=0}, children={
|
||||
@@ -94,25 +106,45 @@ function gui_opened(comb, player)
|
||||
}},
|
||||
---choose-elem-button
|
||||
{type="line", style_mods={top_padding=10}},
|
||||
{type="label", name="network_label", ref={"network_label"}, style="heading_3_label", caption={"cybersyn-gui.network"}, style_mods={top_padding=8}},
|
||||
{type="flow", name="bottom", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="choose-elem-button", name="network", style="slot_button_in_shallow_frame", ref={"network"}, elem_type="signal", tooltip={"cybersyn-gui.network-tooltip"}, signal=signal, style_mods={bottom_margin=1, right_margin=6, top_margin=2}, actions={
|
||||
{type="label", name="network_label", style="heading_3_label", caption={"cybersyn-gui.network"}, style_mods={top_padding=8}},
|
||||
{type="flow", name="bottom", direction="horizontal", style_mods={vertical_align="top"}, children={
|
||||
{type="choose-elem-button", name="network", style="slot_button_in_shallow_frame", elem_type="signal", tooltip={"cybersyn-gui.network-tooltip"}, signal=signal, style_mods={bottom_margin=1, right_margin=6, top_margin=2}, actions={
|
||||
on_elem_changed={"choose-elem-button", comb.unit_number}
|
||||
}},
|
||||
{type="flow", name="right", direction="vertical", style_mods={horizontal_align="left"}, children={
|
||||
{type="flow", name="allow_list", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="checkbox", name="allow_list", ref={"allow_list"}, state=allow_list, tooltip={"cybersyn-gui.allow-list-tooltip"}, actions={
|
||||
on_checked_state_changed={"allow_list", comb.unit_number}
|
||||
{type="flow", name="depot", direction="vertical", style_mods={horizontal_align="left"}, children={
|
||||
{type="flow", name="use_any_depot", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="checkbox", name="use_same_depot", state=setting_flip(bits, SETTING_USE_ANY_DEPOT), tooltip={"cybersyn-gui.use-same-depot-tooltip"}, actions={
|
||||
on_checked_state_changed={"setting-flip", comb.unit_number, SETTING_USE_ANY_DEPOT}
|
||||
}},
|
||||
{type="label", name="allow_list_label", style_mods={left_padding=3}, ref={"allow_list_label"}, caption={"cybersyn-gui.allow-list-description"}},
|
||||
{type="label", name="use_same_depot_label", style_mods={left_padding=3}, caption={"cybersyn-gui.use-same-depot-description"}},
|
||||
}},
|
||||
{type="flow", name="depot_bypass", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="checkbox", name="depot_bypass", state=setting_flip(bits, SETTING_DISABLE_DEPOT_BYPASS), tooltip={"cybersyn-gui.depot-bypass-tooltip"}, actions={
|
||||
on_checked_state_changed={"setting-flip", comb.unit_number, SETTING_DISABLE_DEPOT_BYPASS}
|
||||
}},
|
||||
{type="label", name="depot_bypass_label", style_mods={left_padding=3}, caption={"cybersyn-gui.depot-bypass-description"}},
|
||||
}},
|
||||
}},
|
||||
{type="flow", name="first", direction="vertical", style_mods={horizontal_align="left", right_margin=8}, children={
|
||||
{type="flow", name="allow_list", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="checkbox", name="allow_list", state=setting_flip(bits, SETTING_DISABLE_ALLOW_LIST), tooltip={"cybersyn-gui.allow-list-tooltip"}, actions={
|
||||
on_checked_state_changed={"setting-flip", comb.unit_number, SETTING_DISABLE_ALLOW_LIST}
|
||||
}},
|
||||
{type="label", name="allow_list_label", style_mods={left_padding=3}, caption={"cybersyn-gui.allow-list-description"}},
|
||||
}},
|
||||
{type="flow", name="is_stack", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="checkbox", name="is_stack", ref={"is_stack"}, state=is_stack, tooltip={"cybersyn-gui.is-stack-tooltip"}, actions={
|
||||
on_checked_state_changed={"is_stack", comb.unit_number}
|
||||
{type="checkbox", name="is_stack", state=setting(bits, SETTING_IS_STACK), tooltip={"cybersyn-gui.is-stack-tooltip"}, actions={
|
||||
on_checked_state_changed={"setting", comb.unit_number, SETTING_IS_STACK}
|
||||
}},
|
||||
{type="label", name="is_stack_label", style_mods={left_padding=3}, ref={"is_stack_label"}, caption={"cybersyn-gui.is-stack-description"}},
|
||||
{type="label", name="is_stack_label", style_mods={left_padding=3}, caption={"cybersyn-gui.is-stack-description"}},
|
||||
}},
|
||||
}}
|
||||
}},
|
||||
{type="flow", name="enable_inactive", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="checkbox", name="enable_inactive", state=setting(bits, SETTING_ENABLE_INACTIVE), tooltip={"cybersyn-gui.enable-inactive-tooltip"}, actions={
|
||||
on_checked_state_changed={"setting", comb.unit_number, SETTING_ENABLE_INACTIVE}
|
||||
}},
|
||||
{type="label", name="enable_inactive_label", style_mods={left_padding=3}, caption={"cybersyn-gui.enable-inactive-description"}},
|
||||
}},
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
@@ -197,38 +229,30 @@ function register_gui_actions()
|
||||
local comb = global.to_comb[msg[2]]
|
||||
if not comb or not comb.valid then return end
|
||||
|
||||
local param = get_comb_params(comb)
|
||||
|
||||
local signal = element.elem_value
|
||||
if signal and (signal.name == "signal-everything" or signal.name == "signal-anything" or signal.name == "signal-each") then
|
||||
if param.operation == MODE_PRIMARY_IO or param.operation == MODE_PRIMARY_IO_ACTIVE or param.operation == MODE_PRIMARY_IO_FAILED_REQUEST or param.operation == MODE_REFUELER then
|
||||
signal.name = NETWORK_EACH
|
||||
else
|
||||
signal = nil
|
||||
end
|
||||
signal.name = NETWORK_EACH
|
||||
element.elem_value = signal
|
||||
end
|
||||
set_comb_network_name(comb, signal)
|
||||
|
||||
combinator_update(global, comb)
|
||||
elseif msg[1] == "allow_list" then
|
||||
elseif msg[1] == "setting" then
|
||||
local element = event.element
|
||||
if not element then return end
|
||||
local comb = global.to_comb[msg[2]]
|
||||
if not comb or not comb.valid then return end
|
||||
|
||||
local allows_all_trains = not element.state
|
||||
set_comb_allows_all_trains(comb, allows_all_trains)
|
||||
set_comb_setting(comb, msg[3], element.state)
|
||||
|
||||
combinator_update(global, comb)
|
||||
elseif msg[1] == "is_stack" then
|
||||
elseif msg[1] == "setting-flip" then
|
||||
local element = event.element
|
||||
if not element then return end
|
||||
local comb = global.to_comb[msg[2]]
|
||||
if not comb or not comb.valid then return end
|
||||
|
||||
local is_stack = element.state
|
||||
set_comb_is_stack(comb, is_stack)
|
||||
set_comb_setting(comb, msg[3], not element.state)
|
||||
|
||||
combinator_update(global, comb)
|
||||
elseif msg[1] == "is_pr_switch" then
|
||||
|
||||
Reference in New Issue
Block a user