mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-14 14:12:42 -06:00
added missing items display
This commit is contained in:
@@ -19,6 +19,21 @@ local function get_stop_dist(stop0, stop1)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param map_data MapData
|
||||||
|
---@param station Station
|
||||||
|
---@param manifest Manifest
|
||||||
|
function remove_manifest(map_data, station, manifest, sign)
|
||||||
|
local deliveries = station.deliveries
|
||||||
|
for i, item in ipairs(manifest) do
|
||||||
|
deliveries[item.name] = deliveries[item.name] + sign*item.count
|
||||||
|
if deliveries[item.name] == 0 then
|
||||||
|
deliveries[item.name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set_comb2(map_data, station)
|
||||||
|
station.deliveries_total = station.deliveries_total - 1
|
||||||
|
end
|
||||||
|
|
||||||
---@param map_data MapData
|
---@param map_data MapData
|
||||||
---@param r_station_id uint
|
---@param r_station_id uint
|
||||||
---@param p_station_id uint
|
---@param p_station_id uint
|
||||||
@@ -206,7 +221,6 @@ local function send_train_between(map_data, r_station_id, p_station_id, depot, p
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---@param map_data MapData
|
---@param map_data MapData
|
||||||
local function tick_poll_depot(map_data)
|
local function tick_poll_depot(map_data)
|
||||||
local depot_id
|
local depot_id
|
||||||
@@ -272,6 +286,11 @@ local function tick_poll_station(map_data, mod_settings)
|
|||||||
map_data.tick_state = STATE_DISPATCH
|
map_data.tick_state = STATE_DISPATCH
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
if station.display_update then
|
||||||
|
update_combinator_display(station.entity_comb1, station.display_failed_request)
|
||||||
|
station.display_update = station.display_failed_request
|
||||||
|
station.display_failed_request = nil
|
||||||
|
end
|
||||||
|
|
||||||
if station.network_name and station.deliveries_total < station.entity_stop.trains_limit then
|
if station.network_name and station.deliveries_total < station.entity_stop.trains_limit then
|
||||||
station.r_threshold = mod_settings.r_threshold
|
station.r_threshold = mod_settings.r_threshold
|
||||||
@@ -380,7 +399,7 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
|
|
||||||
r_stations = all_r_stations[item_network_name]
|
r_stations = all_r_stations[item_network_name]
|
||||||
p_stations = all_p_stations[item_network_name]
|
p_stations = all_p_stations[item_network_name]
|
||||||
if p_stations and #r_stations > 0 and #p_stations > 0 then
|
if p_stations then
|
||||||
tick_data.r_stations = r_stations
|
tick_data.r_stations = r_stations
|
||||||
tick_data.p_stations = p_stations
|
tick_data.p_stations = p_stations
|
||||||
tick_data.item_name = signal.name
|
tick_data.item_name = signal.name
|
||||||
@@ -395,6 +414,12 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
break
|
break
|
||||||
|
else
|
||||||
|
for i, id in ipairs(r_stations) do
|
||||||
|
local station = stations[id]
|
||||||
|
station.display_failed_request = true
|
||||||
|
station.display_update = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -435,9 +460,8 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
if could_have_been_serviced then
|
if could_have_been_serviced then
|
||||||
send_missing_train_alert_for_stops(r_station.entity_stop, stations[p_stations[best]].entity_stop)
|
send_missing_train_alert_for_stops(r_station.entity_stop, stations[p_stations[best]].entity_stop)
|
||||||
end
|
end
|
||||||
if r_station.entity_comb1.valid then
|
r_station.display_failed_request = true
|
||||||
set_combinator_operation(r_station.entity_comb1, OPERATION_PRIMARY_IO_NOT_FOUND)
|
r_station.display_update = true
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ COMBINATOR_CLOSE_SOUND = "entity-close/cybersyn-combinator"
|
|||||||
|
|
||||||
OPERATION_DEFAULT = "*"
|
OPERATION_DEFAULT = "*"
|
||||||
OPERATION_PRIMARY_IO = "/"
|
OPERATION_PRIMARY_IO = "/"
|
||||||
OPERATION_PRIMARY_IO_ACTIVE = "^"
|
OPERATION_PRIMARY_IO_REQUEST_FAILED = "^"
|
||||||
OPERATION_PRIMARY_IO_NOT_FOUND = "<<"
|
OPERATION_PRIMARY_IO_ACTIVE = "<<"
|
||||||
OPERATION_SECONDARY_IO = "%"
|
OPERATION_SECONDARY_IO = "%"
|
||||||
OPERATION_DEPOT = "+"
|
OPERATION_DEPOT = "+"
|
||||||
OPERATION_WAGON_MANIFEST = "-"
|
OPERATION_WAGON_MANIFEST = "-"
|
||||||
|
|||||||
@@ -69,22 +69,6 @@ function create_manifest_schedule(depot_name, p_stop, r_stop, manifest)
|
|||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param map_data MapData
|
|
||||||
---@param station Station
|
|
||||||
---@param manifest Manifest
|
|
||||||
function remove_manifest(map_data, station, manifest, sign)
|
|
||||||
local deliveries = station.deliveries
|
|
||||||
for i, item in ipairs(manifest) do
|
|
||||||
deliveries[item.name] = deliveries[item.name] + sign*item.count
|
|
||||||
if deliveries[item.name] == 0 then
|
|
||||||
deliveries[item.name] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
set_comb2(map_data, station)
|
|
||||||
station.deliveries_total = station.deliveries_total - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---@param param ArithmeticCombinatorParameters
|
---@param param ArithmeticCombinatorParameters
|
||||||
function get_comb_secondary_state(param)
|
function get_comb_secondary_state(param)
|
||||||
@@ -142,6 +126,21 @@ function set_combinator_operation(comb, op)
|
|||||||
control.operation = op
|
control.operation = op
|
||||||
a.parameters = control
|
a.parameters = control
|
||||||
end
|
end
|
||||||
|
---@param comb LuaEntity
|
||||||
|
---@param is_failed boolean
|
||||||
|
function update_combinator_display(comb, is_failed)
|
||||||
|
local a = comb.get_or_create_control_behavior()--[[@as LuaArithmeticCombinatorControlBehavior]]
|
||||||
|
local control = a.parameters
|
||||||
|
if is_failed then
|
||||||
|
if control.operation == OPERATION_PRIMARY_IO then
|
||||||
|
control.operation = OPERATION_PRIMARY_IO_REQUEST_FAILED
|
||||||
|
a.parameters = control
|
||||||
|
end
|
||||||
|
elseif control.operation == OPERATION_PRIMARY_IO_REQUEST_FAILED then
|
||||||
|
control.operation = OPERATION_PRIMARY_IO
|
||||||
|
a.parameters = control
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---@param station Station
|
---@param station Station
|
||||||
@@ -214,7 +213,6 @@ function send_lost_train_alert(train)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local send_nonempty_train_in_depot_alert_icon = {name = NONEMPTY_TRAIN_NAME, type = "fluid"}
|
local send_nonempty_train_in_depot_alert_icon = {name = NONEMPTY_TRAIN_NAME, type = "fluid"}
|
||||||
---@param train LuaTrain
|
---@param train LuaTrain
|
||||||
function send_nonempty_train_in_depot_alert(train)
|
function send_nonempty_train_in_depot_alert(train)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
---@class Station
|
---@class Station
|
||||||
---@field public is_p boolean
|
---@field public is_p boolean
|
||||||
---@field public is_r boolean
|
---@field public is_r boolean
|
||||||
|
---@field public allows_all_trains boolean
|
||||||
---@field public deliveries_total int
|
---@field public deliveries_total int
|
||||||
---@field public last_delivery_tick int
|
---@field public last_delivery_tick int
|
||||||
---@field public priority int --transient
|
---@field public priority int --transient
|
||||||
@@ -30,11 +31,12 @@
|
|||||||
---@field public deliveries {[string]: int}
|
---@field public deliveries {[string]: int}
|
||||||
---@field public network_name string?
|
---@field public network_name string?
|
||||||
---@field public network_flag int --transient
|
---@field public network_flag int --transient
|
||||||
---@field public allows_all_trains boolean
|
|
||||||
---@field public accepted_layouts TrainClass
|
---@field public accepted_layouts TrainClass
|
||||||
---@field public layout_pattern string?
|
---@field public layout_pattern string?
|
||||||
---@field public tick_signals {[uint]: Signal}? --transient
|
---@field public tick_signals {[uint]: Signal}? --transient
|
||||||
---@field public p_count_or_r_threshold_per_item {[string]: int} --transient
|
---@field public p_count_or_r_threshold_per_item {[string]: int} --transient
|
||||||
|
---@field public display_failed_request true?
|
||||||
|
---@field public display_update true?
|
||||||
|
|
||||||
---@class Depot
|
---@class Depot
|
||||||
---@field public priority int --transient
|
---@field public priority int --transient
|
||||||
@@ -58,7 +60,7 @@
|
|||||||
---@field public has_filtered_wagon boolean
|
---@field public has_filtered_wagon boolean
|
||||||
|
|
||||||
---@alias Manifest {}[]
|
---@alias Manifest {}[]
|
||||||
---@alias TrainClass {[uint]: boolean}
|
---@alias TrainClass {[uint]: true}
|
||||||
---@alias cybersyn.global MapData
|
---@alias cybersyn.global MapData
|
||||||
|
|
||||||
---@class Economy
|
---@class Economy
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ function gui_opened(comb, player)
|
|||||||
switch_state = "right"
|
switch_state = "right"
|
||||||
end
|
end
|
||||||
|
|
||||||
if op == OPERATION_PRIMARY_IO or op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_NOT_FOUND then
|
if op == OPERATION_PRIMARY_IO or op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_REQUEST_FAILED then
|
||||||
selected_index = 1
|
selected_index = 1
|
||||||
elseif op == OPERATION_SECONDARY_IO then
|
elseif op == OPERATION_SECONDARY_IO then
|
||||||
selected_index = 2
|
selected_index = 2
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local flib_event = require("__flib__.event")
|
|||||||
|
|
||||||
---@param map_data MapData
|
---@param map_data MapData
|
||||||
---@param station Station
|
---@param station Station
|
||||||
|
---@param manifest Manifest
|
||||||
---@param sign int?
|
---@param sign int?
|
||||||
local function set_comb1(map_data, station, manifest, sign)
|
local function set_comb1(map_data, station, manifest, sign)
|
||||||
local comb = station.entity_comb1
|
local comb = station.entity_comb1
|
||||||
@@ -254,7 +255,7 @@ local function on_combinator_built(map_data, comb)
|
|||||||
param.operation = op
|
param.operation = op
|
||||||
param.first_signal = NETWORK_SIGNAL_DEFAULT
|
param.first_signal = NETWORK_SIGNAL_DEFAULT
|
||||||
control.parameters = param
|
control.parameters = param
|
||||||
elseif op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_NOT_FOUND then
|
elseif op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_REQUEST_FAILED then
|
||||||
op = OPERATION_PRIMARY_IO
|
op = OPERATION_PRIMARY_IO
|
||||||
param.operation = op
|
param.operation = op
|
||||||
control.parameters = param
|
control.parameters = param
|
||||||
@@ -403,7 +404,7 @@ local function on_stop_built(map_data, stop)
|
|||||||
map_data.to_stop[entity.unit_number] = stop
|
map_data.to_stop[entity.unit_number] = stop
|
||||||
local control = entity.get_or_create_control_behavior().parameters--[[@as ArithmeticCombinatorParameters]]
|
local control = entity.get_or_create_control_behavior().parameters--[[@as ArithmeticCombinatorParameters]]
|
||||||
local op = control.operation
|
local op = control.operation
|
||||||
if op == OPERATION_PRIMARY_IO or op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_NOT_FOUND then
|
if op == OPERATION_PRIMARY_IO or op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_REQUEST_FAILED then
|
||||||
comb1 = entity
|
comb1 = entity
|
||||||
elseif op == OPERATION_SECONDARY_IO then
|
elseif op == OPERATION_SECONDARY_IO then
|
||||||
comb2 = entity
|
comb2 = entity
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ local flib_migration = require("__flib__.migration")
|
|||||||
|
|
||||||
|
|
||||||
local migrations_table = {
|
local migrations_table = {
|
||||||
["0.0.1"] = function()
|
["0.2.0"] = function()
|
||||||
---@type MapData
|
---@type MapData
|
||||||
local map_data = global
|
local map_data = global
|
||||||
for k, station in pairs(map_data.stations) do
|
for k, station in pairs(map_data.stations) do
|
||||||
station.p_count_or_r_threshold_per_item = {}
|
station.p_count_or_r_threshold_per_item = {}
|
||||||
station.p_threshold = nil
|
station.p_threshold = nil
|
||||||
station.is_all = nil
|
station.is_all = nil
|
||||||
station.is_auto = nil
|
|
||||||
set_station_from_comb_state(station)
|
set_station_from_comb_state(station)
|
||||||
|
set_combinator_operation(station.entity_comb1, OPERATION_PRIMARY_IO)
|
||||||
end
|
end
|
||||||
map_data.tick_state = STATE_INIT
|
map_data.tick_state = STATE_INIT
|
||||||
end,
|
end,
|
||||||
|
|||||||
Reference in New Issue
Block a user