fixed copy-paste

This commit is contained in:
Monica Moniot
2022-11-19 10:21:40 -05:00
parent c93d4bdcf8
commit 3a8e91b11d
7 changed files with 84 additions and 76 deletions

4
TODO
View File

@@ -1,9 +1,7 @@
close gui when the combinator is destroyed close gui when the combinator is destroyed
do not play close sound when a different gui is opened do not play close sound when a different gui is opened
gui can desync if settings are changed outside of it while it is open
do hardcore testing do hardcore testing
models & art models & art
space elevator compat space elevator compat
railloader compat railloader compat
add missing items alert
lost train can be repurposed and rescheduled while alert is active
display when train is coming

View File

@@ -21,7 +21,7 @@ Date: 2022-11-13
- Added warmup period on just built stations - Added warmup period on just built stations
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 0.3.0 Version: 0.3.0
Date: 2022-11-13 Date: 2022-11-15
Features: Features:
- Fixed copy-paste - Fixed copy-paste
- Added alert sounds - Added alert sounds

View File

@@ -33,7 +33,7 @@ function remove_manifest(map_data, station, manifest, sign)
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.entity_comb1.valid then if station.deliveries_total == 0 and station.entity_comb1.valid then
set_combinator_operation(station.entity_comb1, OPERATION_PRIMARY_IO) map_data.to_comb_params[station.entity_comb1.unit_number] = set_combinator_operation(station.entity_comb1, OPERATION_PRIMARY_IO)
end end
end end
@@ -220,10 +220,10 @@ local function send_train_between(map_data, r_station_id, p_station_id, depot, p
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.entity_comb1.valid then if p_station.entity_comb1.valid then
set_combinator_operation(p_station.entity_comb1, OPERATION_PRIMARY_IO_ACTIVE) map_data.to_comb_params[p_station.entity_comb1.unit_number] = set_combinator_operation(p_station.entity_comb1, OPERATION_PRIMARY_IO_ACTIVE)
end end
if r_station.entity_comb1.valid then if r_station.entity_comb1.valid then
set_combinator_operation(r_station.entity_comb1, OPERATION_PRIMARY_IO_ACTIVE) map_data.to_comb_params[r_station.entity_comb1.unit_number] = set_combinator_operation(r_station.entity_comb1, OPERATION_PRIMARY_IO_ACTIVE)
end end
end end
@@ -275,7 +275,7 @@ local function tick_poll_station(map_data, mod_settings)
station = map_data.stations[station_id] station = map_data.stations[station_id]
if station then if station then
if station.display_update then if station.display_update then
update_combinator_display(station.entity_comb1, station.display_failed_request) map_data.to_comb_params[station.entity_comb1.unit_number] = update_combinator_display(station.entity_comb1, station.display_failed_request)
station.display_update = station.display_failed_request station.display_update = station.display_failed_request
station.display_failed_request = nil station.display_failed_request = nil
end end
@@ -439,6 +439,7 @@ local function tick_dispatch(map_data, mod_settings)
local item_type = tick_data.item_type local item_type = tick_data.item_type
local r_threshold = r_station.p_count_or_r_threshold_per_item[item_name] local r_threshold = r_station.p_count_or_r_threshold_per_item[item_name]
if r_threshold then
local best = 0 local best = 0
local best_depot = nil local best_depot = nil
local best_dist = INF local best_dist = INF
@@ -446,7 +447,7 @@ local function tick_dispatch(map_data, mod_settings)
local can_be_serviced = false local can_be_serviced = false
for j, p_station_id in ipairs(p_stations) do for j, p_station_id in ipairs(p_stations) do
local p_station = stations[p_station_id] local p_station = stations[p_station_id]
if p_station and p_station.p_count_or_r_threshold_per_item[item_name] >= r_threshold and p_station.deliveries_total < p_station.entity_stop.trains_limit then if p_station and (p_station.p_count_or_r_threshold_per_item[item_name] or -1) >= r_threshold and p_station.deliveries_total < p_station.entity_stop.trains_limit then
local prior = p_station.priority local prior = p_station.priority
local slot_threshold = item_type == "fluid" and r_threshold or ceil(r_threshold/get_stack_size(map_data, item_name)) local slot_threshold = item_type == "fluid" and r_threshold or ceil(r_threshold/get_stack_size(map_data, item_name))
local depot, d = get_valid_train(map_data, r_station_id, p_station_id, item_type, slot_threshold) local depot, d = get_valid_train(map_data, r_station_id, p_station_id, item_type, slot_threshold)
@@ -478,6 +479,7 @@ local function tick_dispatch(map_data, mod_settings)
r_station.display_update = true r_station.display_update = true
end end
end end
end
return false return false
end end
---@param map_data MapData ---@param map_data MapData

View File

@@ -15,7 +15,7 @@ ALERT_SOUND = "utility/console_message"
OPERATION_DEFAULT = "*" OPERATION_DEFAULT = "*"
OPERATION_PRIMARY_IO = "/" OPERATION_PRIMARY_IO = "/"
OPERATION_PRIMARY_IO_REQUEST_FAILED = "^" OPERATION_PRIMARY_IO_FAILED_REQUEST = "^"
OPERATION_PRIMARY_IO_ACTIVE = "<<" OPERATION_PRIMARY_IO_ACTIVE = "<<"
OPERATION_SECONDARY_IO = "%" OPERATION_SECONDARY_IO = "%"
OPERATION_DEPOT = "+" OPERATION_DEPOT = "+"

View File

@@ -154,13 +154,14 @@ function update_combinator_display(comb, is_failed)
local param = control.parameters local param = control.parameters
if is_failed then if is_failed then
if param.operation == OPERATION_PRIMARY_IO then if param.operation == OPERATION_PRIMARY_IO then
param.operation = OPERATION_PRIMARY_IO_REQUEST_FAILED param.operation = OPERATION_PRIMARY_IO_FAILED_REQUEST
control.parameters = param control.parameters = param
end end
elseif param.operation == OPERATION_PRIMARY_IO_REQUEST_FAILED then elseif param.operation == OPERATION_PRIMARY_IO_FAILED_REQUEST then
param.operation = OPERATION_PRIMARY_IO param.operation = OPERATION_PRIMARY_IO
control.parameters = param control.parameters = param
end end
return param
end end

View File

@@ -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_REQUEST_FAILED then if op == OPERATION_PRIMARY_IO or op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_FAILED_REQUEST 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

View File

@@ -248,21 +248,22 @@ local function on_combinator_built(map_data, comb)
local param = control.parameters local param = control.parameters
local op = param.operation local op = param.operation
map_data.to_comb[comb.unit_number] = comb
map_data.to_output[comb.unit_number] = out
map_data.to_stop[comb.unit_number] = stop
map_data.to_comb_params[comb.unit_number] = param
if op == OPERATION_DEFAULT then if op == OPERATION_DEFAULT then
op = OPERATION_PRIMARY_IO op = OPERATION_PRIMARY_IO
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_REQUEST_FAILED then elseif op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_FAILED_REQUEST then
op = OPERATION_PRIMARY_IO op = OPERATION_PRIMARY_IO
param.operation = op param.operation = op
control.parameters = param control.parameters = param
end end
map_data.to_comb[comb.unit_number] = comb
map_data.to_output[comb.unit_number] = out
map_data.to_stop[comb.unit_number] = stop
map_data.to_comb_params[comb.unit_number] = param
if op == OPERATION_WAGON_MANIFEST then if op == OPERATION_WAGON_MANIFEST then
if rail then if rail then
force_update_station_from_rail(map_data, rail, nil) force_update_station_from_rail(map_data, rail, nil)
@@ -392,14 +393,21 @@ end
function on_combinator_updated(map_data, comb, new_params) function on_combinator_updated(map_data, comb, new_params)
local old_params = map_data.to_comb_params[comb.unit_number] local old_params = map_data.to_comb_params[comb.unit_number]
if new_params.operation ~= old_params.operation then if new_params.operation ~= old_params.operation then
if (new_params.operation == OPERATION_PRIMARY_IO_ACTIVE or new_params.operation == OPERATION_PRIMARY_IO_FAILED_REQUEST or new_params.operation == OPERATION_PRIMARY_IO) and (old_params.operation == OPERATION_PRIMARY_IO_ACTIVE or old_params.operation == OPERATION_PRIMARY_IO_FAILED_REQUEST or old_params.operation == OPERATION_PRIMARY_IO) then
set_combinator_operation(comb, old_params.operation)
new_params.operation = old_params.operation
else
--NOTE: This is rather dangerous, we may need to actually implement operation changing
on_combinator_broken(map_data, comb) on_combinator_broken(map_data, comb)
on_combinator_built(map_data, comb) on_combinator_built(map_data, comb)
else return
end
end
local new_signal = new_params.first_signal local new_signal = new_params.first_signal
local old_signal = old_params.first_signal local old_signal = old_params.first_signal
local new_network = new_signal and new_signal.name or nil local new_network = new_signal and new_signal.name or nil
local old_network = old_signal and old_signal.name or nil local old_network = old_signal and old_signal.name or nil
if (new_network ~= old_network) then if new_network ~= old_network then
on_combinator_network_updated(map_data, comb, new_network) on_combinator_network_updated(map_data, comb, new_network)
end end
if new_params.second_constant ~= old_params.second_constant then if new_params.second_constant ~= old_params.second_constant then
@@ -421,7 +429,6 @@ function on_combinator_updated(map_data, comb, new_params)
end end
map_data.to_comb_params[comb.unit_number] = new_params map_data.to_comb_params[comb.unit_number] = new_params
end end
end
---@param map_data MapData ---@param map_data MapData
---@param stop LuaEntity ---@param stop LuaEntity
@@ -442,7 +449,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 param = get_comb_params(entity) local param = get_comb_params(entity)
local op = param.operation local op = param.operation
if op == OPERATION_PRIMARY_IO or op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_REQUEST_FAILED then if op == OPERATION_PRIMARY_IO then
comb1 = entity comb1 = entity
elseif op == OPERATION_SECONDARY_IO then elseif op == OPERATION_SECONDARY_IO then
comb2 = entity comb2 = entity