fixed minro display bugs

This commit is contained in:
Monica Moniot
2022-12-11 12:46:31 -05:00
parent 3487746a3c
commit bbb68c16b8
3 changed files with 39 additions and 29 deletions

View File

@@ -29,6 +29,8 @@ STATUS_NAMES_DEFAULT = "entity-status.disabled"
---@param comb LuaEntity
---@param player LuaPlayer
function gui_opened(comb, player)
combinator_update(global, comb)
local rootgui = player.gui.screen
local selected_index, signal, check, switch_state = get_comb_gui_settings(comb)

View File

@@ -398,18 +398,33 @@ function combinator_update(map_data, comb)
local old_params = map_data.to_comb_params[unit_number]
local has_changed = false
if params.operation ~= old_params.operation then
if (old_params.operation == MODE_PRIMARY_IO) and (params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST) then
local stop = map_data.to_stop[comb.unit_number]
if stop then
id = stop.unit_number
station = map_data.stations[id]
if station then
--make sure only MODE_PRIMARY_IO gets stored on map_data.to_comb_params
params.operation = MODE_PRIMARY_IO
else
--NOTE: This is rather dangerous, we may need to actually implement operation changing
on_combinator_broken(map_data, comb)
on_combinator_built(map_data, comb)
interface_raise_combinator_changed(comb, old_params)
return
if station.display_state >= 2 then
params.operation = MODE_PRIMARY_IO_ACTIVE
elseif station.display_state == 1 then
params.operation = MODE_PRIMARY_IO_FAILED_REQUEST
else
params.operation = MODE_PRIMARY_IO
end
control.parameters = params
end
end
if params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST then
params.operation = MODE_PRIMARY_IO
end
if params.operation ~= old_params.operation then
--NOTE: This is rather dangerous, we may need to actually implement operation changing
on_combinator_broken(map_data, comb)
on_combinator_built(map_data, comb)
interface_raise_combinator_changed(comb, old_params)
return
end
local new_signal = params.first_signal
local old_signal = old_params.first_signal
local new_network = new_signal and new_signal.name or nil
@@ -420,24 +435,19 @@ function combinator_update(map_data, comb)
end
if params.second_constant ~= old_params.second_constant then
has_changed = true
local stop = map_data.to_stop[comb.unit_number]
if stop then
local id = stop.unit_number
local station = map_data.stations[id]
if station then
local pre = station.allows_all_trains
set_station_from_comb_state(station)
if station.allows_all_trains ~= pre then
update_stop_if_auto(map_data, station, true)
end
else
local refueler = map_data.refuelers[id]
if refueler then
local pre = refueler.allows_all_trains
set_refueler_from_comb(mod_settings, refueler)
if refueler.allows_all_trains ~= pre then
update_stop_if_auto(map_data, refueler, false)
end
if station then
local pre = station.allows_all_trains
set_station_from_comb_state(station)
if station.allows_all_trains ~= pre then
update_stop_if_auto(map_data, station, true)
end
else
local refueler = map_data.refuelers[id]
if refueler then
local pre = refueler.allows_all_trains
set_refueler_from_comb(mod_settings, refueler)
if refueler.allows_all_trains ~= pre then
update_stop_if_auto(map_data, refueler, false)
end
end
end

View File

@@ -374,9 +374,7 @@ local function on_train_leaves_stop(map_data, mod_settings, train_id, train)
interface_raise_train_status_changed(train_id, STATUS_F, train.status)
elseif train.status == STATUS_D then
--The train is leaving the depot without a manifest, the player likely intervened
local depot = map_data.depots[train.parked_at_depot_id--[[@as uint]]]
remove_train(map_data, train_id, train)
send_lost_train_alert(train.entity, depot.entity_stop.backer_name)
end
end