mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-10 16:08:13 -06:00
added a display state for provide lock
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
"Lua.runtime.special": {
|
"Lua.runtime.special": {
|
||||||
"__object_name": "type"
|
"__object_name": "type"
|
||||||
},
|
},
|
||||||
|
"Lua.workspace.checkThirdParty": false,
|
||||||
"Lua.workspace.library": [
|
"Lua.workspace.library": [
|
||||||
"~/.steam/steam/steamapps/common/Factorio/data",
|
"~/.steam/steam/steamapps/common/Factorio/data",
|
||||||
"~/.steam/steam/steamapps/common/Factorio/data/core/lualib",
|
"~/.steam/steam/steamapps/common/Factorio/data/core/lualib",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Version: 1.1.8
|
|||||||
Date: 2022-12-22
|
Date: 2022-12-22
|
||||||
Changes:
|
Changes:
|
||||||
- Fixed depot priority
|
- Fixed depot priority
|
||||||
- Prioritized a train's distance from the provide station over train cargo capacity
|
- Prioritized a train's distance from the provide station over the train's cargo capacity
|
||||||
- Forced provide stations to wait until they can service the highest priority request station
|
- Forced provide stations to wait until they can service the highest priority request station
|
||||||
- Added more detailed missing train alerts
|
- Added more detailed missing train alerts
|
||||||
- Provide stations now override request thresholds with the per-item thresholds set by their station info combinator
|
- Provide stations now override request thresholds with the per-item thresholds set by their station info combinator
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ function remove_manifest(map_data, station, manifest, sign)
|
|||||||
end
|
end
|
||||||
set_comb2(map_data, station)
|
set_comb2(map_data, station)
|
||||||
station.deliveries_total = station.deliveries_total - 1
|
station.deliveries_total = station.deliveries_total - 1
|
||||||
if station.deliveries_total == 0 and station.display_state >= 2 then
|
if station.deliveries_total == 0 and band(station.display_state, 4) > 0 then
|
||||||
station.display_state = station.display_state - 2
|
station.display_state = station.display_state - 4
|
||||||
update_display(map_data, station)
|
update_display(map_data, station)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -81,12 +81,12 @@ function create_delivery(map_data, r_station_id, p_station_id, train_id, manifes
|
|||||||
set_comb2(map_data, p_station)
|
set_comb2(map_data, p_station)
|
||||||
set_comb2(map_data, r_station)
|
set_comb2(map_data, r_station)
|
||||||
|
|
||||||
if p_station.display_state < 2 then
|
if band(p_station.display_state, 4) == 0 then
|
||||||
p_station.display_state = 2
|
p_station.display_state = p_station.display_state + 4
|
||||||
update_display(map_data, p_station)
|
update_display(map_data, p_station)
|
||||||
end
|
end
|
||||||
if r_station.display_state < 2 then
|
if band(r_station.display_state, 4) == 0 then
|
||||||
r_station.display_state = 2
|
r_station.display_state = r_station.display_state + 4
|
||||||
update_display(map_data, r_station)
|
update_display(map_data, r_station)
|
||||||
end
|
end
|
||||||
interface_raise_train_status_changed(train_id, old_status, STATUS_TO_P)
|
interface_raise_train_status_changed(train_id, old_status, STATUS_TO_P)
|
||||||
@@ -225,7 +225,7 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
else
|
else
|
||||||
for i, id in ipairs(r_stations) do
|
for i, id in ipairs(r_stations) do
|
||||||
local station = stations[id]
|
local station = stations[id]
|
||||||
if station and station.display_state%2 == 0 then
|
if station and band(station.display_state, 1) == 0 then
|
||||||
station.display_state = station.display_state + 1
|
station.display_state = station.display_state + 1
|
||||||
update_display(map_data, station)
|
update_display(map_data, station)
|
||||||
end
|
end
|
||||||
@@ -271,7 +271,7 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
if not r_station_i then
|
if not r_station_i then
|
||||||
for _, id in ipairs(r_stations) do
|
for _, id in ipairs(r_stations) do
|
||||||
local station = stations[id]
|
local station = stations[id]
|
||||||
if station and station.display_state%2 == 0 then
|
if station and band(station.display_state, 1) == 0 then
|
||||||
station.display_state = station.display_state + 1
|
station.display_state = station.display_state + 1
|
||||||
update_display(map_data, station)
|
update_display(map_data, station)
|
||||||
end
|
end
|
||||||
@@ -405,7 +405,16 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
--this p station should have serviced the current r station, lock it so it can't serve any others
|
--this p station should have serviced the current r station, lock it so it can't serve any others
|
||||||
--this will lock stations even when the r station manages to find a p station, this not a problem because all stations will be unlocked before it could be an issue
|
--this will lock stations even when the r station manages to find a p station, this not a problem because all stations will be unlocked before it could be an issue
|
||||||
table_remove(p_stations, j)
|
table_remove(p_stations, j)
|
||||||
|
if band(p_station.display_state, 2) == 0 then
|
||||||
|
p_station.display_state = p_station.display_state + 2
|
||||||
|
update_display(map_data, p_station)
|
||||||
|
end
|
||||||
goto p_continue_remove
|
goto p_continue_remove
|
||||||
|
else
|
||||||
|
if band(p_station.display_state, 2) == 1 then
|
||||||
|
p_station.display_state = p_station.display_state - 2
|
||||||
|
update_display(map_data, p_station)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
p_prior = p_station.priority
|
p_prior = p_station.priority
|
||||||
@@ -445,7 +454,7 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
elseif correctness == 4 then
|
elseif correctness == 4 then
|
||||||
send_alert_no_train_matches_p_layout(r_station.entity_stop, closest_to_correct_p_station.entity_stop)
|
send_alert_no_train_matches_p_layout(r_station.entity_stop, closest_to_correct_p_station.entity_stop)
|
||||||
end
|
end
|
||||||
if r_station.display_state%2 == 0 then
|
if band(r_station.display_state, 1) == 0 then
|
||||||
r_station.display_state = r_station.display_state + 1
|
r_station.display_state = r_station.display_state + 1
|
||||||
update_display(map_data, r_station)
|
update_display(map_data, r_station)
|
||||||
end
|
end
|
||||||
@@ -602,7 +611,7 @@ local function tick_poll_station(map_data, mod_settings)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if is_requesting_nothing and station.display_state%2 == 1 then
|
if is_requesting_nothing and band(station.display_state, 1) == 1 then
|
||||||
station.display_state = station.display_state - 1
|
station.display_state = station.display_state - 1
|
||||||
update_display(map_data, station)
|
update_display(map_data, station)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -313,22 +313,7 @@ function set_refueler_from_comb(map_data, mod_settings, id)
|
|||||||
local params = get_comb_params(refueler.entity_comb)
|
local params = get_comb_params(refueler.entity_comb)
|
||||||
local bits = params.second_constant or 0
|
local bits = params.second_constant or 0
|
||||||
local signal = params.first_signal
|
local signal = params.first_signal
|
||||||
|
local old_network = refueler.network_name
|
||||||
local f, a
|
|
||||||
if refueler.network_name == NETWORK_EVERY then
|
|
||||||
f, a = pairs(refueler.network_flag--[[@as {[string]: int}]])
|
|
||||||
else
|
|
||||||
f, a = once, refueler.network_name
|
|
||||||
end
|
|
||||||
for network_name, _ in f, a do
|
|
||||||
local network = map_data.to_refuelers[network_name]
|
|
||||||
if network then
|
|
||||||
network[id] = nil
|
|
||||||
if next(network) == nil then
|
|
||||||
map_data.to_refuelers[network_name] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
refueler.network_name = signal and signal.name or nil
|
refueler.network_name = signal and signal.name or nil
|
||||||
refueler.allows_all_trains = bit_extract(bits, 2) > 0
|
refueler.allows_all_trains = bit_extract(bits, 2) > 0
|
||||||
@@ -343,29 +328,50 @@ function set_refueler_from_comb(map_data, mod_settings, id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local signals = refueler.entity_comb.get_merged_signals(DEFINES_COMBINATOR_INPUT)
|
local signals = refueler.entity_comb.get_merged_signals(DEFINES_COMBINATOR_INPUT)
|
||||||
if not signals then return end
|
if signals then
|
||||||
for k, v in pairs(signals) do
|
for k, v in pairs(signals) do
|
||||||
local item_name = v.signal.name
|
local item_name = v.signal.name
|
||||||
local item_type = v.signal.type
|
local item_type = v.signal.type
|
||||||
local item_count = v.count
|
local item_count = v.count
|
||||||
if item_name then
|
if item_name then
|
||||||
if item_type == "virtual" then
|
if item_type == "virtual" then
|
||||||
if item_name == SIGNAL_PRIORITY then
|
if item_name == SIGNAL_PRIORITY then
|
||||||
refueler.priority = item_count
|
refueler.priority = item_count
|
||||||
elseif refueler.network_name == NETWORK_EVERY then
|
elseif refueler.network_name == NETWORK_EVERY then
|
||||||
refueler.network_flag[item_name] = item_count
|
refueler.network_flag[item_name] = item_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if item_name == refueler.network_name then
|
||||||
|
refueler.network_flag = item_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if item_name == refueler.network_name then
|
end
|
||||||
refueler.network_flag = item_count
|
end
|
||||||
|
|
||||||
|
local f, a
|
||||||
|
if old_network == NETWORK_EVERY then
|
||||||
|
f, a = pairs(refueler.network_flag--[[@as {[string]: int}]])
|
||||||
|
elseif old_network ~= refueler.network_name then
|
||||||
|
f, a = once, old_network
|
||||||
|
else
|
||||||
|
f, a = once, nil
|
||||||
|
end
|
||||||
|
for network_name, _ in f, a do
|
||||||
|
local network = map_data.to_refuelers[network_name]
|
||||||
|
if network then
|
||||||
|
network[id] = nil
|
||||||
|
if next(network) == nil then
|
||||||
|
map_data.to_refuelers[network_name] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if refueler.network_name == NETWORK_EVERY then
|
if refueler.network_name == NETWORK_EVERY then
|
||||||
f, a = pairs(refueler.network_flag--[[@as {[string]: int}]])
|
f, a = pairs(refueler.network_flag--[[@as {[string]: int}]])
|
||||||
else
|
elseif old_network ~= refueler.network_name then
|
||||||
f, a = once, refueler.network_name
|
f, a = once, refueler.network_name
|
||||||
|
else
|
||||||
|
f, a = once, nil
|
||||||
end
|
end
|
||||||
for network_name, _ in f, a do
|
for network_name, _ in f, a do
|
||||||
local network = map_data.to_refuelers[network_name]
|
local network = map_data.to_refuelers[network_name]
|
||||||
@@ -386,9 +392,9 @@ function update_display(map_data, station)
|
|||||||
local params = control.parameters
|
local params = control.parameters
|
||||||
--NOTE: the following check can cause a bug where the display desyncs if the player changes the operation of the combinator and then changes it back before the mod can notice, however removing it causes a bug where the user's change is overwritten and ignored. Everything's bad we need an event to catch copy-paste by blueprint.
|
--NOTE: the following check can cause a bug where the display desyncs if the player changes the operation of the combinator and then changes it back before the mod can notice, however removing it causes a bug where the user's change is overwritten and ignored. Everything's bad we need an event to catch copy-paste by blueprint.
|
||||||
if params.operation == MODE_PRIMARY_IO or params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST then
|
if params.operation == MODE_PRIMARY_IO or params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST then
|
||||||
if station.display_state >= 2 then
|
if station.display_state >= 4 then
|
||||||
params.operation = MODE_PRIMARY_IO_ACTIVE
|
params.operation = MODE_PRIMARY_IO_ACTIVE
|
||||||
elseif station.display_state == 1 then
|
elseif station.display_state >= 1 then
|
||||||
params.operation = MODE_PRIMARY_IO_FAILED_REQUEST
|
params.operation = MODE_PRIMARY_IO_FAILED_REQUEST
|
||||||
else
|
else
|
||||||
params.operation = MODE_PRIMARY_IO
|
params.operation = MODE_PRIMARY_IO
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
---@field public tick_signals {[uint]: Signal}? --transient
|
---@field public tick_signals {[uint]: Signal}? --transient
|
||||||
---@field public item_p_counts {[string]: int} --transient
|
---@field public item_p_counts {[string]: int} --transient
|
||||||
---@field public item_thresholds {[string]: int}? --transient
|
---@field public item_thresholds {[string]: int}? --transient
|
||||||
---@field public display_state 0|1|2|3 --low bit is if this station's request has failed, high bit is if a train is heading to this station
|
---@field public display_state int
|
||||||
|
|
||||||
---@class Depot
|
---@class Depot
|
||||||
---@field public entity_stop LuaEntity
|
---@field public entity_stop LuaEntity
|
||||||
|
|||||||
@@ -95,11 +95,11 @@ function gui_opened(comb, player)
|
|||||||
---choose-elem-button
|
---choose-elem-button
|
||||||
{type="line", style_mods={top_padding=10}},
|
{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="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="flow", name="bottom", direction="horizontal", style_mods={vertical_align="center", top_margin=0, top_padding=0}, 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}, actions={
|
{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}, actions={
|
||||||
on_elem_changed={"choose-elem-button", comb.unit_number}
|
on_elem_changed={"choose-elem-button", comb.unit_number}
|
||||||
}},
|
}},
|
||||||
{type="flow", name="right", direction="vertical", style_mods={horizontal_align="left"}, children={
|
{type="flow", name="right", direction="vertical", style_mods={horizontal_align="left", top_margin=0, top_padding=0}, children={
|
||||||
{type="flow", name="allow_list", direction="horizontal", style_mods={vertical_align="center"}, 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={
|
{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}
|
on_checked_state_changed={"allow_list", comb.unit_number}
|
||||||
|
|||||||
@@ -134,6 +134,9 @@ local migrations_table = {
|
|||||||
|
|
||||||
control.parameters = params
|
control.parameters = params
|
||||||
end
|
end
|
||||||
|
for id, station in pairs(map_data.stations) do
|
||||||
|
station.display_state = (station.display_state >= 2 and 4) + station.display_state%2
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
--STATUS_R_TO_D = 5
|
--STATUS_R_TO_D = 5
|
||||||
|
|||||||
Reference in New Issue
Block a user