Compare commits

...

4 commits

Author SHA1 Message Date
TheSAguy
e30fbfeaad Fix arboretum 2025-08-31 06:34:54 +02:00
TheSAguy
5964b4e1f6 Bio Garden Addition 2025-08-31 06:31:00 +02:00
Simon Brodtmann
afcf60b8d7 Graphics Update 2025-08-31 06:30:29 +02:00
TheSAguy
b23ec80c43 Cleanup/fixes 2025-08-31 06:26:50 +02:00
394 changed files with 1255 additions and 473 deletions

View file

@ -460,10 +460,14 @@ local function On_Built(event)
elseif entity.type == "electric-pole" then
local pole = entity
-- Make sure hidden poles of the Bio gardens are connected correctly!
if pole.name == entities["bi-bio-garden"].hidden[h_key].name and base then
BioInd.writeDebug("Bio garden!")
BioInd.connect_garden_pole(base, pole)
BioInd.writeDebug("Connected %s (%s)", { pole.name, pole.unit_number or "nil" })
local garden_names = { "bi-bio-garden", "bi-bio-garden-larger", "bi-bio-garden-huge" }
for _, gname in ipairs(garden_names) do
if entities[gname] and pole.name == entities[gname].hidden[h_key].name and base then
BioInd.writeDebug("Bio garden (" .. gname .. ")!")
BioInd.connect_garden_pole(base, pole)
BioInd.writeDebug("Connected %s (%s)", { pole.name, pole.unit_number or "nil" })
break
end
end
-- A seedling has been planted
@ -645,16 +649,37 @@ end
-- Radar stuff
--------------------------------------------------------------------
-- Radar completed a sector scan
-- Robust sector scanned handler for Arboretum radar
local function On_Sector_Scanned(event)
local f_name = "On_Sector_Scanned"
BioInd.writeDebug("Entered function %s(%s)", { f_name, event })
-- defensive checks
BioInd.writeDebug("On_Sector_Scanned fired")
--game.print("On_Sector_Scanned fired")
if not (event and event.radar) then return end
local radar = event.radar
if not (radar.valid and radar.unit_number) then return end
---- Each time a Arboretum-Radar scans a sector ----
local arboretum = storage.bi_arboretum_radar_table[event.radar.unit_number]
if arboretum then
Get_Arboretum_Recipe(storage.bi_arboretum_table[arboretum], event)
-- Make sure compound-entity data is available before accessing it
local arb_proto = BioInd.compound_entities and BioInd.compound_entities["bi-arboretum"]
if not (arb_proto and arb_proto.hidden and arb_proto.hidden.radar and arb_proto.hidden.radar.name) then
-- not ready yet (init not finished) — bail out safely
return
end
-- Only handle scans from our arboretum radar type
if radar.name ~= arb_proto.hidden.radar.name then return end
-- Look up the base arboretum unit_number (stored when the hidden radar was created)
local base_unit_number = storage.bi_arboretum_radar_table and storage.bi_arboretum_radar_table[radar.unit_number]
if not base_unit_number then
-- no mapping found -> nothing to do
return
end
local arb_table = storage.bi_arboretum_table and storage.bi_arboretum_table[base_unit_number]
if not arb_table then return end
-- All good: call the arboretum recipe handler
Get_Arboretum_Recipe(arb_table, event)
end

View file

@ -42,12 +42,21 @@ end
-- Check that all ingredients are available!
local function check_ingredients(arboretum)
local recipe = arboretum.get_recipe()
local need = recipe and storage.bi_arboretum_recipe_table[recipe.name]
if not recipe then
--game.print("No recipe set on arboretum")
return nil
end
--game.print("Recipe name: " .. recipe.name)
local need = storage.bi_arboretum_recipe_table[recipe.name]
if not need then
--game.print("No recipe data found for " .. recipe.name)
return nil
end
local function check(need, have)
for name, amount in pairs(need or {}) do
if not (have and have[name]) or (have[name] < amount) then
BioInd.writeDebug("Missing ingredient %s (have %s of %s)", { name, have[name] or 0, amount })
--game.print("Missing ingredient " .. name .. " (have " .. (have[name] or 0) .. " of " .. amount .. ")")
return false
end
end
@ -55,9 +64,38 @@ local function check_ingredients(arboretum)
end
local inventory = arboretum.get_inventory(defines.inventory.assembling_machine_input)
local inv_contents_raw = inventory and inventory.get_contents() or {}
-- Check if inv_contents_raw is a map or list, convert if needed
local function is_map(t)
if type(t) ~= "table" then return false end
for k, v in pairs(t) do
if type(k) ~= "string" or type(v) ~= "number" then
return false
end
end
return true
end
local inv_contents
if is_map(inv_contents_raw) then
inv_contents = inv_contents_raw
else
-- Convert list of item stacks to map
inv_contents = {}
for _, item in pairs(inv_contents_raw) do
inv_contents[item.name] = (inv_contents[item.name] or 0) + item.count
end
end
local fluid_contents = arboretum.get_fluid_contents() or {}
--game.print("Inventory contents (map): " .. serpent.line(inv_contents))
--game.print("Fluid contents: " .. serpent.line(fluid_contents))
return need and
check(need.items, inventory and inventory.get_contents()) and
check(need.fluids, arboretum.get_fluid_contents()) and
check(need.items, inv_contents) and
check(need.fluids, fluid_contents) and
{ ingredients = need, name = recipe.name } or nil
end
@ -111,10 +149,14 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
local check = check_ingredients(arboretum)
local ingredients, recipe_name
if check then
--game.print("There are ingredients")
ingredients, recipe_name = check.ingredients, check.name
else
--game.print("No ingredients")
end
if ingredients then
local create_seedling, new_plant
pos = BioInd.normalize_position(arboretum.position) or
BioInd.arg_err("nil", "position")

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 914 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Some files were not shown because too many files have changed in this diff Show more