mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-10 18:08:13 -06:00
minimum viable product
This commit is contained in:
@@ -7,3 +7,29 @@ cybersyn-provider-threshold=Default provider threshold
|
|||||||
cybersyn-ticks-per-second=How many times per second to check all stations for possible deliveries. This value will be rounded up to a divisor of 60.
|
cybersyn-ticks-per-second=How many times per second to check all stations for possible deliveries. This value will be rounded up to a divisor of 60.
|
||||||
cybersyn-requester-threshold=When a requester threshold signal is not recieved by a station it will default to this value.
|
cybersyn-requester-threshold=When a requester threshold signal is not recieved by a station it will default to this value.
|
||||||
cybersyn-provider-threshold=When a provider threshold signal is not recieved by a station it will default to this value.
|
cybersyn-provider-threshold=When a provider threshold signal is not recieved by a station it will default to this value.
|
||||||
|
|
||||||
|
[item-name]
|
||||||
|
cybersyn-depot=Cybersyn depot
|
||||||
|
cybersyn-station=Cybersyn station
|
||||||
|
|
||||||
|
[item-description]
|
||||||
|
cybersyn-depot=Cybersyn depot
|
||||||
|
cybersyn-station=Cybersyn station
|
||||||
|
|
||||||
|
[entity-name]
|
||||||
|
cybersyn-depot=Cybersyn depot
|
||||||
|
cybersyn-station=Cybersyn station
|
||||||
|
cybersyn-station-out=Cybersyn station output
|
||||||
|
cybersyn-station-in=Cybersyn station input
|
||||||
|
|
||||||
|
[entity-description]
|
||||||
|
cybersyn-depot=Cybersyn depot
|
||||||
|
cybersyn-station=Cybersyn station
|
||||||
|
cybersyn-station-out=Cybersyn station output
|
||||||
|
cybersyn-station-in=Cybersyn station input
|
||||||
|
|
||||||
|
[technology-name]
|
||||||
|
cybersyn-train-network=Cybernetic train network
|
||||||
|
|
||||||
|
[technology-description]
|
||||||
|
cybersyn-train-network=Cybernetic train network
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
--By Mami
|
--By Mami
|
||||||
cybersyn_station_entity = flib.copy_prototype(data.raw["train-stop"]["train-stop"], BUFFER_STATION_NAME)
|
cybersyn_station_entity = flib.copy_prototype(data.raw["train-stop"]["train-stop"], BUFFER_STATION_NAME)
|
||||||
cybersyn_station_entity.icon = "__cybersyn__/graphics/icon/station.png"
|
cybersyn_station_entity.icon = "__cybersyn__/graphics/icons/station.png"
|
||||||
cybersyn_station_entity.icon_size = 64
|
cybersyn_station_entity.icon_size = 64
|
||||||
cybersyn_station_entity.icon_mipmaps = 4
|
cybersyn_station_entity.icon_mipmaps = 4
|
||||||
cybersyn_station_entity.next_upgrade = nil
|
cybersyn_station_entity.next_upgrade = nil
|
||||||
|
|
||||||
cybersyn_depot_entity = flib.copy_prototype(data.raw["train-stop"]["train-stop"], DEPOT_STATION_NAME)
|
cybersyn_depot_entity = flib.copy_prototype(data.raw["train-stop"]["train-stop"], DEPOT_STATION_NAME)
|
||||||
cybersyn_depot_entity.icon = "__cybersyn__/graphics/icon/depot.png"
|
cybersyn_depot_entity.icon = "__cybersyn__/graphics/icons/depot.png"
|
||||||
cybersyn_depot_entity.icon_size = 64
|
cybersyn_depot_entity.icon_size = 64
|
||||||
cybersyn_depot_entity.icon_mipmaps = 4
|
cybersyn_depot_entity.icon_mipmaps = 4
|
||||||
cybersyn_depot_entity.next_upgrade = nil
|
cybersyn_depot_entity.next_upgrade = nil
|
||||||
|
|
||||||
cybersyn_station_in = flib.copy_prototype(data.raw["lamp"]["small-lamp"], STATION_IN_NAME)
|
cybersyn_station_in = flib.copy_prototype(data.raw["lamp"]["small-lamp"], STATION_IN_NAME)
|
||||||
cybersyn_station_in.icon = "__cybersyn__/graphics/icon/station.png"
|
cybersyn_station_in.icon = "__cybersyn__/graphics/icons/station.png"
|
||||||
cybersyn_station_in.icon_size = 64
|
cybersyn_station_in.icon_size = 64
|
||||||
cybersyn_station_in.icon_mipmaps = 4
|
cybersyn_station_in.icon_mipmaps = 4
|
||||||
cybersyn_station_in.next_upgrade = nil
|
cybersyn_station_in.next_upgrade = nil
|
||||||
cybersyn_station_in.minable = nil
|
cybersyn_station_in.minable = nil
|
||||||
cybersyn_station_in.selection_box = {{-0.5, -0.5}, {0.5, 0.5}}
|
cybersyn_station_in.selection_box = {{-0.5, -0.5}, {0.5, 0.5}}
|
||||||
cybersyn_station_in.selection_priority = cybersyn_station_in.selection_priority + 10
|
cybersyn_station_in.selection_priority = 60
|
||||||
cybersyn_station_in.collision_box = {{-0.15, -0.15}, {0.15, 0.15}}
|
cybersyn_station_in.collision_box = {{-0.15, -0.15}, {0.15, 0.15}}
|
||||||
cybersyn_station_in.collision_mask = {"rail-layer"}
|
cybersyn_station_in.collision_mask = {"rail-layer"}
|
||||||
cybersyn_station_in.energy_usage_per_tick = "10W"
|
cybersyn_station_in.energy_usage_per_tick = "10W"
|
||||||
@@ -26,12 +26,12 @@ cybersyn_station_in.light = {intensity = 1, size = 6}
|
|||||||
cybersyn_station_in.energy_source = {type="void"}
|
cybersyn_station_in.energy_source = {type="void"}
|
||||||
|
|
||||||
cybersyn_station_out = flib.copy_prototype(data.raw["constant-combinator"]["constant-combinator"],STATION_OUT_NAME)
|
cybersyn_station_out = flib.copy_prototype(data.raw["constant-combinator"]["constant-combinator"],STATION_OUT_NAME)
|
||||||
cybersyn_station_out.icon = "__cybersyn__/graphics/icon/station.png"
|
cybersyn_station_out.icon = "__cybersyn__/graphics/icons/station.png"
|
||||||
cybersyn_station_out.icon_size = 64
|
cybersyn_station_out.icon_size = 64
|
||||||
cybersyn_station_out.icon_mipmaps = 4
|
cybersyn_station_out.icon_mipmaps = 4
|
||||||
cybersyn_station_out.next_upgrade = nil
|
cybersyn_station_out.next_upgrade = nil
|
||||||
cybersyn_station_out.minable = nil
|
cybersyn_station_out.minable = nil
|
||||||
cybersyn_station_out.selection_box = {{-0.5, -0.5}, {0.5, 0.5}}
|
cybersyn_station_out.selection_box = {{-0.5, -0.5}, {0.5, 0.5}}
|
||||||
cybersyn_station_out.selection_priority = cybersyn_station_out.selection_priority + 10
|
cybersyn_station_out.selection_priority = 60
|
||||||
cybersyn_station_out.collision_box = {{-0.15, -0.15}, {0.15, 0.15}}
|
cybersyn_station_out.collision_box = {{-0.15, -0.15}, {0.15, 0.15}}
|
||||||
cybersyn_station_out.collision_mask = {"rail-layer"}
|
cybersyn_station_out.collision_mask = {"rail-layer"}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ cybersyn_station_recipe.ingredients = {
|
|||||||
}
|
}
|
||||||
cybersyn_station_recipe.enabled = false
|
cybersyn_station_recipe.enabled = false
|
||||||
|
|
||||||
cybersyn_depot_recipe = flib.copy_prototype(data.raw["recipe"]["train-stop"], BUFFER_STATION_NAME)
|
cybersyn_depot_recipe = flib.copy_prototype(data.raw["recipe"]["train-stop"], DEPOT_STATION_NAME)
|
||||||
cybersyn_depot_recipe.ingredients = {
|
cybersyn_depot_recipe.ingredients = {
|
||||||
{"train-stop", 1},
|
{"train-stop", 1},
|
||||||
{"electronic-circuit", 5},
|
{"electronic-circuit", 5},
|
||||||
@@ -15,8 +15,8 @@ cybersyn_depot_recipe.enabled = false
|
|||||||
|
|
||||||
cybersyn_tech = {
|
cybersyn_tech = {
|
||||||
type = "technology",
|
type = "technology",
|
||||||
name = "cybernetic-train-network",
|
name = "cybersyn-train-network",
|
||||||
icon = "__cybersyn__/graphics/icon/tech.png",
|
icon = "__cybersyn__/graphics/icons/tech.png",
|
||||||
icon_size = 64,
|
icon_size = 64,
|
||||||
icon_mipmaps = 4,
|
icon_mipmaps = 4,
|
||||||
prerequisites = {
|
prerequisites = {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ local INF = math.huge
|
|||||||
|
|
||||||
local function icpairs(a, start_i)
|
local function icpairs(a, start_i)
|
||||||
if #a == 0 then
|
if #a == 0 then
|
||||||
return nil
|
return function() end
|
||||||
end
|
end
|
||||||
start_i = start_i%#a + 1
|
start_i = start_i%#a + 1
|
||||||
local i = start_i - 1
|
local i = start_i - 1
|
||||||
@@ -126,34 +126,38 @@ local function send_train_between(map_data, r_station_id, p_station_id, train, p
|
|||||||
local manifest = {}
|
local manifest = {}
|
||||||
|
|
||||||
local r_signals = get_signals(r_station)
|
local r_signals = get_signals(r_station)
|
||||||
for k, v in pairs(r_signals) do
|
if r_signals then
|
||||||
local item_name = v.signal.name
|
for k, v in pairs(r_signals) do
|
||||||
local item_count = v.count
|
local item_name = v.signal.name
|
||||||
local item_type = v.signal.type
|
local item_count = v.count
|
||||||
if item_name and item_type and item_type ~= "virtual" then
|
local item_type = v.signal.type
|
||||||
local effective_item_count = item_count + r_station.deliveries[item_name]
|
if item_name and item_type and item_type ~= "virtual" then
|
||||||
if -effective_item_count >= r_station.r_threshold then
|
local effective_item_count = item_count + r_station.deliveries[item_name]
|
||||||
requests[item_name] = -effective_item_count
|
if -effective_item_count >= r_station.r_threshold then
|
||||||
|
requests[item_name] = -effective_item_count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local p_signals = get_signals(r_station)
|
local p_signals = get_signals(r_station)
|
||||||
for k, v in pairs(p_signals) do
|
if p_signals then
|
||||||
local item_name = v.signal.name
|
for k, v in pairs(p_signals) do
|
||||||
local item_count = v.count
|
local item_name = v.signal.name
|
||||||
local item_type = v.signal.type
|
local item_count = v.count
|
||||||
if item_name and item_type and item_type ~= "virtual" then
|
local item_type = v.signal.type
|
||||||
local effective_item_count = item_count + p_station.deliveries[item_name]
|
if item_name and item_type and item_type ~= "virtual" then
|
||||||
if effective_item_count >= p_station.p_threshold then
|
local effective_item_count = item_count + p_station.deliveries[item_name]
|
||||||
local r = requests[item_name]
|
if effective_item_count >= p_station.p_threshold then
|
||||||
if r then
|
local r = requests[item_name]
|
||||||
local item = {name = item_name, count = math.min(r, effective_item_count), type = item_type}
|
if r then
|
||||||
if item_name == primary_item_name then
|
local item = {name = item_name, count = math.min(r, effective_item_count), type = item_type}
|
||||||
manifest[#manifest + 1] = manifest[1]
|
if item_name == primary_item_name then
|
||||||
manifest[1] = item
|
manifest[#manifest + 1] = manifest[1]
|
||||||
else
|
manifest[1] = item
|
||||||
manifest[#manifest + 1] = item
|
else
|
||||||
|
manifest[#manifest + 1] = item
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -260,44 +264,46 @@ function tick(map_data, mod_settings)
|
|||||||
station.p_threshold = mod_settings.p_threshold
|
station.p_threshold = mod_settings.p_threshold
|
||||||
station.priority = 0
|
station.priority = 0
|
||||||
local signals = get_signals(station)
|
local signals = get_signals(station)
|
||||||
for k, v in pairs(signals) do
|
if signals then
|
||||||
local item_name = v.signal.name
|
for k, v in pairs(signals) do
|
||||||
local item_count = v.count
|
local item_name = v.signal.name
|
||||||
local item_type = v.signal.type
|
local item_count = v.count
|
||||||
if item_name and item_type then
|
local item_type = v.signal.type
|
||||||
if item_type == "virtual" then
|
if item_name and item_type then
|
||||||
if item_name == SIGNAL_PRIORITY then
|
if item_type == "virtual" then
|
||||||
station.priority = item_count
|
if item_name == SIGNAL_PRIORITY then
|
||||||
elseif item_name == REQUEST_THRESHOLD then
|
station.priority = item_count
|
||||||
station.r_threshold = math.abs(item_count)
|
elseif item_name == REQUEST_THRESHOLD then
|
||||||
elseif item_name == PROVIDE_THRESHOLD then
|
station.r_threshold = math.abs(item_count)
|
||||||
station.p_threshold = math.abs(item_count)
|
elseif item_name == PROVIDE_THRESHOLD then
|
||||||
|
station.p_threshold = math.abs(item_count)
|
||||||
|
end
|
||||||
|
signals[k] = nil
|
||||||
end
|
end
|
||||||
|
else
|
||||||
signals[k] = nil
|
signals[k] = nil
|
||||||
end
|
end
|
||||||
else
|
|
||||||
signals[k] = nil
|
|
||||||
end
|
end
|
||||||
end
|
for k, v in pairs(signals) do
|
||||||
for k, v in pairs(signals) do
|
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]
|
||||||
local effective_item_count = item_count + station.deliveries[item_name]
|
|
||||||
|
|
||||||
if -effective_item_count >= station.r_threshold then
|
if -effective_item_count >= station.r_threshold then
|
||||||
if r_stations_all[item_name] == nil then
|
if r_stations_all[item_name] == nil then
|
||||||
r_stations_all[item_name] = {}
|
r_stations_all[item_name] = {}
|
||||||
p_stations_all[item_name] = {}
|
p_stations_all[item_name] = {}
|
||||||
all_items[#all_items + 1] = item_name
|
all_items[#all_items + 1] = item_name
|
||||||
|
end
|
||||||
|
table.insert(r_stations_all[item_name], station_id)
|
||||||
|
elseif effective_item_count >= station.p_threshold then
|
||||||
|
if r_stations_all[item_name] == nil then
|
||||||
|
r_stations_all[item_name] = {}
|
||||||
|
p_stations_all[item_name] = {}
|
||||||
|
all_items[#all_items + 1] = item_name
|
||||||
|
end
|
||||||
|
table.insert(p_stations_all[item_name], station_id)
|
||||||
end
|
end
|
||||||
table.insert(r_stations_all[item_name], station_id)
|
|
||||||
elseif effective_item_count >= station.p_threshold then
|
|
||||||
if r_stations_all[item_name] == nil then
|
|
||||||
r_stations_all[item_name] = {}
|
|
||||||
p_stations_all[item_name] = {}
|
|
||||||
all_items[#all_items + 1] = item_name
|
|
||||||
end
|
|
||||||
table.insert(p_stations_all[item_name], station_id)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ Layout: string
|
|||||||
]]
|
]]
|
||||||
--TODO: only init once
|
--TODO: only init once
|
||||||
mod_settings = {}
|
mod_settings = {}
|
||||||
mod_settings.tps = settings.global["cybersyn-ticks-per-second"]
|
mod_settings.tps = settings.global["cybersyn-ticks-per-second"].value
|
||||||
mod_settings.r_threshold = settings.global["cybersyn-requester-threshold"]
|
mod_settings.r_threshold = settings.global["cybersyn-requester-threshold"].value
|
||||||
mod_settings.p_threshold = settings.global["cybersyn-provider-threshold"]
|
mod_settings.p_threshold = settings.global["cybersyn-provider-threshold"].value
|
||||||
|
|
||||||
global.total_ticks = 0
|
global.total_ticks = 0
|
||||||
global.stations = {}
|
global.stations = {}
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ local function on_broken(event)
|
|||||||
on_train_broken(global, entity.train)
|
on_train_broken(global, entity.train)
|
||||||
end
|
end
|
||||||
elseif entity.name == BUFFER_STATION_NAME then
|
elseif entity.name == BUFFER_STATION_NAME then
|
||||||
on_station_broken(entity.unit_number)
|
on_station_broken(global, entity)
|
||||||
elseif entity.type == "inserter" then
|
elseif entity.type == "inserter" then
|
||||||
elseif entity.type == "pump" then
|
elseif entity.type == "pump" then
|
||||||
end
|
end
|
||||||
@@ -500,7 +500,7 @@ local function on_surface_removed(event)
|
|||||||
local train_stops = surface.find_entities_filtered({type = "train-stop"})
|
local train_stops = surface.find_entities_filtered({type = "train-stop"})
|
||||||
for _, entity in pairs(train_stops) do
|
for _, entity in pairs(train_stops) do
|
||||||
if entity.name == BUFFER_STATION_NAME then
|
if entity.name == BUFFER_STATION_NAME then
|
||||||
on_station_broken(entity.unit_number)
|
on_station_broken(global, entity)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user