added minor improvement

This commit is contained in:
Monica Moniot
2022-11-12 01:16:20 -05:00
parent 7f44dae0ec
commit 5ccd52d214
2 changed files with 37 additions and 30 deletions

View File

@@ -14,15 +14,6 @@ r_threshold_signal = {
subgroup = "cybersyn-signal", subgroup = "cybersyn-signal",
order = "a" order = "a"
} }
priority_signal = {
type = "virtual-signal",
name = SIGNAL_PRIORITY,
icon = "__cybersyn__/graphics/icons/priority.png",
icon_size = 64,
icon_mipmaps = 4,
subgroup = "cybersyn-signal",
order = "b"
}
locked_slots_signal = { locked_slots_signal = {
type = "virtual-signal", type = "virtual-signal",
name = LOCKED_SLOTS, name = LOCKED_SLOTS,
@@ -30,5 +21,14 @@ locked_slots_signal = {
icon_size = 64, icon_size = 64,
icon_mipmaps = 4, icon_mipmaps = 4,
subgroup = "cybersyn-signal", subgroup = "cybersyn-signal",
order = "b"
}
priority_signal = {
type = "virtual-signal",
name = SIGNAL_PRIORITY,
icon = "__cybersyn__/graphics/icons/priority.png",
icon_size = 64,
icon_mipmaps = 4,
subgroup = "cybersyn-signal",
order = "c" order = "c"
} }

View File

@@ -324,30 +324,37 @@ local function tick_poll_station(map_data, mod_settings)
local item_name = v.signal.name local item_name = v.signal.name
local item_count = v.count local item_count = v.count
local effective_item_count = item_count + (station.deliveries[item_name] or 0) local effective_item_count = item_count + (station.deliveries[item_name] or 0)
local r_threshold = get_threshold(map_data, station, v.signal)
if station.is_r and -effective_item_count >= r_threshold and -item_count >= r_threshold then local flag = true
local item_network_name = station.network_name..":"..item_name if station.is_r then
local stations = all_r_stations[item_network_name] local r_threshold = get_threshold(map_data, station, v.signal)
if stations == nil then if -effective_item_count >= r_threshold and -item_count >= r_threshold then
stations = {} flag = false
all_r_stations[item_network_name] = stations local item_network_name = station.network_name..":"..item_name
all_names[#all_names + 1] = item_network_name local stations = all_r_stations[item_network_name]
all_names[#all_names + 1] = v.signal if stations == nil then
stations = {}
all_r_stations[item_network_name] = stations
all_names[#all_names + 1] = item_network_name
all_names[#all_names + 1] = v.signal
end
stations[#stations + 1] = station_id
station.p_count_or_r_threshold_per_item[item_name] = r_threshold
end end
stations[#stations + 1] = station_id end
station.p_count_or_r_threshold_per_item[item_name] = r_threshold if flag then
elseif station.is_p and effective_item_count > 0 and item_count > 0 then if station.is_p and effective_item_count > 0 and item_count > 0 then
local item_network_name = station.network_name..":"..item_name local item_network_name = station.network_name..":"..item_name
local stations = all_p_stations[item_network_name] local stations = all_p_stations[item_network_name]
if stations == nil then if stations == nil then
stations = {} stations = {}
all_p_stations[item_network_name] = stations all_p_stations[item_network_name] = stations
end
stations[#stations + 1] = station_id
station.p_count_or_r_threshold_per_item[item_name] = effective_item_count
else
signals[k] = nil
end end
stations[#stations + 1] = station_id
station.p_count_or_r_threshold_per_item[item_name] = effective_item_count
else
signals[k] = nil
end end
end end
end end