mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-09 18:08:06 -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-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.
|
||||
|
||||
[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
|
||||
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_mipmaps = 4
|
||||
cybersyn_station_entity.next_upgrade = nil
|
||||
|
||||
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_mipmaps = 4
|
||||
cybersyn_depot_entity.next_upgrade = nil
|
||||
|
||||
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_mipmaps = 4
|
||||
cybersyn_station_in.next_upgrade = nil
|
||||
cybersyn_station_in.minable = nil
|
||||
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_mask = {"rail-layer"}
|
||||
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_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_mipmaps = 4
|
||||
cybersyn_station_out.next_upgrade = nil
|
||||
cybersyn_station_out.minable = nil
|
||||
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_mask = {"rail-layer"}
|
||||
|
||||
@@ -6,7 +6,7 @@ cybersyn_station_recipe.ingredients = {
|
||||
}
|
||||
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 = {
|
||||
{"train-stop", 1},
|
||||
{"electronic-circuit", 5},
|
||||
@@ -15,8 +15,8 @@ cybersyn_depot_recipe.enabled = false
|
||||
|
||||
cybersyn_tech = {
|
||||
type = "technology",
|
||||
name = "cybernetic-train-network",
|
||||
icon = "__cybersyn__/graphics/icon/tech.png",
|
||||
name = "cybersyn-train-network",
|
||||
icon = "__cybersyn__/graphics/icons/tech.png",
|
||||
icon_size = 64,
|
||||
icon_mipmaps = 4,
|
||||
prerequisites = {
|
||||
|
||||
@@ -5,7 +5,7 @@ local INF = math.huge
|
||||
|
||||
local function icpairs(a, start_i)
|
||||
if #a == 0 then
|
||||
return nil
|
||||
return function() end
|
||||
end
|
||||
start_i = start_i%#a + 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 r_signals = get_signals(r_station)
|
||||
for k, v in pairs(r_signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local item_type = v.signal.type
|
||||
if item_name and item_type and item_type ~= "virtual" then
|
||||
local effective_item_count = item_count + r_station.deliveries[item_name]
|
||||
if -effective_item_count >= r_station.r_threshold then
|
||||
requests[item_name] = -effective_item_count
|
||||
if r_signals then
|
||||
for k, v in pairs(r_signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local item_type = v.signal.type
|
||||
if item_name and item_type and item_type ~= "virtual" then
|
||||
local effective_item_count = item_count + r_station.deliveries[item_name]
|
||||
if -effective_item_count >= r_station.r_threshold then
|
||||
requests[item_name] = -effective_item_count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local p_signals = get_signals(r_station)
|
||||
for k, v in pairs(p_signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local item_type = v.signal.type
|
||||
if item_name and item_type and item_type ~= "virtual" then
|
||||
local effective_item_count = item_count + p_station.deliveries[item_name]
|
||||
if effective_item_count >= p_station.p_threshold then
|
||||
local r = requests[item_name]
|
||||
if r then
|
||||
local item = {name = item_name, count = math.min(r, effective_item_count), type = item_type}
|
||||
if item_name == primary_item_name then
|
||||
manifest[#manifest + 1] = manifest[1]
|
||||
manifest[1] = item
|
||||
else
|
||||
manifest[#manifest + 1] = item
|
||||
if p_signals then
|
||||
for k, v in pairs(p_signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local item_type = v.signal.type
|
||||
if item_name and item_type and item_type ~= "virtual" then
|
||||
local effective_item_count = item_count + p_station.deliveries[item_name]
|
||||
if effective_item_count >= p_station.p_threshold then
|
||||
local r = requests[item_name]
|
||||
if r then
|
||||
local item = {name = item_name, count = math.min(r, effective_item_count), type = item_type}
|
||||
if item_name == primary_item_name then
|
||||
manifest[#manifest + 1] = manifest[1]
|
||||
manifest[1] = item
|
||||
else
|
||||
manifest[#manifest + 1] = item
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -260,44 +264,46 @@ function tick(map_data, mod_settings)
|
||||
station.p_threshold = mod_settings.p_threshold
|
||||
station.priority = 0
|
||||
local signals = get_signals(station)
|
||||
for k, v in pairs(signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local item_type = v.signal.type
|
||||
if item_name and item_type then
|
||||
if item_type == "virtual" then
|
||||
if item_name == SIGNAL_PRIORITY then
|
||||
station.priority = item_count
|
||||
elseif item_name == REQUEST_THRESHOLD then
|
||||
station.r_threshold = math.abs(item_count)
|
||||
elseif item_name == PROVIDE_THRESHOLD then
|
||||
station.p_threshold = math.abs(item_count)
|
||||
if signals then
|
||||
for k, v in pairs(signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local item_type = v.signal.type
|
||||
if item_name and item_type then
|
||||
if item_type == "virtual" then
|
||||
if item_name == SIGNAL_PRIORITY then
|
||||
station.priority = item_count
|
||||
elseif item_name == REQUEST_THRESHOLD then
|
||||
station.r_threshold = math.abs(item_count)
|
||||
elseif item_name == PROVIDE_THRESHOLD then
|
||||
station.p_threshold = math.abs(item_count)
|
||||
end
|
||||
signals[k] = nil
|
||||
end
|
||||
else
|
||||
signals[k] = nil
|
||||
end
|
||||
else
|
||||
signals[k] = nil
|
||||
end
|
||||
end
|
||||
for k, v in pairs(signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local effective_item_count = item_count + station.deliveries[item_name]
|
||||
for k, v in pairs(signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local effective_item_count = item_count + station.deliveries[item_name]
|
||||
|
||||
if -effective_item_count >= station.r_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
|
||||
if -effective_item_count >= station.r_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(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
|
||||
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
|
||||
|
||||
@@ -47,9 +47,9 @@ Layout: string
|
||||
]]
|
||||
--TODO: only init once
|
||||
mod_settings = {}
|
||||
mod_settings.tps = settings.global["cybersyn-ticks-per-second"]
|
||||
mod_settings.r_threshold = settings.global["cybersyn-requester-threshold"]
|
||||
mod_settings.p_threshold = settings.global["cybersyn-provider-threshold"]
|
||||
mod_settings.tps = settings.global["cybersyn-ticks-per-second"].value
|
||||
mod_settings.r_threshold = settings.global["cybersyn-requester-threshold"].value
|
||||
mod_settings.p_threshold = settings.global["cybersyn-provider-threshold"].value
|
||||
|
||||
global.total_ticks = 0
|
||||
global.stations = {}
|
||||
|
||||
@@ -460,7 +460,7 @@ local function on_broken(event)
|
||||
on_train_broken(global, entity.train)
|
||||
end
|
||||
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 == "pump" then
|
||||
end
|
||||
@@ -500,7 +500,7 @@ local function on_surface_removed(event)
|
||||
local train_stops = surface.find_entities_filtered({type = "train-stop"})
|
||||
for _, entity in pairs(train_stops) do
|
||||
if entity.name == BUFFER_STATION_NAME then
|
||||
on_station_broken(entity.unit_number)
|
||||
on_station_broken(global, entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user