diff --git a/cybersyn/info.json b/cybersyn/info.json index dc78c1f..719e2ed 100644 --- a/cybersyn/info.json +++ b/cybersyn/info.json @@ -1,6 +1,6 @@ { "name": "cybersyn", - "version": "0.2.0", + "version": "0.2.1", "title": "Project Cybersyn", "author": "Mami", "factorio_version": "1.1", diff --git a/cybersyn/prototypes/signal.lua b/cybersyn/prototypes/signal.lua index b8819f6..a29220d 100644 --- a/cybersyn/prototypes/signal.lua +++ b/cybersyn/prototypes/signal.lua @@ -5,15 +5,6 @@ subgroup_signal = { group = "signals", order = "f" } -priority_signal = { - type = "virtual-signal", - name = SIGNAL_PRIORITY, - icon = "__cybersyn__/graphics/icons/priority.png", - icon_size = 64, - icon_mipmaps = 4, - subgroup = "cybersyn-signal", - order = "a" -} r_threshold_signal = { type = "virtual-signal", name = REQUEST_THRESHOLD, @@ -21,7 +12,16 @@ r_threshold_signal = { icon_size = 64, icon_mipmaps = 4, subgroup = "cybersyn-signal", - order = "c" + 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 = { type = "virtual-signal", @@ -30,5 +30,5 @@ locked_slots_signal = { icon_size = 64, icon_mipmaps = 4, subgroup = "cybersyn-signal", - order = "d" + order = "c" } diff --git a/cybersyn/scripts/central-planning.lua b/cybersyn/scripts/central-planning.lua index 1e047b3..0994233 100644 --- a/cybersyn/scripts/central-planning.lua +++ b/cybersyn/scripts/central-planning.lua @@ -32,6 +32,9 @@ function remove_manifest(map_data, station, manifest, sign) end set_comb2(map_data, station) station.deliveries_total = station.deliveries_total - 1 + if station.deliveries_total == 0 and station.entity_comb1.valid then + set_combinator_operation(station.entity_comb1, OPERATION_PRIMARY_IO) + end end ---@param map_data MapData @@ -448,8 +451,8 @@ local function tick_dispatch(map_data, mod_settings) highest_prior = prior can_be_serviced = true elseif d < INF then - can_be_serviced = true best = j + can_be_serviced = true end end end diff --git a/cybersyn/scripts/factorio-api.lua b/cybersyn/scripts/factorio-api.lua index cfe3d8e..4565793 100644 --- a/cybersyn/scripts/factorio-api.lua +++ b/cybersyn/scripts/factorio-api.lua @@ -45,9 +45,10 @@ function create_inactivity_order(depot_name) return {station = depot_name, wait_conditions = create_inactivity_order_condition} end +local create_direct_to_station_order_condition = {{type = "time", compare_type = "and", ticks = 1}} ---@param stop LuaEntity local function create_direct_to_station_order(stop) - return {rail = stop.connected_rail, rail_direction = stop.connected_rail_direction} + return {rail = stop.connected_rail, rail_direction = stop.connected_rail_direction,wait_conditions = create_direct_to_station_order_condition} end ---@param depot_name string diff --git a/cybersyn/scripts/gui.lua b/cybersyn/scripts/gui.lua index e6afbb4..0f27d03 100644 --- a/cybersyn/scripts/gui.lua +++ b/cybersyn/scripts/gui.lua @@ -220,10 +220,10 @@ function register_gui_actions() local comb = global.to_comb[msg[2]] if not comb or not comb.valid then return end - local a = comb.get_or_create_control_behavior()--[[@as LuaArithmeticCombinatorControlBehavior]] + local control = comb.get_or_create_control_behavior()--[[@as LuaArithmeticCombinatorControlBehavior]] local allows_all_trains = not element.state - set_comb_allows_all_trains(a, allows_all_trains) + set_comb_allows_all_trains(control, allows_all_trains) local stop = global.to_stop[comb.unit_number] if stop then diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 3a1ec3a..ebd5730 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -16,9 +16,6 @@ local function set_comb1(map_data, station, manifest, sign) end set_combinator_output(map_data, comb, signals) else - if station.deliveries_total == 0 then - set_combinator_operation(comb, OPERATION_PRIMARY_IO) - end set_combinator_output(map_data, comb, nil) end end @@ -131,7 +128,6 @@ local function on_station_built(map_data, stop, comb1, comb2) last_delivery_tick = 0, priority = 0, r_threshold = 0, - p_threshold = 0, locked_slots = 0, --network_name = param.first_signal and param.first_signal.name or nil, network_flag = 0, @@ -570,6 +566,8 @@ local function on_train_arrives_buffer(map_data, stop, train) set_comb1(map_data, station, train.manifest, -1) set_r_wagon_combs(map_data, station, train) end + elseif train.status == STATUS_P and train.p_station_id == station_id then + elseif train.status == STATUS_R and train.r_station_id == station_id then else on_failed_delivery(map_data, train) remove_train(map_data, train, train.entity.id) diff --git a/cybersyn/scripts/migrations.lua b/cybersyn/scripts/migrations.lua index ac79f7e..8cc7149 100644 --- a/cybersyn/scripts/migrations.lua +++ b/cybersyn/scripts/migrations.lua @@ -16,6 +16,13 @@ local migrations_table = { map_data.all_station_ids[#map_data.all_station_ids + 1] = id end end, + ["0.2.1"] = function() + ---@type MapData + local map_data = global + for id, station in pairs(map_data.stations) do + station.p_threshold = nil + end + end, } ---@param data ConfigurationChangedData