minimum viable product

This commit is contained in:
Monica Moniot
2022-10-16 02:23:47 -04:00
parent 131e9fab15
commit 8f514d3913
6 changed files with 102 additions and 70 deletions

View File

@@ -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

View File

@@ -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"}

View File

@@ -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 = {

View File

@@ -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,6 +126,7 @@ local function send_train_between(map_data, r_station_id, p_station_id, train, p
local manifest = {}
local r_signals = get_signals(r_station)
if r_signals then
for k, v in pairs(r_signals) do
local item_name = v.signal.name
local item_count = v.count
@@ -137,8 +138,10 @@ local function send_train_between(map_data, r_station_id, p_station_id, train, p
end
end
end
end
local p_signals = get_signals(r_station)
if p_signals then
for k, v in pairs(p_signals) do
local item_name = v.signal.name
local item_count = v.count
@@ -159,6 +162,7 @@ local function send_train_between(map_data, r_station_id, p_station_id, train, p
end
end
end
end
local total_slots_left = train.item_slot_capacity
local total_liquid_left = train.fluid_capacity
@@ -260,6 +264,7 @@ function tick(map_data, mod_settings)
station.p_threshold = mod_settings.p_threshold
station.priority = 0
local signals = get_signals(station)
if signals then
for k, v in pairs(signals) do
local item_name = v.signal.name
local item_count = v.count
@@ -302,6 +307,7 @@ function tick(map_data, mod_settings)
end
end
end
end
local failed_because_missing_trains_total = 0
--we do not dispatch more than one train per station per tick

View File

@@ -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 = {}

View File

@@ -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