mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-09 16:08:11 -06:00
Merge branch 'main' of https://github.com/Zoryn4163/project-cybersyn
This commit is contained in:
@@ -1,4 +1,13 @@
|
|||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
|
Version: 2.0.2
|
||||||
|
Changes:
|
||||||
|
- Refactored quality handling
|
||||||
|
- Initial update of the LTN GUI for 2.0
|
||||||
|
---------------------------------------------------------------------------------------------------
|
||||||
|
Version: 2.0.1
|
||||||
|
Bugfixes:
|
||||||
|
- Migrate the get_rail_segment_entity function call that no longer exists in 2.0
|
||||||
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 2.0.0
|
Version: 2.0.0
|
||||||
Changes:
|
Changes:
|
||||||
- Initial version of 2.0 compatibility
|
- Initial version of 2.0 compatibility
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cybersyn",
|
"name": "cybersyn",
|
||||||
"version": "2.0.0",
|
"version": "2.0.2",
|
||||||
"title": "Project Cybersyn",
|
"title": "Project Cybersyn",
|
||||||
"author": "Mami",
|
"author": "Mami",
|
||||||
"factorio_version": "2.0",
|
"factorio_version": "2.0",
|
||||||
|
|||||||
@@ -588,6 +588,7 @@ 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 item_type = v.signal.type
|
local item_type = v.signal.type
|
||||||
|
-- FIXME handle v.signal.quality
|
||||||
if item_name then
|
if item_name then
|
||||||
if item_type == "virtual" then
|
if item_type == "virtual" then
|
||||||
if item_name == SIGNAL_PRIORITY then
|
if item_name == SIGNAL_PRIORITY then
|
||||||
@@ -605,6 +606,7 @@ 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 item_type = v.signal.type
|
local item_type = v.signal.type
|
||||||
|
-- FIXME handle v.signal.quality
|
||||||
if item_name then
|
if item_name then
|
||||||
if item_type == "virtual" then
|
if item_type == "virtual" then
|
||||||
if item_name == SIGNAL_PRIORITY then
|
if item_name == SIGNAL_PRIORITY then
|
||||||
|
|||||||
@@ -689,40 +689,8 @@ end
|
|||||||
function set_combinator_output(map_data, comb, signals)
|
function set_combinator_output(map_data, comb, signals)
|
||||||
local out = map_data.to_output[comb.unit_number]
|
local out = map_data.to_output[comb.unit_number]
|
||||||
if out.valid then
|
if out.valid then
|
||||||
--out.get_or_create_control_behavior().parameters = signals
|
-- out is a non-interactable, invisible combinator whiche means players cannot change the number of sections
|
||||||
local constBehaviour = out.get_or_create_control_behavior()
|
out.get_or_create_control_behavior().get_section(1).filters = signals or {}
|
||||||
|
|
||||||
if constBehaviour.sections == nil or constBehaviour.sections_count == 0 then
|
|
||||||
constBehaviour.add_section()
|
|
||||||
end
|
|
||||||
|
|
||||||
if constBehaviour.sections and constBehaviour.sections_count > 0 then
|
|
||||||
if constBehaviour.sections_count > 1 then
|
|
||||||
--only the default section, messy but whatever
|
|
||||||
local i = 1
|
|
||||||
for _,v in pairs(constBehaviour.sections) do
|
|
||||||
if i ~= 1 then
|
|
||||||
constBehaviour.removeSection(i)
|
|
||||||
end
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local primarySection = constBehaviour.get_section(1)
|
|
||||||
local filters = {}
|
|
||||||
if signals ~= nil then
|
|
||||||
for _,v in pairs(signals) do
|
|
||||||
local filt = {
|
|
||||||
type = v.signal.type,
|
|
||||||
name = v.signal.name,
|
|
||||||
quality = nil,
|
|
||||||
comparator = nil
|
|
||||||
}
|
|
||||||
table.insert(filters, filt)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
primarySection.filters = filters
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -757,7 +725,8 @@ function set_comb2(map_data, station)
|
|||||||
for item_name, count in pairs(deliveries) do
|
for item_name, count in pairs(deliveries) do
|
||||||
local i = #signals + 1
|
local i = #signals + 1
|
||||||
local is_fluid = prototypes.item[item_name] == nil--NOTE: this is expensive
|
local is_fluid = prototypes.item[item_name] == nil--NOTE: this is expensive
|
||||||
signals[i] = {index = i, signal = {type = is_fluid and "fluid" or "item", name = item_name}, count = sign*count}
|
-- FIXME: the circuit network can only carry exact qualities, so deliveries must provide each quality separately
|
||||||
|
signals[i] = {value = {type = is_fluid and "fluid" or "item", name = item_name, quality = "normal", comparator = "="}, min = sign*count} -- constant combinator cannot have quality = nil (any)
|
||||||
end
|
end
|
||||||
set_combinator_output(map_data, station.entity_comb2, signals)
|
set_combinator_output(map_data, station.entity_comb2, signals)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -102,6 +102,7 @@
|
|||||||
---@class ManifestEntry
|
---@class ManifestEntry
|
||||||
---@field public type string
|
---@field public type string
|
||||||
---@field public name string
|
---@field public name string
|
||||||
|
---@field public quality string
|
||||||
---@field public count int
|
---@field public count int
|
||||||
|
|
||||||
---@class Economy
|
---@class Economy
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ function inventory_tab.build(map_data, player_data)
|
|||||||
if comb1_signals then
|
if comb1_signals then
|
||||||
for _, signal_ID in pairs(comb1_signals) do
|
for _, signal_ID in pairs(comb1_signals) do
|
||||||
local item = signal_ID.signal.name
|
local item = signal_ID.signal.name
|
||||||
|
-- FIXME handle signal_ID.signal.quality
|
||||||
if item then
|
if item then
|
||||||
if item == search_item then
|
if item == search_item then
|
||||||
goto has_match
|
goto has_match
|
||||||
@@ -136,6 +137,7 @@ function inventory_tab.build(map_data, player_data)
|
|||||||
if station.is_stack and item_type == "item" then
|
if station.is_stack and item_type == "item" then
|
||||||
r_threshold = r_threshold*get_stack_size(map_data, item.name)
|
r_threshold = r_threshold*get_stack_size(map_data, item.name)
|
||||||
end
|
end
|
||||||
|
-- FIXME handle v.signal.quality
|
||||||
|
|
||||||
if -count >= r_threshold then
|
if -count >= r_threshold then
|
||||||
if inventory_requested[item.name] == nil then
|
if inventory_requested[item.name] == nil then
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ function stations_tab.build(map_data, player_data, query_limit)
|
|||||||
if comb1_signals then
|
if comb1_signals then
|
||||||
for _, signal_ID in pairs(comb1_signals) do
|
for _, signal_ID in pairs(comb1_signals) do
|
||||||
local item = signal_ID.signal.name
|
local item = signal_ID.signal.name
|
||||||
|
-- FIXME handle signal_ID.signal.quality
|
||||||
if item then
|
if item then
|
||||||
if item == search_item then
|
if item == search_item then
|
||||||
goto has_match
|
goto has_match
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ function util.slot_table_build_from_station(station)
|
|||||||
end
|
end
|
||||||
local count = v.count
|
local count = v.count
|
||||||
local name = item.name
|
local name = item.name
|
||||||
|
-- FIXME handle item.quality
|
||||||
local sprite, img_path, item_string = util.generate_item_references(name)
|
local sprite, img_path, item_string = util.generate_item_references(name)
|
||||||
if sprite ~= nil then
|
if sprite ~= nil then
|
||||||
local color
|
local color
|
||||||
@@ -181,6 +182,7 @@ function util.slot_table_build_from_control_signals(station, map_data)
|
|||||||
local item = v.signal
|
local item = v.signal
|
||||||
local count = v.count
|
local count = v.count
|
||||||
local name = item.name
|
local name = item.name
|
||||||
|
-- FIXME handle item.quality
|
||||||
local sprite = ""
|
local sprite = ""
|
||||||
local color = "default"
|
local color = "default"
|
||||||
if item.type ~= "virtual" then
|
if item.type ~= "virtual" then
|
||||||
|
|||||||
@@ -228,7 +228,8 @@ function set_p_wagon_combs(map_data, station, train)
|
|||||||
local count_to_fill = min(item_slots_capacity*stack_size, item_count)
|
local count_to_fill = min(item_slots_capacity*stack_size, item_count)
|
||||||
local slots_to_fill = ceil(count_to_fill/stack_size)
|
local slots_to_fill = ceil(count_to_fill/stack_size)
|
||||||
|
|
||||||
signals[i] = {index = i, signal = {type = item.type, name = item.name}, count = sign*count_to_fill}
|
-- FIXME: quality any for now, should match the delivery
|
||||||
|
signals[i] = {value = {type = item.type, name = item.name}, min = sign*count_to_fill}
|
||||||
item_count = item_count - count_to_fill
|
item_count = item_count - count_to_fill
|
||||||
item_slots_capacity = item_slots_capacity - slots_to_fill
|
item_slots_capacity = item_slots_capacity - slots_to_fill
|
||||||
if comb then
|
if comb then
|
||||||
@@ -323,7 +324,8 @@ function set_r_wagon_combs(map_data, station, train)
|
|||||||
local stack = inv[stack_i]
|
local stack = inv[stack_i]
|
||||||
if stack.valid_for_read then
|
if stack.valid_for_read then
|
||||||
local i = #signals + 1
|
local i = #signals + 1
|
||||||
signals[i] = {index = i, signal = {type = "item", name = stack.name}, count = sign*stack.count}
|
-- FIXME item stacks have quality
|
||||||
|
signals[i] = {value = {type = "item", name = stack.name, quality = "normal", comparator = "="}, min = sign*stack.count}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_combinator_output(map_data, comb, signals)
|
set_combinator_output(map_data, comb, signals)
|
||||||
@@ -334,7 +336,8 @@ function set_r_wagon_combs(map_data, station, train)
|
|||||||
local inv = carriage.get_fluid_contents()
|
local inv = carriage.get_fluid_contents()
|
||||||
for fluid_name, count in pairs(inv) do
|
for fluid_name, count in pairs(inv) do
|
||||||
local i = #signals + 1
|
local i = #signals + 1
|
||||||
signals[i] = {index = i, signal = {type = "fluid", name = fluid_name}, count = sign*floor(count)}
|
-- FIXME ? pump conditions can have quality (but why? fluids can only be produced at normal quality and pump filters ignore quality)
|
||||||
|
signals[i] = {value = {type = "fluid", name = fluid_name, quality = "normal", comparator = "="}, min = sign*floor(count)}
|
||||||
end
|
end
|
||||||
set_combinator_output(map_data, comb, signals)
|
set_combinator_output(map_data, comb, signals)
|
||||||
end
|
end
|
||||||
@@ -388,10 +391,12 @@ function set_refueler_combs(map_data, refueler, train)
|
|||||||
if stack.valid_for_read then
|
if stack.valid_for_read then
|
||||||
if comb then
|
if comb then
|
||||||
local i = #wagon_signals + 1
|
local i = #wagon_signals + 1
|
||||||
wagon_signals[i] = {index = i, signal = {type = "item", name = stack.name}, count = stack.count}
|
-- FIXME fuel items can have quality which improves acceleration and top speed (but not fuel value)
|
||||||
|
wagon_signals[i] = {value = {type = "item", name = stack.name, quality = "normal", comparator = "="}, min = stack.count}
|
||||||
end
|
end
|
||||||
local j = #signals + 1
|
local j = #signals + 1
|
||||||
signals[j] = {index = j, signal = {type = "item", name = stack.name}, count = stack.count}
|
-- FIXME fuel items can have quality which improves acceleration and top speed (but not fuel value)
|
||||||
|
signals[j] = {value = {type = "item", name = stack.name, quality = "normal", comparator = "="}, min = stack.count}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if comb then
|
if comb then
|
||||||
@@ -650,27 +655,12 @@ end
|
|||||||
function update_stop_from_rail(map_data, rail, forbidden_entity, force)
|
function update_stop_from_rail(map_data, rail, forbidden_entity, force)
|
||||||
--NOTE: is this a correct way to figure out the direction?
|
--NOTE: is this a correct way to figure out the direction?
|
||||||
---@type LuaEntity?
|
---@type LuaEntity?
|
||||||
local rail_front = rail
|
local stop = rail.get_rail_segment_stop(defines_front)
|
||||||
---@type LuaEntity?
|
if not stop then
|
||||||
local rail_back = rail
|
stop = rail.get_rail_segment_stop(defines_back)
|
||||||
---@type defines.rail_direction
|
end
|
||||||
for i = 1, 112 do
|
if stop then
|
||||||
if rail_back then
|
resolve_update_stop_from_rail(map_data, stop, forbidden_entity, force)
|
||||||
local entity = rail_back.get_rail_segment_signal(defines_back, false)
|
|
||||||
if entity and entity.name == "train-stop" then
|
|
||||||
resolve_update_stop_from_rail(map_data, entity, forbidden_entity, force)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
rail_back = rail_back.get_connected_rail({rail_direction = defines_back, rail_connection_direction = defines_straight})
|
|
||||||
end
|
|
||||||
if rail_front then
|
|
||||||
local entity = rail_front.get_rail_segment_signal(defines_front, false)
|
|
||||||
if entity and entity.name == "train-stop" then
|
|
||||||
resolve_update_stop_from_rail(map_data, entity, forbidden_entity, force)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
rail_front = rail_front.get_connected_rail({rail_direction = defines_front, rail_connection_direction = defines_straight})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -259,11 +259,13 @@ local function on_combinator_built(map_data, comb)
|
|||||||
force = comb.force
|
force = comb.force
|
||||||
})
|
})
|
||||||
assert(out, "cybersyn: could not spawn combinator controller")
|
assert(out, "cybersyn: could not spawn combinator controller")
|
||||||
local wireConnectorRed = comb.get_wire_connector(defines.wire_connector_id.circuit_red, true)
|
local comb_red = comb.get_wire_connector(defines.wire_connector_id.combinator_output_red, true)
|
||||||
local wireConnectorGreen = comb.get_wire_connector(defines.wire_connector_id.circuit_green, true)
|
local out_red = out.get_wire_connector(defines.wire_connector_id.circuit_red, true)
|
||||||
|
out_red.connect_to(comb_red, false, defines.wire_origin.script)
|
||||||
|
|
||||||
wireConnectorRed.connect_to(out.get_wire_connector(defines.wire_connector_id.circuit_red, true))
|
local comb_green = comb.get_wire_connector(defines.wire_connector_id.combinator_output_green, true)
|
||||||
wireConnectorGreen.connect_to(out.get_wire_connector(defines.wire_connector_id.circuit_green, true))
|
local out_green = out.get_wire_connector(defines.wire_connector_id.circuit_green, true)
|
||||||
|
out_green.connect_to(comb_green, false, defines.wire_origin.script)
|
||||||
|
|
||||||
local control = get_comb_control(comb)
|
local control = get_comb_control(comb)
|
||||||
local params = control.parameters
|
local params = control.parameters
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ local function set_comb1(map_data, station, manifest, sign)
|
|||||||
if manifest then
|
if manifest then
|
||||||
local signals = {}
|
local signals = {}
|
||||||
for i, item in ipairs(manifest) do
|
for i, item in ipairs(manifest) do
|
||||||
signals[i] = {index = i, signal = {type = item.type, name = item.name}, count = sign*item.count}
|
signals[i] = {value = {type = item.type, name = item.name, quality = item.quality or "normal", comparator = "="}, min = sign*item.count}
|
||||||
end
|
end
|
||||||
set_combinator_output(map_data, comb, signals)
|
set_combinator_output(map_data, comb, signals)
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user