Reformat code

This commit is contained in:
Simon Brodtmann 2025-07-07 23:09:46 +02:00
parent 7134f437e5
commit bac183d1c1
9 changed files with 2438 additions and 2435 deletions

View file

@ -4,82 +4,82 @@
function Test_Spawn()
local surface = game.surfaces['nauvis']
surface.create_entity({name = "tree-01", position = {2, 10}, force = game.forces.player})
surface.create_entity({name = "tree-02", position = {4, 10}, force = game.forces.player})
surface.create_entity({name = "tree-02-red", position = {6, 10}, force = game.forces.player})
surface.create_entity({name = "tree-03", position = {8, 10}, force = game.forces.player})
surface.create_entity({name = "tree-04", position = {10, 10}, force = game.forces.player})
surface.create_entity({name = "tree-05", position = {12, 10}, force = game.forces.player})
surface.create_entity({name = "tree-06", position = {14, 10}, force = game.forces.player})
surface.create_entity({name = "tree-06-brown", position = {16, 10}, force = game.forces.player})
surface.create_entity({name = "tree-07", position = {18, 10}, force = game.forces.player})
surface.create_entity({name = "tree-08", position = {20, 10}, force = game.forces.player})
surface.create_entity({name = "tree-08-brown", position = {22, 10}, force = game.forces.player})
surface.create_entity({name = "tree-09", position = {24, 10}, force = game.forces.player})
surface.create_entity({name = "tree-09-brown", position = {26, 10}, force = game.forces.player})
surface.create_entity({name = "tree-09-red", position = {28, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-a", position = {30, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-b", position = {32, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-c", position = {34, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-d", position = {36, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-e", position = {38, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-f", position = {40, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-g", position = {42, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-h", position = {44, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-i", position = {46, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-j", position = {48, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-k", position = {50, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-l", position = {52, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-m", position = {54, 10}, force = game.forces.player})
surface.create_entity({name = "tree-desert-n", position = {56, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-a", position = {58, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-b", position = {60, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-c", position = {62, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-d", position = {64, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-e", position = {66, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-f", position = {68, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-g", position = {70, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-h", position = {72, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-i", position = {74, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-j", position = {76, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-k", position = {78, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-l", position = {80, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-m", position = {82, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-n", position = {84, 10}, force = game.forces.player})
surface.create_entity({name = "tree-dryland-o", position = {86, 10}, force = game.forces.player})
surface.create_entity({ name = "tree-01", position = { 2, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-02", position = { 4, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-02-red", position = { 6, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-03", position = { 8, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-04", position = { 10, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-05", position = { 12, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-06", position = { 14, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-06-brown", position = { 16, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-07", position = { 18, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-08", position = { 20, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-08-brown", position = { 22, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-09", position = { 24, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-09-brown", position = { 26, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-09-red", position = { 28, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-a", position = { 30, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-b", position = { 32, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-c", position = { 34, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-d", position = { 36, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-e", position = { 38, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-f", position = { 40, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-g", position = { 42, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-h", position = { 44, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-i", position = { 46, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-j", position = { 48, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-k", position = { 50, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-l", position = { 52, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-m", position = { 54, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-desert-n", position = { 56, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-a", position = { 58, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-b", position = { 60, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-c", position = { 62, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-d", position = { 64, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-e", position = { 66, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-f", position = { 68, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-g", position = { 70, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-h", position = { 72, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-i", position = { 74, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-j", position = { 76, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-k", position = { 78, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-l", position = { 80, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-m", position = { 82, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-n", position = { 84, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-dryland-o", position = { 86, 10 }, force = game.forces.player })
--surface.create_entity({name = "tree-grassland-0", position = {88, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-a", position = {90, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-b", position = {92, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-c", position = {94, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-d", position = {96, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-e", position = {98, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-f", position = {100, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-g", position = {102, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-h", position = {104, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-h2", position = {106, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-h3", position = {108, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-i", position = {110, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-k", position = {112, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-l", position = {114, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-m", position = {116, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-n", position = {118, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-p", position = {120, 10}, force = game.forces.player})
surface.create_entity({name = "tree-grassland-q", position = {122, 10}, force = game.forces.player})
surface.create_entity({name = "tree-snow-a", position = {124, 10}, force = game.forces.player})
surface.create_entity({name = "tree-volcanic-a", position = {126, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-a", position = {128, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-b", position = {130, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-c", position = {132, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-d", position = {134, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-e", position = {136, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-f", position = {138, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-g", position = {140, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-h", position = {142, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-i", position = {144, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-j", position = {146, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-k", position = {148, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-l", position = {150, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-m", position = {152, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-n", position = {154, 10}, force = game.forces.player})
surface.create_entity({name = "tree-wetland-o", position = {156, 10}, force = game.forces.player})
surface.create_entity({ name = "tree-grassland-a", position = { 90, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-b", position = { 92, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-c", position = { 94, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-d", position = { 96, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-e", position = { 98, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-f", position = { 100, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-g", position = { 102, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-h", position = { 104, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-h2", position = { 106, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-h3", position = { 108, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-i", position = { 110, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-k", position = { 112, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-l", position = { 114, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-m", position = { 116, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-n", position = { 118, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-p", position = { 120, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-grassland-q", position = { 122, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-snow-a", position = { 124, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-volcanic-a", position = { 126, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-a", position = { 128, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-b", position = { 130, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-c", position = { 132, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-d", position = { 134, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-e", position = { 136, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-f", position = { 138, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-g", position = { 140, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-h", position = { 142, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-i", position = { 144, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-j", position = { 146, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-k", position = { 148, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-l", position = { 150, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-m", position = { 152, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-n", position = { 154, 10 }, force = game.forces.player })
surface.create_entity({ name = "tree-wetland-o", position = { 156, 10 }, force = game.forces.player })
end

View file

@ -14,10 +14,10 @@ end
local AlienBiomes
local Event = require('__kry_stdlib__/stdlib/event/event').set_protected_mode(false)
require ("util")
require ("libs/util_ext")
require ("control_tree")
require ("control_arboretum")
require("util")
require("libs/util_ext")
require("control_tree")
require("control_arboretum")
---************** Used for Testing -----
@ -38,7 +38,7 @@ local function Create_dummy_force()
-- New force won't share chart data with any other force
f.share_chart = false
BioInd.writeDebug("Created force: %s", {game.forces[BioInd.MuskForceName].name})
BioInd.writeDebug("Created force: %s", { game.forces[BioInd.MuskForceName].name })
end
@ -46,10 +46,10 @@ end
local function get_bi_trees()
local list = {}
local trees = prototypes.get_entity_filtered({{filter = "type", type = "tree"}})
local trees = prototypes.get_entity_filtered({ { filter = "type", type = "tree" } })
for tree_name, tree in pairs(trees) do
if tree_name:match("^bio%-tree%-.+%-%d$") then
BioInd.show("Found matching tree", tree_name)
BioInd.show("Found matching tree", tree_name)
list[tree_name] = true
end
end
@ -71,14 +71,14 @@ local function get_fixed_tiles()
for tile_name, tile in pairs(prototypes.tile) do
for p, pattern in ipairs(tile_patterns) do
if tile_name:match(pattern) then
BioInd.show("Found matching tile", tile_name)
BioInd.show("Found matching tile", tile_name)
-- If a tile is minable and fertilizer is used on it, we must deduct the mined
-- tiles from the player/robot again!
list[tile_name] = tile.mineable_properties.products or true
end
end
end
BioInd.show("Forbidden tiles", list)
BioInd.show("Forbidden tiles", list)
return list
end
@ -112,7 +112,7 @@ end
--------------------------------------------------------------------
local function init()
BioInd.writeDebug("Entered init!")
BioInd.writeDebug("Entered init!")
if BioInd.is_debug then
game.check_prototype_translations()
end
@ -162,7 +162,7 @@ BioInd.writeDebug("Entered init!")
-- them to remove duplicates
compound_entity_tables[compound_data.tab] = compound
end
BioInd.show("Need to check these tables in global", compound_entity_tables)
BioInd.show("Need to check these tables in global", compound_entity_tables)
-- Prepare global tables storing data of compound entities
local result
@ -170,14 +170,14 @@ BioInd.show("Need to check these tables in global", compound_entity_tables)
-- Init table
storage[compound_tab] = storage[compound_tab] or {}
BioInd.writeDebug("Initialized storage[%s] (%s entities stored)",
{compound_name, table_size(storage[compound_tab])})
{ compound_name, table_size(storage[compound_tab]) })
-- If this compound entity requires additional tables in global, initialize
-- them now!
local related_tables = storage.compound_entities[compound_name].add_global_tables
if related_tables then
for t, tab in ipairs(related_tables or {}) do
storage[tab] = storage[tab] or {}
BioInd.writeDebug("Initialized storage[%s] (%s values)", {tab, table_size(storage[tab])})
BioInd.writeDebug("Initialized storage[%s] (%s values)", { tab, table_size(storage[tab]) })
end
end
-- If this compound entity requires additional values in global, initialize
@ -186,7 +186,7 @@ BioInd.show("Need to check these tables in global", compound_entity_tables)
if related_vars then
for var_name, value in pairs(related_vars or {}) do
storage[var_name] = storage[var_name] or value
BioInd.writeDebug("Set storage[%s] to %s", {var_name, storage[var_name]})
BioInd.writeDebug("Set storage[%s] to %s", { var_name, storage[var_name] })
end
end
@ -195,16 +195,16 @@ BioInd.show("Need to check these tables in global", compound_entity_tables)
-- Remove invalid entities
result = BioInd.clean_global_compounds_table(compound_name)
BioInd.writeDebug("Removed %s invalid entries from storage[%s]!",
{result, compound_tab})
{ result, compound_tab })
-- Restore missing hidden entities
result = BioInd.restore_missing_entities(compound_name)
BioInd.writeDebug("Checked %s compound entities and restored %s missing hidden entries for storage[\"%s\"]!",
{result.checked, result.restored, compound_tab})
{ result.checked, result.restored, compound_tab })
end
end
-- Search all surfaces for unregistered compound entities
result = BioInd.find_unregistered_entities()
BioInd.writeDebug("Registered %s forgotten entities!", {result})
BioInd.writeDebug("Registered %s forgotten entities!", { result })
@ -236,7 +236,7 @@ BioInd.show("Need to check these tables in global", compound_entity_tables)
-- enable researched recipes
for i, force in pairs(game.forces) do
BioInd.writeDebug("Reset technology effects for force %s.", {force.name})
BioInd.writeDebug("Reset technology effects for force %s.", { force.name })
force.reset_technology_effects()
end
@ -244,20 +244,18 @@ BioInd.show("Need to check these tables in global", compound_entity_tables)
if BioInd.UseMuskForce and not game.forces[BioInd.MuskForceName] then
Create_dummy_force()
end
end
--------------------------------------------------------------------
local function On_Load()
log("Entered On_Load!")
end
--------------------------------------------------------------------
local function On_Config_Change(ConfigurationChangedData)
BioInd.writeDebug("On Configuration changed: %s", {ConfigurationChangedData})
BioInd.writeDebug("On Configuration changed: %s", { ConfigurationChangedData })
-- Re-initialize global tables etc.
@ -278,10 +276,10 @@ BioInd.writeDebug("On Configuration changed: %s", {ConfigurationChangedData})
-- Growing stages
for i = 1, 4 do
tab = storage.bi["tree_growing_stage_" .. i]
BioInd.writeDebug("Number of trees in growing stage %s: %s", {i, table_size(tab)})
BioInd.writeDebug("Number of trees in growing stage %s: %s", { i, table_size(tab) })
for t = #tab, 1, -1 do
if not trees[tab[t].tree_name] then
BioInd.writeDebug("Removing invalid tree %s (%s)", {t, tab[t].tree_name})
BioInd.writeDebug("Removing invalid tree %s (%s)", { t, tab[t].tree_name })
table.remove(tab, t)
end
end
@ -291,7 +289,7 @@ BioInd.writeDebug("Number of trees in growing stage %s: %s", {i, table_size(tab)
-- tree with index 1 when checking if a tree has completed the growing stage, so
-- lets sort the table after all invalid trees have been removed!)
table.sort(tab, function(a, b) return a.time < b.time end)
BioInd.show("Number of trees in final list", #tab)
BioInd.show("Number of trees in final list", #tab)
end
end
@ -334,11 +332,11 @@ Event.register(defines.events.on_trigger_created_entity, function(event)
BioInd.writeDebug("Seed Bomb Activated - Standard")
local currTile = surface.get_tile(position).name
if storage.bi.barren_tiles[currTile] then
BioInd.writeDebug("Can't fertilize %s!", {currTile})
BioInd.writeDebug("Can't fertilize %s!", { currTile })
else
BioInd.writeDebug("Using fertilizer!")
local terrain_name_s = AlienBiomes and "vegetation-green-grass-3" or "grass-3"
surface.set_tiles{{name = terrain_name_s, position = position}}
surface.set_tiles { { name = terrain_name_s, position = position } }
end
seed_planted_trigger(event)
@ -347,11 +345,11 @@ Event.register(defines.events.on_trigger_created_entity, function(event)
BioInd.writeDebug("Seed Bomb Activated - Advanced")
local currTile = surface.get_tile(position).name
if storage.bi.barren_tiles[currTile] then
BioInd.writeDebug("Can't fertilize %s!", {currTile})
BioInd.writeDebug("Can't fertilize %s!", { currTile })
else
BioInd.writeDebug("Using fertilizer!")
local terrain_name_a = AlienBiomes and "vegetation-green-grass-1" or "grass-1"
surface.set_tiles{{name = terrain_name_a, position = position}}
surface.set_tiles { { name = terrain_name_a, position = position } }
end
seed_planted_trigger(event)
end
@ -375,7 +373,7 @@ local function On_Built(event)
-- We can ignore ghosts -- if ghosts are revived, there will be
-- another event that triggers where actual entities are placed!
if entity.name == "entity-ghost" then
BioInd.writeDebug("Built ghost of %s -- return!", {entity.ghost_name})
BioInd.writeDebug("Built ghost of %s -- return!", { entity.ghost_name })
return
end
@ -390,16 +388,17 @@ local function On_Built(event)
-- remove anything from it for real.
local hidden_entities = util.table.deepcopy(base_entry.hidden)
BioInd.writeDebug("%s (%s) is a compound entity. Need to create %s", {base.name, base.unit_number, hidden_entities})
BioInd.show("hidden_entities", hidden_entities)
BioInd.writeDebug("%s (%s) is a compound entity. Need to create %s",
{ base.name, base.unit_number, hidden_entities })
BioInd.show("hidden_entities", hidden_entities)
local new_base
local new_base_name = base_entry.new_base_name
-- If the base entity is only an overlay, we'll replace it with the real base
-- entity and raise an event. The hidden entities will be created in the second
-- pass (triggered by building the final entity).
BioInd.show("base_entry.new_base_name", base_entry.new_base_name)
BioInd.show("base_entry.new_base_name == base.name", base_entry.new_base_name == base.name)
BioInd.show("base_entry.optional", base_entry.optional)
BioInd.show("base_entry.new_base_name", base_entry.new_base_name)
BioInd.show("base_entry.new_base_name == base.name", base_entry.new_base_name == base.name)
BioInd.show("base_entry.optional", base_entry.optional)
if new_base_name and new_base_name ~= base.name then
new_base = surface.create_entity({
name = new_base_name,
@ -411,39 +410,39 @@ BioInd.show("base_entry.optional", base_entry.optional)
new_base.health = base.health
BioInd.show("Created final base entity", BioInd.print_name_id(new_base))
base.destroy({raise_destroy = true})
base.destroy({ raise_destroy = true })
base = new_base
BioInd.writeDebug("Destroyed old base entity!")
-- Second pass: We've placed the final base entity now, so we can create the
-- the hidden entities!
else
BioInd.writeDebug("Second pass -- creating hidden entities!")
BioInd.show("base_entry", base_entry)
BioInd.writeDebug("Second pass -- creating hidden entities!")
BioInd.show("base_entry", base_entry)
BioInd.writeDebug("storage[%s]: %s", {base_entry.tab, storage[base_entry.tab]})
BioInd.show("base.name", base.name)
BioInd.show("base.unit_number", base.unit_number)
BioInd.show("hidden_entities", hidden_entities)
BioInd.writeDebug("storage[%s]: %s", { base_entry.tab, storage[base_entry.tab] })
BioInd.show("base.name", base.name)
BioInd.show("base.unit_number", base.unit_number)
BioInd.show("hidden_entities", hidden_entities)
-- We must call create_entities even if there are no hidden entities (e.g. if
-- the "Easy Gardens" setting is disabled and no hidden poles are required)
-- because the compound entity gets registered there!
BioInd.create_entities(storage[base_entry.tab], base, hidden_entities)
BioInd.writeDebug("Stored %s in table: %s",
{BioInd.print_name_id(base), storage[base_entry.tab][base.unit_number]})
{ BioInd.print_name_id(base), storage[base_entry.tab][base.unit_number] })
end
-- The built entity isn't one of our compound entities.
else
BioInd.writeDebug("%s is not a compound entity!", {BioInd.print_name_id(entity)})
BioInd.writeDebug("%s is not a compound entity!", { BioInd.print_name_id(entity) })
-- If one of our hidden entities has been built, we'll have raised this event
-- ourselves and have passed on the base entity.
base = event.base_entity
local entities = BioInd.compound_entities
BioInd.show("Base entity", BioInd.print_name_id(base))
BioInd.show("Base entity", BioInd.print_name_id(base))
-- The hidden entities are listed with a common handle ("pole", "panel" etc.). We
-- can get it from the reverse-lookup list via the entity type!
@ -455,16 +454,16 @@ BioInd.show("Base entity", BioInd.print_name_id(base))
entity.name == entities["bi-arboretum-area"].hidden[h_key].name and base then
storage.bi_arboretum_radar_table[entity.unit_number] = base.unit_number
entity.backer_name = ""
BioInd.writeDebug("Added %s to storage.bi_arboretum_radar_table", {BioInd.print_name_id(entity)})
BioInd.writeDebug("Added %s to storage.bi_arboretum_radar_table", { BioInd.print_name_id(entity) })
-- Electric poles -- we need to take care that they don't hook up to hidden poles!
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.writeDebug("Bio garden!")
BioInd.connect_garden_pole(base, pole)
BioInd.writeDebug("Connected %s (%s)", {pole.name, pole.unit_number or "nil"})
BioInd.writeDebug("Connected %s (%s)", { pole.name, pole.unit_number or "nil" })
end
-- A seedling has been planted
@ -474,7 +473,7 @@ BioInd.writeDebug("Bio garden!")
-- Something else has been built
else
BioInd.writeDebug("Nothing to do for %s!", {entity.name})
BioInd.writeDebug("Nothing to do for %s!", { entity.name })
end
end
BioInd.writeDebug("End of function On_Built")
@ -482,7 +481,7 @@ end
local function remove_plants(entity_position, tabl)
BioInd.writeDebug("Entered function remove_plants(%s, %s)", {entity_position or "nil", tabl or "nil"})
BioInd.writeDebug("Entered function remove_plants(%s, %s)", { entity_position or "nil", tabl or "nil" })
local e = BioInd.normalize_position(entity_position)
if not e then
BioInd.arg_err(entity_position or "nil", "position")
@ -494,7 +493,7 @@ BioInd.writeDebug("Entered function remove_plants(%s, %s)", {entity_position or
for k, v in pairs(tabl or {}) do
pos = BioInd.normalize_position(v.position)
if pos and pos.x == e.x and pos.y == e.y then
BioInd.writeDebug("Removing entry %s from table: %s", {k, v})
BioInd.writeDebug("Removing entry %s from table: %s", { k, v })
table.remove(tabl, k)
break
end
@ -504,7 +503,7 @@ end
--------------------------------------------------------------------
local function On_Pre_Remove(event)
BioInd.writeDebug("Entered function On_Pre_Remove(%s)", {event})
BioInd.writeDebug("Entered function On_Pre_Remove(%s)", { event })
local entity = event.entity
if not (entity and entity.valid) then
@ -514,40 +513,41 @@ BioInd.writeDebug("Entered function On_Pre_Remove(%s)", {event})
local compound_entity = storage.compound_entities[entity.name]
local base_entry = compound_entity and storage[compound_entity.tab][entity.unit_number]
BioInd.show("entity.name", entity.name)
BioInd.show("entity.unit_number", entity.unit_number)
BioInd.show("entity.name", entity.name)
BioInd.show("entity.unit_number", entity.unit_number)
BioInd.show("compound_entity", compound_entity)
BioInd.show("base_entry", base_entry)
BioInd.show("compound_entity.tab", compound_entity and compound_entity.tab or "nil")
BioInd.writeDebug("storage[%s]: %s", {compound_entity and compound_entity.tab or "nil", compound_entity and storage[compound_entity.tab] or "nil"})
BioInd.show("compound_entity", compound_entity)
BioInd.show("base_entry", base_entry)
BioInd.show("compound_entity.tab", compound_entity and compound_entity.tab or "nil")
BioInd.writeDebug("storage[%s]: %s",
{ compound_entity and compound_entity.tab or "nil", compound_entity and storage[compound_entity.tab] or "nil" })
-- Found a compound entity from our list!
if base_entry then
BioInd.writeDebug("Found compound entity %s",
{base_entry.base and BioInd.print_name_id(base_entry.base)})
BioInd.writeDebug("Found compound entity %s",
{ base_entry.base and BioInd.print_name_id(base_entry.base) })
-- Arboretum: Need to separately remove the entry from the radar table
if entity.name == "bi-arboretum" and base_entry.radar and base_entry.radar.valid then
storage.bi_arboretum_radar_table[base_entry.radar.unit_number] = nil
BioInd.show("Removed arboretum radar! Table", storage.bi_arboretum_radar_table)
BioInd.show("Removed arboretum radar! Table", storage.bi_arboretum_radar_table)
end
-- Power rails: Connections must be explicitely removed, otherwise the poles
-- from the remaining rails will automatically connect and bridge the gap in
-- the power supply!
if entity.name:match("bi%-%a+%-rail%-power") and base_entry.pole and base_entry.pole.valid then
BioInd.writeDebug("Before")
BioInd.writeDebug("Disconnecting %s!", {BioInd.print_name_id(base_entry.pole)})
BioInd.writeDebug("Before")
BioInd.writeDebug("Disconnecting %s!", { BioInd.print_name_id(base_entry.pole) })
base_entry.pole.disconnect_neighbour()
BioInd.writeDebug("After")
BioInd.writeDebug("After")
end
-- Default: Remove all hidden entities!
for hidden, h_name in pairs(compound_entity.hidden or {}) do
BioInd.show("hidden", hidden)
BioInd.show("hidden", hidden)
BioInd.writeDebug("Removing hidden entity %s", {BioInd.print_name_id(base_entry[hidden])})
BioInd.writeDebug("Removing hidden entity %s", { BioInd.print_name_id(base_entry[hidden]) })
BioInd.remove_entity(base_entry[hidden])
base_entry[hidden] = nil
end
@ -559,7 +559,7 @@ BioInd.writeDebug("Removing hidden entity %s", {BioInd.print_name_id(base_entry[
elseif entity.name == "bi-power-to-rail-pole" then
BioInd.writeDebug("Rail-to-power connector has been removed")
entity.disconnect_neighbour()
BioInd.writeDebug("Removed copper wires from %s (%g)", {entity.name, entity.unit_number})
BioInd.writeDebug("Removed copper wires from %s (%g)", { entity.name, entity.unit_number })
-- Removed seedling
elseif entity.name == "seedling" then
@ -571,7 +571,7 @@ BioInd.writeDebug("Removing hidden entity %s", {BioInd.print_name_id(base_entry[
BioInd.show("Removed tree", entity.name)
local tree_stage = entity.name:match('^.+%-(%d)$')
BioInd.writeDebug("Removed tree %s (grow stage: %s)", {entity.name, tree_stage or nil})
BioInd.writeDebug("Removed tree %s (grow stage: %s)", { entity.name, tree_stage or nil })
if tree_stage then
remove_plants(entity.position, storage.bi["tree_growing_stage_" .. tree_stage])
else
@ -580,7 +580,7 @@ BioInd.writeDebug("Removed tree %s (grow stage: %s)", {entity.name, tree_stage o
-- Removed something else
else
BioInd.writeDebug("%s has been removed -- nothing to do!", {entity.name})
BioInd.writeDebug("%s has been removed -- nothing to do!", { entity.name })
end
end
@ -588,7 +588,7 @@ end
--------------------------------------------------------------------
local function On_Damage(event)
local f_name = "On_Damage"
BioInd.writeDebug("Entered function %s(%s)", {f_name, event})
BioInd.writeDebug("Entered function %s(%s)", { f_name, event })
local entity = event.entity
local final_health = event.final_health
@ -618,7 +618,7 @@ end
--------------------------------------------------------------------
local function On_Death(event)
local f_name = "On_Death"
BioInd.writeDebug("Entered function %s(%s)", {f_name, event})
BioInd.writeDebug("Entered function %s(%s)", { f_name, event })
local entity = event.entity
if not entity then
@ -633,7 +633,6 @@ BioInd.writeDebug("Entered function %s(%s)", {f_name, event})
entity.name == storage.compound_entities["bi-arboretum"].hidden.radar.name or
entity.name == "bi-power-to-rail-pole" or
entity.name == "seedling" then
BioInd.writeDebug("Divert to On_Pre_Remove!")
On_Pre_Remove(event)
else
@ -649,7 +648,7 @@ end
-- Radar completed a sector scan
local function On_Sector_Scanned(event)
local f_name = "On_Sector_Scanned"
BioInd.writeDebug("Entered function %s(%s)", {f_name, event})
BioInd.writeDebug("Entered function %s(%s)", { f_name, event })
---- Each time a Arboretum-Radar scans a sector ----
local arboretum = storage.bi_arboretum_radar_table[event.radar.unit_number]
@ -666,7 +665,7 @@ end
--------------------------------------------------------------------
-- Solar mat was removed
local function solar_mat_removed(event)
BioInd.writeDebug("Entered solar_mat_removed (\"%s\")", {event})
BioInd.writeDebug("Entered solar_mat_removed (\"%s\")", { event })
local surface = game.surfaces[event.surface_index]
local tiles = event.tiles
@ -678,12 +677,12 @@ local function solar_mat_removed(event)
pos = BioInd.normalize_position(tile.position)
x, y = pos.x, pos.y
BioInd.writeDebug("Looking for hidden entities to remove")
for _, o in pairs(surface.find_entities_filtered{
name = {'bi-musk-mat-hidden-pole', 'bi-musk-mat-hidden-panel'},
position = {x + 0.5, y + 0.5}
BioInd.writeDebug("Looking for hidden entities to remove")
for _, o in pairs(surface.find_entities_filtered {
name = { 'bi-musk-mat-hidden-pole', 'bi-musk-mat-hidden-panel' },
position = { x + 0.5, y + 0.5 }
} or {}) do
BioInd.show("Removing", o.name)
BioInd.show("Removing", o.name)
o.destroy()
end
@ -692,7 +691,7 @@ BioInd.show("Removing", o.name)
storage.bi_musk_floor_table.tiles[x] and
storage.bi_musk_floor_table.tiles[x][y]
if force_name then
BioInd.writeDebug("Removing Musk floor tile from tables!")
BioInd.writeDebug("Removing Musk floor tile from tables!")
storage.bi_musk_floor_table.tiles[x][y] = nil
if not next(storage.bi_musk_floor_table.tiles[x]) then
storage.bi_musk_floor_table.tiles[x] = nil
@ -706,11 +705,10 @@ BioInd.writeDebug("Removing Musk floor tile from tables!")
end
end
end
end
end
BioInd.writeDebug("bi-solar-mat: removed %g tiles", {table_size(tiles)})
BioInd.writeDebug("bi-solar-mat: removed %g tiles", { table_size(tiles) })
end
@ -723,11 +721,11 @@ local function place_musk_floor(force, position, surface)
local x, y = position.x, position.y
local created
for n, name in ipairs({"bi-musk-mat-hidden-pole", "bi-musk-mat-hidden-panel"}) do
created = surface.create_entity({name = name, position = {x + 0.5, y + 0.5}, force = force})
for n, name in ipairs({ "bi-musk-mat-hidden-pole", "bi-musk-mat-hidden-panel" }) do
created = surface.create_entity({ name = name, position = { x + 0.5, y + 0.5 }, force = force })
created.minable = false
created.destructible = false
BioInd.writeDebug("Created %s: %s", {name, created.unit_number})
BioInd.writeDebug("Created %s: %s", { name, created.unit_number })
end
-- Add to global tables!
@ -742,7 +740,7 @@ end
--------------------------------------------------------------------
-- Solar mat was built
local function solar_mat_built(event)
BioInd.show("Entered function \"solar_mat_built\"", event)
BioInd.show("Entered function \"solar_mat_built\"", event)
-- Called from player, bot and script-raised events, so event may
-- contain "robot" or "player_index"
@ -754,7 +752,7 @@ BioInd.show("Entered function \"solar_mat_built\"", event)
(event.player_index and game.players[event.player_index].force.name) or
(event.robot and event.robot.force.name) or
event.force.name
BioInd.show("Force.name", force)
BioInd.show("Force.name", force)
-- Item that was used to place the tile
local item = event.item
@ -767,19 +765,19 @@ BioInd.show("Force.name", force)
-- Musk floor has been built -- create hidden entities!
if tile.name == "bi-solar-mat" then
BioInd.writeDebug("Solar Mat has been built -- must create hidden entities!")
BioInd.show("Tile data", tile )
BioInd.show("Tile data", tile)
for index, t in pairs(old_tiles or {tile}) do
BioInd.show("Read old_tile inside loop", t)
for index, t in pairs(old_tiles or { tile }) do
BioInd.show("Read old_tile inside loop", t)
-- event.tiles will also contain landscape tiles like "grass-1", and it will always
-- contain at least one tile
position = BioInd.normalize_position(t.position)
-- If we got here by a call from script_raised_built, force may be stored
-- with the tile
force = force or t.force
BioInd.show("Got force from tile data", t.force or "false")
BioInd.show("Got force from tile data", t.force or "false")
BioInd.writeDebug("Building solar mat for force %s at position %s",
{tostring(type(force) == "table" and force.name or force), position})
{ tostring(type(force) == "table" and force.name or force), position })
place_musk_floor(force, position, surface)
end
@ -787,38 +785,37 @@ BioInd.show("Got force from tile data", t.force or "false")
-- Fertilizer/Advanced fertilizer has been used. Check if the tile was valid
-- (no Musk floor, no wooden floor, no concrete etc.)
elseif item and (item.name == "fertilizer" or item.name == "bi-adv-fertilizer") then
local restore_tiles = {}
local products, remove_this
for index, t in pairs(old_tiles or {tile}) do
BioInd.show("index", index)
BioInd.show("t.old_tile.name", t.old_tile.name)
for index, t in pairs(old_tiles or { tile }) do
BioInd.show("index", index)
BioInd.show("t.old_tile.name", t.old_tile.name)
-- We want to restore removed tiles if nothing is supposed to grow on them!
if storage.bi.barren_tiles[t.old_tile.name] then
BioInd.writeDebug("%s was used on forbidden ground (%s)!", {item.name, t.old_tile.name})
restore_tiles[#restore_tiles + 1] = {name = t.old_tile.name, position = t.position}
BioInd.writeDebug("%s was used on forbidden ground (%s)!", { item.name, t.old_tile.name })
restore_tiles[#restore_tiles + 1] = { name = t.old_tile.name, position = t.position }
-- Is that tile minable?
products = storage.bi.barren_tiles[t.old_tile.name]
if type(products) == "table" then
for p, product in ipairs(products) do
remove_this = {name = product.name, count = product.amount}
remove_this = { name = product.name, count = product.amount }
if player then
BioInd.writeDebug("Removing %s (%s) from player %s",
{product.name, product.amount, player.name})
{ product.name, product.amount, player.name })
player.remove_item(remove_this)
elseif robot then
BioInd.writeDebug("Removing %s (%s) from robot %s",
{product.name, product.amount, robot.unit_number})
{ product.name, product.amount, robot.unit_number })
robot.remove_item(remove_this)
end
end
end
end
end
BioInd.show("restore_tiles", restore_tiles)
BioInd.show("restore_tiles", restore_tiles)
if restore_tiles then
surface.set_tiles(
restore_tiles,
@ -833,7 +830,7 @@ BioInd.show("restore_tiles", restore_tiles)
else
local test
local removed_tiles = {}
for index, t in pairs(old_tiles or {tile}) do
for index, t in pairs(old_tiles or { tile }) do
position = BioInd.normalize_position(t.position)
test = storage.bi_musk_floor_table and
storage.bi_musk_floor_table.tiles and
@ -841,18 +838,17 @@ BioInd.show("restore_tiles", restore_tiles)
storage.bi_musk_floor_table.tiles[position.x][position.y]
if test then
removed_tiles[#removed_tiles + 1] = {
old_tile = {name = "bi-solar-mat"},
old_tile = { name = "bi-solar-mat" },
position = position
}
end
end
if next(removed_tiles) then
solar_mat_removed({surface_index = event.surface_index, tiles = removed_tiles})
solar_mat_removed({ surface_index = event.surface_index, tiles = removed_tiles })
else
BioInd.writeDebug("%s has been built -- nothing to do!", {tile.name})
BioInd.writeDebug("%s has been built -- nothing to do!", { tile.name })
end
end
end
@ -860,7 +856,7 @@ end
-- A tille has been changed
local function Tile_Changed(event)
local f_name = "Tile_Changed"
BioInd.writeDebug("Entered function %s(%s)", {f_name, event})
BioInd.writeDebug("Entered function %s(%s)", { f_name, event })
-- The event gives us only a list of the new tiles that have been placed.
-- So let's check if any Musk floor has been built!
@ -872,7 +868,7 @@ local function Tile_Changed(event)
local tile_force
for t, tile in ipairs(event.tiles) do
BioInd.show("t", t)
BioInd.show("t", t)
pos = BioInd.normalize_position(tile.position)
tile_force = storage.bi_musk_floor_table.tiles[pos.x] and
storage.bi_musk_floor_table.tiles[pos.x][pos.y]
@ -894,7 +890,7 @@ BioInd.show("t", t)
BioInd.writeDebug("Fertilizer was used!")
-- Fertilizer was used on a Musk floor tile -- restore the tile!
BioInd.show("Musk floor tile in position", tile_force)
BioInd.show("Musk floor tile in position", tile_force)
if tile_force then
old_musk_floor_tiles[#old_musk_floor_tiles + 1] = {
old_tile = { name = "bi-solar-mat" },
@ -910,14 +906,14 @@ BioInd.show("Musk floor tile in position", tile_force)
}
end
end
BioInd.show("new_musk_floor_tiles", new_musk_floor_tiles)
BioInd.show("old_musk_floor_tiles", old_musk_floor_tiles)
BioInd.show("remove_musk_floor_tiles", remove_musk_floor_tiles)
BioInd.show("new_musk_floor_tiles", new_musk_floor_tiles)
BioInd.show("old_musk_floor_tiles", old_musk_floor_tiles)
BioInd.show("remove_musk_floor_tiles", remove_musk_floor_tiles)
if next(new_musk_floor_tiles) then
solar_mat_built({
surface_index = event.surface_index,
tile = {name = "bi-solar-mat"},
tile = { name = "bi-solar-mat" },
force = BioInd.MuskForceName,
tiles = new_musk_floor_tiles
})
@ -925,12 +921,12 @@ BioInd.show("remove_musk_floor_tiles", remove_musk_floor_tiles)
if next(old_musk_floor_tiles) then
solar_mat_built({
surface_index = event.surface_index,
tile = {name = "bi-solar-mat"},
tile = { name = "bi-solar-mat" },
tiles = old_musk_floor_tiles
})
end
if next(remove_musk_floor_tiles) then
solar_mat_removed({surface_index = event.surface_index, tiles = remove_musk_floor_tiles})
solar_mat_removed({ surface_index = event.surface_index, tiles = remove_musk_floor_tiles })
end
BioInd.show("End of function", f_name)
end
@ -956,7 +952,7 @@ Event.pre_remove_events = {
defines.events.on_player_mined_entity,
defines.events.on_robot_mined_entity,
}
Event.death_events = {
Event.death_events = {
defines.events.on_entity_died,
defines.events.script_raised_destroy
}
@ -1009,14 +1005,14 @@ Event.register(Event.tile_script_action, Tile_Changed)
-- (Thanks to eradicator!) --
------------------------------------------------------------------------------------
setmetatable(_ENV, {
__newindex = function (self, key, value) --locked_global_write
__newindex = function(self, key, value) --locked_global_write
error('\n\n[ER Global Lock] Forbidden global *write*:\n'
.. serpent.line{key = key or '<nil>', value = value or '<nil>'} .. '\n')
.. serpent.line { key = key or '<nil>', value = value or '<nil>' } .. '\n')
end,
__index = function (self, key) --locked_global_read
__index = function(self, key) --locked_global_read
if not (key == "game" or key == "mods" or key == "storage") then
error('\n\n[ER Global Lock] Forbidden global *read*:\n'
.. serpent.line{key = key or '<nil>'} .. '\n')
.. serpent.line { key = key or '<nil>' } .. '\n')
end
end
})

View file

@ -1,4 +1,3 @@
BioInd.writeDebug("Entered control_arboretum.lua")
---Arboretum Stuff
@ -36,7 +35,7 @@ local function get_new_position(pos)
local xxx = math.random(-plant_radius, plant_radius)
local yyy = math.random(-plant_radius, plant_radius)
return {x = pos.x + xxx, y = pos.y + yyy}
return { x = pos.x + xxx, y = pos.y + yyy }
end
@ -48,7 +47,7 @@ local function check_ingredients(arboretum)
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})
BioInd.writeDebug("Missing ingredient %s (have %s of %s)", { name, have[name] or 0, amount })
return false
end
end
@ -59,30 +58,30 @@ local function check_ingredients(arboretum)
return need and
check(need.items, inventory and inventory.get_contents()) and
check(need.fluids, arboretum.get_fluid_contents()) and
{ingredients = need, name = recipe.name} or nil
{ ingredients = need, name = recipe.name } or nil
end
local function consume_ingredients(arboretum, need)
local inventory = arboretum.get_inventory(defines.inventory.assembling_machine_input)
for item, i in pairs(need.items or {}) do
inventory.remove({name = item, count = i})
BioInd.writeDebug("Removed %s (%s)", {item, i})
inventory.remove({ name = item, count = i })
BioInd.writeDebug("Removed %s (%s)", { item, i })
end
BioInd.show("Inventory", inventory.get_contents() or "nil")
BioInd.show("Inventory", inventory.get_contents() or "nil")
for fluid, f in pairs(need.fluids or {}) do
arboretum.remove_fluid({name = fluid, amount = f})
BioInd.writeDebug("Removed %s (%s)", {fluid, f})
arboretum.remove_fluid({ name = fluid, amount = f })
BioInd.writeDebug("Removed %s (%s)", { fluid, f })
end
BioInd.show("Fluid contents", arboretum.get_fluid_contents() or "nil")
BioInd.show("Fluid contents", arboretum.get_fluid_contents() or "nil")
end
local function set_tile(current, target, surface, position)
if current ~= target then
surface.set_tiles(
{{name = target, position = position}},
{ { name = target, position = position } },
true, -- correct_tiles
true, -- remove_colliding_entities
true, -- remove_colliding_decoratives
@ -92,7 +91,7 @@ local function set_tile(current, target, surface, position)
end
function Get_Arboretum_Recipe(ArboretumTable, event)
BioInd.writeDebug("Entered function Get_Arboretum_Recipe(%s, %s)", {ArboretumTable, event})
BioInd.writeDebug("Entered function Get_Arboretum_Recipe(%s, %s)", { ArboretumTable, event })
if not ArboretumTable then
BioInd.writeDebug("%s is not a valid ArboretumTable. Leaving immediately!")
return
@ -129,7 +128,7 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
for k = 1, 10 do
new_position = get_new_position(pos)
new_plant = {
name= "seedling",
name = "seedling",
position = new_position,
force = "neutral"
}
@ -156,14 +155,14 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
if Bi_Industries.fertility[currentTilename] and not Terrain_Check_1[currentTilename] then
consume_ingredients(arboretum, ingredients)
BioInd.writeDebug("%s: Changing terrain from %s to %s (%s)",
{k, currentTilename or "unknown tile",
terrain_name_g3, serpent.line(new_position)})
{ k, currentTilename or "unknown tile",
terrain_name_g3, serpent.line(new_position) })
set_tile(currentTilename, terrain_name_g3, surface, new_position)
--- After sucessfully changing the terrain, break out of the loop.
break
else
BioInd.writeDebug("%s: Can't change terrain (%s)",
{k, currentTilename or "unknown tile"})
{ k, currentTilename or "unknown tile" })
end
end
-- Fertilize the ground with advanced fertilizer. Ignore tiles listed in Terrain_Check_2!
@ -177,14 +176,14 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
if Bi_Industries.fertility[currentTilename] and currentTilename ~= terrain_name_g1 then
consume_ingredients(arboretum, ingredients)
BioInd.writeDebug("%s: Changing terrain from %s to %s (%s)",
{k, currentTilename or "unknown tile",
terrain_name_g1, serpent.line(new_position)})
{ k, currentTilename or "unknown tile",
terrain_name_g1, serpent.line(new_position) })
set_tile(currentTilename, terrain_name_g1, surface, new_position)
--- After sucessfully changing the terrain, break out of the loop.
break
else
BioInd.writeDebug("%s: Can't change terrain (%s)",
{k, currentTilename or "unknown tile"})
{ k, currentTilename or "unknown tile" })
end
end
-- Fertilize the ground with normal fertilizer. Ignore tiles listed in Terrain_Check_1!
@ -196,7 +195,7 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
new_position = get_new_position(pos)
currentTilename = surface.get_tile(new_position.x, new_position.y).name
new_plant = {
name= "seedling",
name = "seedling",
position = new_position,
force = "neutral"
}
@ -206,7 +205,7 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
consume_ingredients(arboretum, ingredients)
-- Refund fertilizer -- no need to waste it on fertile ground!
if Terrain_Check_1[currentTilename] then
arboretum.insert({name = "fertilizer", count = ingredients.items.fertilizer})
arboretum.insert({ name = "fertilizer", count = ingredients.items.fertilizer })
BioInd.writeDebug("Refunded fertilizer!")
end
@ -217,7 +216,7 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
break
else
BioInd.writeDebug("%s: Can't change terrain and plant a tree (%s)",
{k, currentTilename or "unknown tile"})
{ k, currentTilename or "unknown tile" })
end
end
-- Fertilize the ground with advanced fertilizer. Ignore tiles listed in Terrain_Check_2!
@ -229,7 +228,7 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
new_position = get_new_position(pos)
currentTilename = surface.get_tile(new_position.x, new_position.y).name
new_plant = {
name= "seedling",
name = "seedling",
position = new_position,
force = "neutral"
}
@ -246,12 +245,12 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
set_tile(currentTilename, terrain_name_g1, surface, new_position)
create_seedling = surface.create_entity(new_plant)
seed_planted_arboretum (event, create_seedling)
seed_planted_arboretum(event, create_seedling)
--- After sucessfully planting a tree or changing the terrain, break out of the loop.
break
else
BioInd.writeDebug("%s: Can't change terrain and plant a tree (%s)",
{k, currentTilename or "unknown tile"})
{ k, currentTilename or "unknown tile" })
end
end
else

View file

@ -1,4 +1,3 @@
-- All tree Growing stuff
local Event = require('__kry_stdlib__/stdlib/event/event').set_protected_mode(true)
@ -233,8 +232,8 @@ local function get_tile_fertility(surface, position, tile_name)
local fertility = Bi_Industries.fertility[tile_name]
return fertility and {fertility = fertility, key = "fertilizer"} or
{fertility = 1, key = "default"}
return fertility and { fertility = fertility, key = "fertilizer" } or
{ fertility = 1, key = "default" }
end
@ -255,12 +254,12 @@ local function plant_tree(tabl, tree, create_entity)
end
local grow_until_tick = tree.time
BioInd.show("grow_until_tick", grow_until_tick)
BioInd.show("grow_until_tick", grow_until_tick)
tabl[grow_until_tick] = tabl[grow_until_tick] or {}
-- Update table
table.insert(tabl[grow_until_tick], tree)
BioInd.writeDebug("Added tree to table!")
BioInd.writeDebug("Added tree to table!")
-- Plant the new tree
if create_entity then
@ -275,17 +274,17 @@ end
-- t_base, t_penalty: numbers; seedbomb: Boolean
local function plant_seed(event, t_base, t_penalty, seedbomb)
for a, arg in pairs({
{arg = event, type = "table"},
{arg = t_base, type = "number"},
{arg = t_penalty, type = "number"}
{ arg = event, type = "table" },
{ arg = t_base, type = "number" },
{ arg = t_penalty, type = "number" }
}) do
BioInd.check_args(arg.arg, arg.type, arg.desc)
end
BioInd.show("event", event)
BioInd.show("t_base", t_base)
BioInd.show("t_penalty", t_penalty)
BioInd.show("seedbomb", seedbomb)
BioInd.show("event", event)
BioInd.show("t_base", t_base)
BioInd.show("t_penalty", t_penalty)
BioInd.show("seedbomb", seedbomb)
-- Seed Planted (Put the seedling in the table)
local entity = event.entity or event.created_entity or
BioInd.arg_err("nil", "entity")
@ -322,7 +321,6 @@ function seed_planted_arboretum(event, entity)
plant_seed(event, 2000, 6000, false)
end
function summ_weight(tabl)
local summ = 0
for i, tree_weights in pairs(tabl or {}) do
@ -349,12 +347,12 @@ function tree_from_max_index_tabl(max_index, tabl)
end
local function random_tree(tile_name)
BioInd.show("[random_tree] tile_name", tile_name)
BioInd.show("[random_tree] tile_name", tile_name)
if terrains[tile_name] then
local trees_table = terrains[tile_name]
local max_index = summ_weight(trees_table)
BioInd.writeDebug("Found %s in table terrains.\tmax_index: %s",
{tile_name, max_index})
{ tile_name, max_index })
return tree_from_max_index_tabl(max_index, trees_table)
end
end
@ -363,16 +361,16 @@ end
-- Settings used for the different grow stages
local stage_settings = {
[1] = {
fertilizer = {max = 1500, penalty = 3000, factor = 30},
default = {max = 1500, penalty = 6000, factor = 30},
fertilizer = { max = 1500, penalty = 3000, factor = 30 },
default = { max = 1500, penalty = 6000, factor = 30 },
},
[2] = {
fertilizer = {max = 1000, penalty = 2000, factor = 20},
default = {max = 1500, penalty = 6000, factor = 30},
fertilizer = { max = 1000, penalty = 2000, factor = 20 },
default = { max = 1500, penalty = 6000, factor = 30 },
},
[3] = {
fertilizer = {max = 1000, penalty = 2000, factor = 20},
default = {max = 1500, penalty = 6000, factor = 30},
fertilizer = { max = 1000, penalty = 2000, factor = 20 },
default = { max = 1500, penalty = 6000, factor = 30 },
},
}
@ -389,26 +387,26 @@ local function Grow_tree_first_stage(first_stage_table, event)
local tree2 = surface.find_entity("seedling-2", position)
local tree3 = surface.find_entity("seedling-3", position)
BioInd.writeDebug("tree: %s\ttree2: %s\ttree3: %s",
{tree and tree.valid and tree.name or "nil",
{ tree and tree.valid and tree.name or "nil",
tree2 and tree2.valid and tree2.name or "nil",
tree3 and tree3.valid and tree3.name or "nil"})
tree3 and tree3.valid and tree3.name or "nil" })
local tile_name = surface.get_tile(position).name
-- fertility will be 1 if terrain type is not listed above, so very small chance to grow.
local f = get_tile_fertility(surface, position, tile_name)
local fertility, key = f.fertility, f.key
BioInd.show("fertility", fertility)
BioInd.show("key", key)
BioInd.show("fertility", fertility)
BioInd.show("key", key)
-- Random value. Tree will grow if this value is smaller than the 'Fertility' value
local growth_chance = math.random(100)
local tree_name, can_be_placed
if tree or tree2 or tree3 then
BioInd.writeDebug("Found a seedling!")
BioInd.writeDebug("Found a seedling!")
tree_name = random_tree(tile_name)
end
BioInd.show("tree_name", tree_name)
BioInd.show("tree_name", tree_name)
if tree then
@ -425,23 +423,23 @@ BioInd.show("tree_name", tree_name)
can_be_placed = surface.can_place_entity({
name = tree_name, position = position, force = "neutral"
})
BioInd.show("can_be_placed", can_be_placed)
BioInd.show("growth_chance", growth_chance)
BioInd.show("fertility", fertility)
BioInd.show(growth_chance.." <= ("..fertility.." + 5)", growth_chance <= (fertility + 5))
BioInd.show("can_be_placed", can_be_placed)
BioInd.show("growth_chance", growth_chance)
BioInd.show("fertility", fertility)
BioInd.show(growth_chance .. " <= (" .. fertility .. " + 5)", growth_chance <= (fertility + 5))
if can_be_placed and growth_chance <= (fertility + 5) then
BioInd.writeDebug("Can be placed etc!")
-- Trees will grow faster on Fertile than on barren tiles
local grow_time = math.max(1, math.random(2000) + 4000 - (40 * fertility))
BioInd.show("grow_time", grow_time)
BioInd.show("grow_time", grow_time)
local stage_1_tree_name = "bio-tree-"..tree_name.."-1"
local stage_1_tree_name = "bio-tree-" .. tree_name .. "-1"
if not (prototypes.item[stage_1_tree_name] or
prototypes.entity[stage_1_tree_name]) then
stage_1_tree_name = tree_name
end
BioInd.writeDebug("stage_1_tree_name: %s", {stage_1_tree_name})
BioInd.writeDebug("stage_1_tree_name: %s", { stage_1_tree_name })
local tree_data = {
tree_name = stage_1_tree_name,
@ -456,9 +454,9 @@ BioInd.writeDebug("stage_1_tree_name: %s", {stage_1_tree_name})
end
--- Seed Bomb Code
BioInd.show("tree_name", tree_name)
BioInd.show("tree2", tree2)
BioInd.show("tree3", tree3)
BioInd.show("tree_name", tree_name)
BioInd.show("tree2", tree2)
BioInd.show("tree3", tree3)
if seed_bomb then
BioInd.writeDebug("Seed bomb was used!")
@ -472,17 +470,17 @@ BioInd.show("tree3", tree3)
end
--- Depending on Terrain, choose tree type & Convert seedling into a tree
BioInd.show("key", key)
BioInd.show("key", key)
if key == "fertilizer" then
BioInd.writeDebug("Got Tile")
if tree_name then
BioInd.writeDebug("Found Tree: %s", {tree_name})
local new_tree = {name = tree_name, position = position, force = "neutral"}
BioInd.writeDebug("Found Tree: %s", { tree_name })
local new_tree = { name = tree_name, position = position, force = "neutral" }
can_be_placed = surface.can_place_entity(new_tree)
BioInd.show("can_be_placed", can_be_placed)
BioInd.show("growth_chance", growth_chance)
BioInd.show("fertility", fertility)
BioInd.show("growth_chance <= fertility", growth_chance <= fertility)
BioInd.show("can_be_placed", can_be_placed)
BioInd.show("growth_chance", growth_chance)
BioInd.show("fertility", fertility)
BioInd.show("growth_chance <= fertility", growth_chance <= fertility)
if can_be_placed and growth_chance <= fertility then
surface.create_entity(new_tree)
BioInd.writeDebug("Created new tree!")
@ -524,9 +522,8 @@ local function Grow_tree_last_stage(last_stage_table)
--- Convert growing tree to fully grown tree
if (key == "fertilizer" or growth_chance <= fertility) then
-- Grow the new tree
BioInd.writeDebug("Final Tree Name: %s", {final_tree})
BioInd.writeDebug("Final Tree Name: %s", { final_tree })
surface.create_entity({
name = final_tree,
position = position,
@ -538,7 +535,7 @@ end
local function Grow_tree_stage(stage_table, stage)
BioInd.writeDebug("Entered function Grow_tree_stage(%s, %s)", {stage_table, stage})
BioInd.writeDebug("Entered function Grow_tree_stage(%s, %s)", { stage_table, stage })
BioInd.check_args(stage_table, "table")
BioInd.check_args(stage, "number")
@ -546,9 +543,9 @@ BioInd.writeDebug("Entered function Grow_tree_stage(%s, %s)", {stage_table, stag
Grow_tree_last_stage(stage_table)
else
for a, arg in pairs({
{arg = stage_table.tree_name, type = "string", desc = "tree_name"},
{arg = stage_table.final_tree, type = "string", desc = "final_tree"},
{arg = stage_table.time, type = "number", desc = "time"},
{ arg = stage_table.tree_name, type = "string", desc = "tree_name" },
{ arg = stage_table.final_tree, type = "string", desc = "final_tree" },
{ arg = stage_table.time, type = "number", desc = "time" },
}) do
BioInd.check_args(arg.arg, arg.type, arg.desc)
end
@ -574,23 +571,22 @@ BioInd.writeDebug("Entered function Grow_tree_stage(%s, %s)", {stage_table, stag
local f = get_tile_fertility(surface, position)
local fertility, key = f.fertility, f.key
local next_stage_tree_name = "bio-tree-"..final_tree.."-"..next_stage
local next_stage_tree_name = "bio-tree-" .. final_tree .. "-" .. next_stage
if not (prototypes.item[next_stage_tree_name] or
prototypes.entity[next_stage_tree_name]) then
next_stage_tree_name = final_tree
BioInd.writeDebug("Next stage %g: Prototype did not exist", {next_stage})
BioInd.writeDebug("Next stage %g: Prototype did not exist", { next_stage })
else
BioInd.writeDebug("Next stage %g: %s", {next_stage, next_stage_tree_name})
BioInd.writeDebug("Next stage %g: %s", { next_stage, next_stage_tree_name })
end
local can_be_placed = surface.can_place_entity{
local can_be_placed = surface.can_place_entity {
name = next_stage_tree_name,
position = position,
force = "neutral"
}
if can_be_placed then
if next_stage_tree_name == final_tree then
BioInd.writeDebug("Tree reached final stage, don't insert")
surface.create_entity({
@ -610,10 +606,9 @@ BioInd.writeDebug("Entered function Grow_tree_stage(%s, %s)", {stage_table, stag
time = time_planted + grow_time,
surface = surface
}
plant_tree(storage.bi["tree_growing_stage_"..next_stage], tree_data, true)
plant_tree(storage.bi["tree_growing_stage_" .. next_stage], tree_data, true)
end
end
else
BioInd.writeDebug("Did not find that tree I was looking for...")
end
@ -626,7 +621,7 @@ end
Event.register(defines.events.on_tick, function(event)
if storage.bi.tree_growing_stage_1 == nil then
for i = 1, 4 do
storage.bi["tree_growing_stage_"..i] = storage.bi["tree_growing_stage_"..i] or {}
storage.bi["tree_growing_stage_" .. i] = storage.bi["tree_growing_stage_" .. i] or {}
end
end
@ -634,23 +629,23 @@ Event.register(defines.events.on_tick, function(event)
if storage.bi.tree_growing[tick] then
for t, tree_data in pairs(storage.bi.tree_growing[tick]) do
BioInd.writeDebug("Trying to move tree %s to first grow stage!", {t})
BioInd.writeDebug("Trying to move tree %s to first grow stage!", { t })
Grow_tree_first_stage(tree_data, event)
end
BioInd.writeDebug("Removing storage.bi.tree_growing[%s]!", {tick})
BioInd.writeDebug("Removing storage.bi.tree_growing[%s]!", { tick })
storage.bi.tree_growing[tick] = nil
end
local stage_table
for stage = 1, 4 do
stage_table = storage.bi["tree_growing_stage_"..stage]
stage_table = storage.bi["tree_growing_stage_" .. stage]
if stage_table[tick] then
for t, tree_data in pairs(stage_table[tick]) do
BioInd.writeDebug("Moving tree %s to next grow stage!", {t})
BioInd.writeDebug("Moving tree %s to next grow stage!", { t })
Grow_tree_stage(tree_data, stage)
end
BioInd.writeDebug("Removing storage.bi.tree_growing_stage_%s[%s]!",
{stage, tick})
{ stage, tick })
stage_table[tick] = nil
end
end

View file

@ -14,13 +14,12 @@ for name, _ in pairs(ignore_trees or {}) do
BioInd.show("Removed tree prototype", name)
end
end
BioInd.writeDebug("Removed %g tree prototypes. Number of trees to ignore now: %g", {removed, table_size(ignore_trees)})
BioInd.writeDebug("Removed %g tree prototypes. Number of trees to ignore now: %g", { removed, table_size(ignore_trees) })
BI.Settings.BI_Game_Tweaks_Emissions_Multiplier = settings.startup["BI_Game_Tweaks_Emissions_Multiplier"].value
---- Game Tweaks ---- Tree
if BI.Settings.BI_Game_Tweaks_Tree then
local new_results = {
{
type = "item",
@ -32,8 +31,11 @@ if BI.Settings.BI_Game_Tweaks_Tree then
for tree_name, tree in pairs(data.raw["tree"] or {}) do
if tree.minable and not ignore_trees[tree_name] then
BioInd.writeDebug("Tree name: %s\tminable.result: %s\tminable.count: %s", {tree.name, (tree.minable and tree.minable.result or "nil"), (tree.minable and tree.minable.count or "nil")}, "line")
BioInd.writeDebug("Tree name: %s\tminable.results: %s", {tree.name, (tree.minable and tree.minable.results or "nil")}, "line")
BioInd.writeDebug("Tree name: %s\tminable.result: %s\tminable.count: %s",
{ tree.name, (tree.minable and tree.minable.result or "nil"), (tree.minable and tree.minable.count or "nil") },
"line")
BioInd.writeDebug("Tree name: %s\tminable.results: %s",
{ tree.name, (tree.minable and tree.minable.results or "nil") }, "line")
--CHECK FOR SINGLE RESULTS
-- mining.result may be set although mining.results exists (mining.result
-- will be ignored in that case; happens, for example with IR2's rubber
@ -44,7 +46,7 @@ BioInd.writeDebug("Tree name: %s\tminable.results: %s", {tree.name, (tree.minabl
BioInd.writeDebug("Tree has minable.result")
--CHECK FOR VANILLA TREES WOOD x 4
if tree.minable.result == "wood" and tree.minable.count == 4 then
BioInd.writeDebug("Changing wood yield of %s to random value.", {tree.name})
BioInd.writeDebug("Changing wood yield of %s to random value.", { tree.name })
tree.minable.mining_particle = "wooden-particle"
tree.minable.mining_time = 1.5
tree.minable.results = new_results
@ -66,7 +68,7 @@ BioInd.writeDebug("Tree name: %s\tminable.results: %s", {tree.name, (tree.minabl
for r, result in pairs(tree.minable.results) do
--CHECK FOR RESULT WOOD x 4
if result.name == "wood" and result.amount == 4 then
BioInd.writeDebug("Changing result %s: %s", {r, result}, "line")
BioInd.writeDebug("Changing result %s: %s", { r, result }, "line")
result.amount = nil
result.amount_min = 1
result.amount_max = 6
@ -80,9 +82,9 @@ BioInd.writeDebug("Tree name: %s\tminable.results: %s", {tree.name, (tree.minabl
tree.minable.results = new_results
end
BioInd.writeDebug("New minable.results: %s",
{tree.minable and tree.minable.results or "nil"}, "line")
{ tree.minable and tree.minable.results or "nil" }, "line")
else
BioInd.writeDebug("Won't change results of %s!", {tree.name})
BioInd.writeDebug("Won't change results of %s!", { tree.name })
end
end
end
@ -130,17 +132,16 @@ if BI.Settings.BI_Game_Tweaks_Player then
local found, ignore
for char_name, character in pairs(data.raw.character) do
BioInd.show("Checking character", char_name)
BioInd.show("Checking character", char_name)
found = false
for w, w_pattern in ipairs(whitelist) do
if char_name == w_pattern or char_name:match(w_pattern) then
ignore = false
BioInd.show("Found whitelisted character name", char_name)
BioInd.show("Found whitelisted character name", char_name)
for b, b_pattern in ipairs(blacklist) do
if char_name == b_pattern or char_name:match(b_pattern) then
BioInd.writeDebug("%s is on the ignore list!", char_name)
BioInd.writeDebug("%s is on the ignore list!", char_name)
-- Mark character as found
ignore = true
break
@ -160,7 +161,7 @@ BioInd.writeDebug("%s is on the ignore list!", char_name)
if found then
for tweak_name, tweak in pairs(tweaks) do
if character[tweak_name] < tweak then
BioInd.writeDebug("Changing %s from %s to %s", {tweak_name, character[tweak_name], tweak})
BioInd.writeDebug("Changing %s from %s to %s", { tweak_name, character[tweak_name], tweak })
character[tweak_name] = tweak
end
end
@ -195,25 +196,26 @@ if BI.Settings.BI_Game_Tweaks_Bot then
end
if can_insert then
table.insert(bot.flags, "not-flammable")
BioInd.writeDebug("Added flag \"not-flammable\" to %s", {bot.name})
BioInd.writeDebug("Added flag \"not-flammable\" to %s", { bot.name })
end
can_insert = true
for r, resistance in pairs(bot.resistances) do
if resistance.type == "fire" and resistance.percent ~= 100 then
BioInd.writeDebug("Change resistance against \"fire\" from %s to 100 %% for %s", {resistance.percent or "nil", bot.name})
bot.resistances[r] = {type = "fire", percent = 100}
BioInd.writeDebug("Change resistance against \"fire\" from %s to 100 %% for %s",
{ resistance.percent or "nil", bot.name })
bot.resistances[r] = { type = "fire", percent = 100 }
can_insert = false
break
end
end
if can_insert then
table.insert(bot.resistances, {type = "fire", percent = 100})
BioInd.writeDebug("Added resistance against \"fire\" to %s", {bot.name})
table.insert(bot.resistances, { type = "fire", percent = 100 })
BioInd.writeDebug("Added resistance against \"fire\" to %s", { bot.name })
end
bot.minable = nil
BioInd.writeDebug("Made %s unminable", {bot.name})
BioInd.writeDebug("Made %s unminable", { bot.name })
end
--catches modded bots too
@ -231,11 +233,11 @@ end
if BI.Settings.BI_Game_Tweaks_Stack_Size then
-- Changed for 0.18.34/1.1.4
local tweaks = {
["wood"] = {value = 400, se_limit = 200},
["stone"] = {value = 400, se_limit = 50},
["stone-crushed"] = {value = 800, se_limit = 200},
["concrete"] = {value = 400, se_limit = 200},
["slag"] = {value = 800, se_limit = 200},
["wood"] = { value = 400, se_limit = 200 },
["stone"] = { value = 400, se_limit = 50 },
["stone-crushed"] = { value = 800, se_limit = 200 },
["concrete"] = { value = 400, se_limit = 200 },
["slag"] = { value = 800, se_limit = 200 },
}
local item
local five_dim = BioInd.get_startup_setting("5d-change-stack")
@ -246,12 +248,12 @@ if BI.Settings.BI_Game_Tweaks_Stack_Size then
-- Only adjust stack_size if 5Dim sets multiplier of 1 or is not active!
if item.stack_size < tweak.value and (five_dim == 1 or not five_dim) then
BioInd.writeDebug("Changing stacksize of %s from %s to %s",
{item.name, item.stack_size, tweak.value})
{ item.name, item.stack_size, tweak.value })
item.stack_size = tweak.value
end
if mods["space-exploration"] then
item.stack_size = math.min(tweak.se_limit, item.stack_size)
BioInd.show("Adjusted stack_size on account of SE", item.stack_size )
BioInd.show("Adjusted stack_size on account of SE", item.stack_size)
end
end
end
@ -321,12 +323,14 @@ if mods["Krastorio2"] then
"bi-seed", "seedling", "water",
}
for _, recipe in pairs(data.raw.recipe) do
BioInd.writeDebug("Recipe has \"mod\" property: %s", {recipe.mod and true or false})
BioInd.writeDebug("Recipe has \"mod\" property: %s", { recipe.mod and true or false })
if recipe.mod == "Bio_Industries_2" then
krastorio.recipes.multiplyIngredients(recipe.name, update, 4)
krastorio.recipes.multiplyProducts(recipe.name, update, 4)
BioInd.writeDebug("Changed ingredients for %s: %s", {recipe and recipe.name or "nil", recipe and recipe.ingredients or "nil"})
BioInd.writeDebug("Changed results for %s: %s", {recipe and recipe.name or "nil", recipe and recipe.results or "nil"})
BioInd.writeDebug("Changed ingredients for %s: %s",
{ recipe and recipe.name or "nil", recipe and recipe.ingredients or "nil" })
BioInd.writeDebug("Changed results for %s: %s",
{ recipe and recipe.name or "nil", recipe and recipe.results or "nil" })
end
end
end
@ -346,7 +350,7 @@ if not fertilizer.place_as_tile then
fertilizer.place_as_tile = {
result = AlienBiomes and "vegetation-green-grass-3" or "grass-3",
condition_size = 1,
condition = { layers = { water_tile = true }}
condition = { layers = { water_tile = true } }
}
fertilizer.icon = ICONPATH .. "fertilizer_64.png"
fertilizer.icon_size = 64
@ -356,19 +360,19 @@ if not fertilizer.place_as_tile then
icon_size = 64,
}
}
fertilizer.localised_name = {"BI-item-name.fertilizer"}
fertilizer.localised_description = {"BI-item-description.fertilizer"}
fertilizer.localised_name = { "BI-item-name.fertilizer" }
fertilizer.localised_description = { "BI-item-description.fertilizer" }
end
data.raw.item["bi-adv-fertilizer"].place_as_tile = {
result = AlienBiomes and "vegetation-green-grass-1" or "grass-1",
condition_size = 1,
condition = { layers = { water_tile = true }}
condition = { layers = { water_tile = true } }
}
if mods["pycoalprocessing"] and BI.Settings.BI_Bio_Fuel then
-- Bio_Fuel/recipe.lua:30: {type = "item", name = "bi-ash", amount = 15}
thxbob.lib.recipe.remove_result ("bi-basic-gas-processing", "bi-ash")
thxbob.lib.recipe.remove_result("bi-basic-gas-processing", "bi-ash")
thxbob.lib.recipe.add_result("bi-basic-gas-processing", {
type = "item",
name = "ash",
@ -404,7 +408,6 @@ if mods["space-exploration"] then
end
if not mods["Natural_Evolution_Buildings"] then
local ammo_tweaks = {
["bi-dart-magazine-basic"] = 400,
["bi-dart-magazine-standard"] = 400,
@ -422,11 +425,12 @@ end
if BI.Settings.Bio_Cannon then
local default_target_masks = data.raw["utility-constants"].default.default_trigger_target_mask_by_type
default_target_masks["unit-spawner"] = default_target_masks["unit-spawner"] or {"common"} -- everything should have "common", unless there is specific reason not to
default_target_masks["unit-spawner"] = default_target_masks["unit-spawner"] or
{ "common" } -- everything should have "common", unless there is specific reason not to
table.insert(default_target_masks["unit-spawner"], "Bio_Cannon_Ammo")
for w, worm in pairs(data.raw.turret) do
worm.trigger_target_mask = worm.trigger_target_mask or default_target_masks["turret"] or {"common"}
worm.trigger_target_mask = worm.trigger_target_mask or default_target_masks["turret"] or { "common" }
table.insert(worm.trigger_target_mask, "Bio_Cannon_Ammo")
end
end
@ -442,7 +446,7 @@ BioInd.BI_add_icons()
for k, v in pairs(data.raw) do
for t, p in pairs(v) do
if p.se_allow_in_space then
BioInd.writeDebug("%s (%s) can be built in space!", {p.name, t})
BioInd.writeDebug("%s (%s) can be built in space!", { p.name, t })
end
end
end

View file

@ -25,9 +25,9 @@ require("prototypes.Wood_Products.pipes")
-- Damage Bonus to Ammo
-- Don't duplicate what NE does
if not mods["Natural_Evolution_Buildings"] then
thxbob.lib.tech.add_recipe_unlock ("military", "bi-dart-magazine-standard")
thxbob.lib.tech.add_recipe_unlock ("military-2", "bi-dart-magazine-enhanced")
thxbob.lib.tech.add_recipe_unlock ("military-3", "bi-dart-magazine-poison")
thxbob.lib.tech.add_recipe_unlock("military", "bi-dart-magazine-standard")
thxbob.lib.tech.add_recipe_unlock("military-2", "bi-dart-magazine-enhanced")
thxbob.lib.tech.add_recipe_unlock("military-3", "bi-dart-magazine-poison")
end
require("prototypes.Bio_Turret.technology-updates")
@ -56,8 +56,8 @@ thxbob.lib.tech.add_recipe_unlock("logistics-3", "bi-wooden-chest-giga")
-- Add Big and Huge electric poles to tech tree
thxbob.lib.tech.add_recipe_unlock ("logistics", "bi-wooden-pole-big")
thxbob.lib.tech.add_recipe_unlock ("electric-energy-distribution-2", "bi-wooden-pole-huge")
thxbob.lib.tech.add_recipe_unlock("logistics", "bi-wooden-pole-big")
thxbob.lib.tech.add_recipe_unlock("electric-energy-distribution-2", "bi-wooden-pole-huge")
--- Wood Floors
-- Make wood placeable only if Dectorio isn't installed. Should leave existing flooring intact.
@ -65,14 +65,14 @@ if not mods["Dectorio"] then
data.raw.item["wood"].place_as_tile = {
result = "bi-wood-floor",
condition_size = 4,
condition = { layers = { water_tile = true }}
condition = { layers = { water_tile = true } }
}
end
--- Make it so that the Base game tile "grass" can't be placed in blueprints
--- New as of 0.16
for _, tile in ipairs{"grass-1", "grass-2", "grass-3", "grass-4"} do
for _, tile in ipairs { "grass-1", "grass-2", "grass-3", "grass-4" } do
BI_Functions.lib.remove_from_blueprint(tile)
end
@ -156,7 +156,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-wooden-pole-huge", {
type = "item",
name = "tinned-copper-cable",
amount = 15}
amount = 15
}
)
end
@ -166,7 +167,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-bio-solar-farm", {
type = "item",
name = "solar-panel-large",
amount = 30}
amount = 30
}
)
end
@ -176,7 +178,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-large-substation", {
type = "item",
name = "substation-3",
amount = 6}
amount = 6
}
)
end
@ -185,7 +188,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-large-substation", {
type = "item",
name = "electrum-alloy",
amount = 10}
amount = 10
}
)
end
@ -195,7 +199,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-bio-accumulator", {
type = "item",
name = "large-accumulator",
amount = 30}
amount = 30
}
)
end
@ -204,7 +209,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-bio-accumulator", {
type = "item",
name = "aluminium-plate",
amount = 50}
amount = 50
}
)
end
@ -214,7 +220,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-solar-mat", {
type = "item",
name = "aluminium-plate",
amount = 1}
amount = 1
}
)
end
@ -223,7 +230,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-solar-mat", {
type = "item",
name = "silicon-wafer",
amount = 4}
amount = 4
}
)
end
@ -233,7 +241,8 @@ if BI.Settings.BI_Solar_Additions then
thxbob.lib.recipe.add_new_ingredient("bi-solar-boiler-hidden-panel", {
type = "item",
name = "angels-electric-boiler",
amount = 1}
amount = 1
}
)
end
end
@ -280,10 +289,10 @@ if BI.Settings.BI_Bio_Fuel then
else
thxbob.lib.tech.add_recipe_unlock("bi-tech-advanced-biotechnology", "bi-sulfur")
end
else
thxbob.lib.recipe.add_new_ingredient("bi-adv-fertilizer-1", {type = "item", name = "fertilizer", amount = 50})
thxbob.lib.recipe.remove_ingredient ("bi-adv-fertilizer-2", "fertilizer")
thxbob.lib.recipe.add_new_ingredient("bi-adv-fertilizer-2", {type = "item", name = "fertilizer", amount = 30})
else
thxbob.lib.recipe.add_new_ingredient("bi-adv-fertilizer-1", { type = "item", name = "fertilizer", amount = 50 })
thxbob.lib.recipe.remove_ingredient("bi-adv-fertilizer-2", "fertilizer")
thxbob.lib.recipe.add_new_ingredient("bi-adv-fertilizer-2", { type = "item", name = "fertilizer", amount = 30 })
end
@ -294,7 +303,8 @@ if data.raw.item["alien-artifact"] then
thxbob.lib.recipe.add_new_ingredient("bi-adv-fertilizer-1", {
type = "item",
name = "alien-artifact",
amount = 5}
amount = 5
}
)
thxbob.lib.tech.add_recipe_unlock("bi-tech-advanced-biotechnology", "bi-adv-fertilizer-1")
end
@ -307,7 +317,8 @@ if mods["Natural_Evolution_Buildings"] then
thxbob.lib.recipe.add_new_ingredient("bi-adv-fertilizer-1", {
type = "fluid",
name = "NE_enhanced-nutrient-solution",
amount = 50}
amount = 50
}
)
end
@ -323,7 +334,7 @@ if data.raw["item"]["bob-greenhouse"] then
data.raw["item"]["fertilizer"].place_as_tile = {
result = BioInd.AB_tiles() and "vegetation-green-grass-3" or "grass-3",
condition_size = 1,
condition = { layers = { water_tile = true }}
condition = { layers = { water_tile = true } }
}
end
@ -348,32 +359,32 @@ if mods["angelspetrochem"] then
data.raw.item["pellet-coke"].fuel_top_speed_multiplier = 1.2
data.raw.recipe["pellet-coke"].category = "biofarm-mod-smelting"
thxbob.lib.tech.remove_recipe_unlock ("angels-coal-processing-2", "pellet-coke")
thxbob.lib.tech.remove_recipe_unlock("angels-coal-processing-2", "pellet-coke")
thxbob.lib.tech.add_recipe_unlock("angels-coal-cracking", "pellet-coke")
end
if data.raw.item["ash"] and mods["pycoalprocessing"] then
thxbob.lib.recipe.replace_ingredient ("bi-fertilizer-2", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-fertilizer-2", "bi-ash", "ash")
if mods["angelsrefining"] then
thxbob.lib.recipe.replace_ingredient ("bi-slag-slurry", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-slag-slurry", "bi-ash", "ash")
end
thxbob.lib.recipe.replace_ingredient ("bi-seed-2", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient ("bi-seedling-2", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient ("bi-logs-2", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-seed-2", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-seedling-2", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-logs-2", "bi-ash", "ash")
data.raw.recipe["bi-ash-1"].result = "ash"
data.raw.recipe["bi-ash-2"].result = "ash"
thxbob.lib.recipe.replace_ingredient ("bi-stone-brick", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient ("bi-fertilizer-1", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-stone-brick", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-fertilizer-1", "bi-ash", "ash")
if BI.Settings.BI_Bio_Fuel then
thxbob.lib.recipe.replace_ingredient ("bi-biomass-3", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient ("bi-sulfur", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient ("bi-sulfur-angels", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-biomass-3", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-sulfur", "bi-ash", "ash")
thxbob.lib.recipe.replace_ingredient("bi-sulfur-angels", "bi-ash", "ash")
data.raw.recipe["bi-sulfur"].icon = ICONPATH .. "py_bio_sulfur.png"
data.raw.recipe["bi-sulfur"].icon_size = 64
@ -398,11 +409,11 @@ if data.raw.item["ash"] and mods["pycoalprocessing"] then
data.raw.recipe["bi-ash-2"].icon_size = 64
data.raw.recipe["bi-stone-brick"].icon = ICONPATH .. "py_bi_stone_brick.png"
data.raw.recipe["bi-stone-brick"].icon_size = 64
end
end
----- If Bob's bobrevamp, then ----
if mods["bobrevamp"] then
thxbob.lib.tech.remove_recipe_unlock ("bi-tech-coal-processing-1", "bi-solid-fuel")
thxbob.lib.tech.remove_recipe_unlock("bi-tech-coal-processing-1", "bi-solid-fuel")
thxbob.lib.tech.add_recipe_unlock("solid-fuel", "bi-solid-fuel")
end
@ -419,11 +430,11 @@ end
-- We may need liquid air and nitrogen -- but not if any of the following mods is active!
local ICONPATH = BioInd.modRoot .. "/graphics/icons/"
local ICONPATH = BioInd.modRoot .. "/graphics/icons/"
-- We only want to create nitrogen if it doesn't exist yet. We then also need to create
-- liquid air.
if not data.raw.fluid["nitrogen"] then
-- We only want to create nitrogen if it doesn't exist yet. We then also need to create
-- liquid air.
if not data.raw.fluid["nitrogen"] then
data:extend({
{
type = "fluid",
@ -441,8 +452,8 @@ end
gas_temperature = -210,
max_temperature = 100,
heat_capacity = "1kJ",
base_color = {r = 0.0, g = 0.0, b = 1.0},
flow_color = {r = 0.0, g = 0.0, b = 1.0},
base_color = { r = 0.0, g = 0.0, b = 1.0 },
flow_color = { r = 0.0, g = 0.0, b = 1.0 },
pressure_to_speed_ratio = 0.4,
flow_to_energy_ratio = 0.59,
order = "a[fluid]-b[nitrogen]"
@ -468,8 +479,8 @@ end
gas_temperature = -100,
max_temperature = 100,
heat_capacity = "1kJ",
base_color = {r = 0, g = 0, b = 0},
flow_color = {r = 0.5, g = 1.0, b = 1.0},
base_color = { r = 0, g = 0, b = 0 },
flow_color = { r = 0.5, g = 1.0, b = 1.0 },
pressure_to_speed_ratio = 0.4,
flow_to_energy_ratio = 0.59,
order = "a[fluid]-b[liquid-air]"
@ -479,7 +490,7 @@ end
end
-- Recipes for "bi-liquid-air" and "bi-nitrogen" aren't needed!
else
else
-- Remove recipe unlocks
thxbob.lib.tech.remove_recipe_unlock("bi-tech-fertilizer", "bi-liquid-air")
thxbob.lib.tech.remove_recipe_unlock("bi-tech-fertilizer", "bi-nitrogen")
@ -501,28 +512,28 @@ end
data.raw.recipe["bi-liquid-air"] = nil
data.raw.recipe["bi-nitrogen"] = nil
BioInd.writeDebug("Removed recipes for \"nitrogen\" and \"liquid air\".")
end
end
-- Moved here from data-final-fixes.lua for 0.18.34/1.1.4! (Fixes https://mods.factorio.com/mod/Bio_Industries/discussion/5ff570bd916993002371332a)
---- Game Tweaks ---- Recipes
if BI.Settings.BI_Game_Tweaks_Recipe then
--- Concrete Recipe Tweak
thxbob.lib.recipe.remove_ingredient("concrete", "iron-ore")
thxbob.lib.recipe.add_new_ingredient("concrete", {type = "item", name = "iron-stick", amount = 2})
thxbob.lib.recipe.add_new_ingredient("concrete", { type = "item", name = "iron-stick", amount = 2 })
--- Stone Wall
thxbob.lib.recipe.add_new_ingredient("stone-wall", {type = "item", name = "iron-stick", amount = 1})
thxbob.lib.recipe.add_new_ingredient("stone-wall", { type = "item", name = "iron-stick", amount = 1 })
--- Rail (Remove Stone and Add Crushed Stone)
if data.raw.item["stone-crushed"] then
thxbob.lib.recipe.remove_ingredient("rail", "stone")
thxbob.lib.recipe.add_new_ingredient("rail", {type = "item", name = "stone-crushed", amount = 6})
thxbob.lib.recipe.add_new_ingredient("rail", { type = "item", name = "stone-crushed", amount = 6 })
thxbob.lib.recipe.remove_ingredient("bi-rail-wood", "stone")
thxbob.lib.recipe.add_new_ingredient("bi-rail-wood", {type = "item", name = "stone-crushed", amount = 6})
thxbob.lib.recipe.add_new_ingredient("bi-rail-wood", { type = "item", name = "stone-crushed", amount = 6 })
end
-- vanilla rail recipe update
thxbob.lib.recipe.add_new_ingredient("rail", {type = "item", name = "concrete", amount = 6})
thxbob.lib.recipe.add_new_ingredient("rail", { type = "item", name = "concrete", amount = 6 })
end
@ -540,7 +551,6 @@ if BI.Settings.BI_Game_Tweaks_Disassemble then
}) do
thxbob.lib.tech.add_recipe_unlock(tech, recipe)
end
end
--- Enable Productivity in Recipes
@ -598,7 +608,7 @@ for h_key, h_names in pairs(BI.hidden_entities.types) do
for h_name, h in pairs(h_names) do
data.raw[h_type][h_name].resistances = resistances
BioInd.writeDebug("Added resistances to %s (%s): %s",
{h_name, h_type, data.raw[h_type][h_name].resistances})
{ h_name, h_type, data.raw[h_type][h_name].resistances })
end
end
@ -612,7 +622,7 @@ if b and r then
local resistances = data.raw[b.type][b.name].resistances
if resistances then
data.raw[r.type][r.name].resistances = util.table.deepcopy(resistances)
BioInd.writeDebug("Copied resistances from %s to %s!", {b.name, r.name})
BioInd.writeDebug("Copied resistances from %s to %s!", { b.name, r.name })
end
end
------------------------------------------------------------------------------------
@ -625,7 +635,7 @@ if mods["omnimatter_fluid"] then
forbidden_boilers = forbidden_boilers or {}
forbidden_boilers["bi-solar-boiler"] = true
end
BioInd.writeDebug("OMNIFLUID Test! forbidden_boilers = %s", {forbidden_boilers})
BioInd.writeDebug("OMNIFLUID Test! forbidden_boilers = %s", { forbidden_boilers })
------------------------------------------------------------------------------------
@ -647,7 +657,7 @@ if mods["pyrawores"] then
for i = 1, 3 do
for u, unlock in ipairs(unlocks[i]) do
thxbob.lib.tech.add_recipe_unlock("coal-mk0" .. i, unlock.recipe)
BioInd.writeDebug("Added recipe %s to unlocks of %s", {unlock.recipe, "coal-mk0" .. i})
BioInd.writeDebug("Added recipe %s to unlocks of %s", { unlock.recipe, "coal-mk0" .. i })
end
end
end
@ -669,7 +679,7 @@ if mods["pycoalprocessing"] and not set then
for i = 1, 3 do
for u, unlock in ipairs(unlocks[i]) do
thxbob.lib.tech.add_recipe_unlock("coal-processing-" .. i, unlock.recipe)
BioInd.writeDebug("Added recipe %s to unlocks of %s", {unlock.recipe, "coal-processing-" .. i})
BioInd.writeDebug("Added recipe %s to unlocks of %s", { unlock.recipe, "coal-processing-" .. i })
end
end
end
@ -677,7 +687,7 @@ end
if set then
for i = 1, 3 do
data.raw.technology["bi-tech-coal-processing-" .. i] = nil
BioInd.writeDebug("Removed technology " .. "bi-tech-coal-processing-" .. i)
BioInd.writeDebug("Removed technology " .. "bi-tech-coal-processing-" .. i)
end
end

View file

@ -27,76 +27,75 @@ for var, name in pairs({
end
--- Help Files
require ("libs.item-functions") -- From Bob's Libary
require ("libs.recipe-functions") -- From Bob's Libary
require ("libs.technology-functions") -- From Bob's Libary
require ("libs.functions") -- From Bob's Libary
require ("libs.category-functions") -- From Bob's Libary
require ("libs.bi_functions") -- Functions
require("libs.item-functions") -- From Bob's Libary
require("libs.recipe-functions") -- From Bob's Libary
require("libs.technology-functions") -- From Bob's Libary
require("libs.functions") -- From Bob's Libary
require("libs.category-functions") -- From Bob's Libary
require("libs.bi_functions") -- Functions
require ("prototypes.category")
require("prototypes.category")
--- Bio Farm
require ("prototypes.Bio_Farm.entities")
require ("prototypes.Bio_Farm.item")
require ("prototypes.Bio_Farm.recipe")
require ("prototypes.Bio_Farm.liquids")
require ("prototypes.Bio_Farm.recipe-categories")
require ("prototypes.Bio_Farm.pipeConnectors")
require ("prototypes.Bio_Farm.technology")
require ("prototypes.Bio_Farm.tree_entities")
require("prototypes.Bio_Farm.entities")
require("prototypes.Bio_Farm.item")
require("prototypes.Bio_Farm.recipe")
require("prototypes.Bio_Farm.liquids")
require("prototypes.Bio_Farm.recipe-categories")
require("prototypes.Bio_Farm.pipeConnectors")
require("prototypes.Bio_Farm.technology")
require("prototypes.Bio_Farm.tree_entities")
-- Bio Garden
require ("prototypes.Bio_Garden.entities")
require ("prototypes.Bio_Garden.item")
require ("prototypes.Bio_Garden.recipe")
require ("prototypes.Bio_Garden.recipe-categories")
require("prototypes.Bio_Garden.entities")
require("prototypes.Bio_Garden.item")
require("prototypes.Bio_Garden.recipe")
require("prototypes.Bio_Garden.recipe-categories")
--- Bio Solar Farm
require ("prototypes.Bio_Solar_Farm.entities")
require ("prototypes.Bio_Solar_Farm.item")
require ("prototypes.Bio_Solar_Farm.recipe")
require("prototypes.Bio_Solar_Farm.entities")
require("prototypes.Bio_Solar_Farm.item")
require("prototypes.Bio_Solar_Farm.recipe")
--- Wood Products
require ("prototypes.Wood_Products.entities")
require ("prototypes.Wood_Products.item")
require ("prototypes.Wood_Products.recipe")
require ("prototypes.Wood_Products.containers-entities")
require ("prototypes.Wood_Products.containers-item")
require ("prototypes.Wood_Products.containers-recipe")
require("prototypes.Wood_Products.entities")
require("prototypes.Wood_Products.item")
require("prototypes.Wood_Products.recipe")
require("prototypes.Wood_Products.containers-entities")
require("prototypes.Wood_Products.containers-item")
require("prototypes.Wood_Products.containers-recipe")
if not mods["Natural_Evolution_Buildings"] then
--- Dart Turret (Bio turret)
require ("prototypes.Bio_Turret.item-group")
require ("prototypes.Bio_Turret.damage-type")
require ("prototypes.Bio_Turret.item")
require ("prototypes.Bio_Turret.recipe")
require ("prototypes.Bio_Turret.entity")
require("prototypes.Bio_Turret.item-group")
require("prototypes.Bio_Turret.damage-type")
require("prototypes.Bio_Turret.item")
require("prototypes.Bio_Turret.recipe")
require("prototypes.Bio_Turret.entity")
--- Bio Cannon
--- Bio Cannon
-- Items Groups
require ("prototypes.Bio_Cannon.item-group")
require("prototypes.Bio_Cannon.item-group")
-- Cannon
require ("prototypes.Bio_Cannon.item")
require ("prototypes.Bio_Cannon.recipe")
require ("prototypes.Bio_Cannon.entity")
require ("prototypes.Bio_Cannon.technology")
require("prototypes.Bio_Cannon.item")
require("prototypes.Bio_Cannon.recipe")
require("prototypes.Bio_Cannon.entity")
require("prototypes.Bio_Cannon.technology")
-- Projectiles
require ("prototypes.Bio_Cannon.projectiles-item")
require ("prototypes.Bio_Cannon.projectiles-recipe")
require ("prototypes.Bio_Cannon.projectiles-entity")
require("prototypes.Bio_Cannon.projectiles-item")
require("prototypes.Bio_Cannon.projectiles-recipe")
require("prototypes.Bio_Cannon.projectiles-entity")
end
---- Add Bio Fuel & Plastic, etc.

View file

@ -1,5 +1,5 @@
local setting_list = {}
-- Add/enable stuff
-- Add/enable stuff
setting_list.BI_Solar_Additions = {
type = "bool-setting",
name = "BI_Solar_Additions",
@ -48,7 +48,7 @@ setting_list.BI_Bigger_Wooden_Chests = {
order = "a[modifier]-b[Bigger_Wooden_Chests]",
}
-- Game tweaks
-- Game tweaks
setting_list.BI_Game_Tweaks_Emissions_Multiplier = {
type = "bool-setting",
name = "BI_Game_Tweaks_Emissions_Multiplier",
@ -71,7 +71,7 @@ setting_list.BI_Game_Tweaks_Recipe = {
default_value = true,
order = "b[tweaks]-c1[Recipe]",
}
setting_list.BI_Game_Tweaks_Production_Science = {
setting_list.BI_Game_Tweaks_Production_Science = {
type = "bool-setting",
name = "BI_Game_Tweaks_Production_Science",
setting_type = "startup",
@ -109,7 +109,7 @@ setting_list.BI_Game_Tweaks_Bot = {
-- Compatibility with other mods (optional)
-- Industrial Revolution + AAI Industry
-- Industrial Revolution + AAI Industry
if not (mods["IndustrialRevolution"] or mods["aai-industry"]) then
setting_list.BI_Game_Tweaks_Disassemble = {
type = "bool-setting",
@ -121,7 +121,7 @@ if not (mods["IndustrialRevolution"] or mods["aai-industry"]) then
end
-- Lua API global Variable Viewer (gvv)
-- Lua API global Variable Viewer (gvv)
if mods["gvv"] then
setting_list.BI_Enable_gvv_support = {
type = "bool-setting",
@ -134,7 +134,7 @@ end
local list = {}
for name, setting in pairs(setting_list) do
data:extend({setting})
data:extend({ setting })
end
--[[
Types of settings:

View file

@ -9,7 +9,7 @@ local settings_changed = {}
-- Adjust the force of hidden poles on Musk floor!
settings_changed.musk_floor = function()
log("Entered function settings_changed.musk_floor!")
log("Entered function settings_changed.musk_floor!")
-- Look for solar panels on every surface. They determine the force poles will use
-- if the electric grid overlay will be shown in mapview.
local sm_panel_name = "bi-musk-mat-hidden-panel"
@ -62,22 +62,22 @@ log("Entered function settings_changed.musk_floor!")
end
for name, surface in pairs(game.surfaces) do
BioInd.writeDebug("Looking for %s on surface %s", {sm_panel_name, name})
local sm_panel = surface.find_entities_filtered{name = sm_panel_name}
BioInd.writeDebug("Looking for %s on surface %s", { sm_panel_name, name })
local sm_panel = surface.find_entities_filtered { name = sm_panel_name }
local sm_pole = {}
-- Look for hidden poles on position of hidden panels
for p, panel in ipairs(sm_panel) do
sm_pole = surface.find_entities_filtered{
sm_pole = surface.find_entities_filtered {
name = sm_pole_name,
position = panel.position,
}
-- If more than one hidden pole exists at that position for some reason, remove all but the first!
if #sm_pole > 1 then
BioInd.writeDebug("Number of poles for panel %g: %g", {p, #sm_pole})
BioInd.writeDebug("Number of poles for panel %g: %g", { p, #sm_pole })
for i = 2, #sm_pole do
BioInd.writeDebug("Destroying pole number %g", {i})
BioInd.writeDebug("Destroying pole number %g", { i })
sm_pole[i].destroy()
end
end
@ -87,7 +87,7 @@ BioInd.writeDebug("Destroying pole number %g", {i})
end
end
BioInd.writeDebug("Electric grid overlay of musk floor will be %s in map view.",
{BioInd.UseMuskForce and "hidden" or "displayed"})
{ BioInd.UseMuskForce and "hidden" or "displayed" })
end
@ -96,11 +96,11 @@ settings_changed.bio_garden = function()
-- Has this setting been changed since the last time the game was run?
local current = BioInd.get_startup_setting("BI_Easy_Bio_Gardens")
BioInd.show("Last state of BI_Easy_Bio_Gardens", storage.mod_settings.BI_Easy_Bio_Gardens)
BioInd.show("Current state of BI_Easy_Bio_Gardens", current)
BioInd.show("Last state of BI_Easy_Bio_Gardens", storage.mod_settings.BI_Easy_Bio_Gardens)
BioInd.show("Current state of BI_Easy_Bio_Gardens", current)
if storage.mod_settings.BI_Easy_Bio_Gardens ~= current then
BioInd.writeDebug("Setting has been changed!")
BioInd.writeDebug("Setting has been changed!")
local pole, neighbours
-- This is the unmodified table!
local compound_entity = BioInd.compound_entities["bi-bio-garden"]
@ -112,10 +112,10 @@ BioInd.writeDebug("Setting has been changed!")
if not (garden.base and garden.base.valid) then
-- Remove all hidden entities!
for hidden, h_name in pairs(compound_entity.hidden or {}) do
BioInd.show("hidden", hidden)
BioInd.writeDebug("Removing hidden entity %s %s", {
BioInd.show("hidden", hidden)
BioInd.writeDebug("Removing hidden entity %s %s", {
garden[hidden] and garden[hidden].valid and garden[hidden].name or "nil",
garden[hidden] and garden[hidden].valid and garden[hidden].unit_number or "nil"})
garden[hidden] and garden[hidden].valid and garden[hidden].unit_number or "nil" })
BioInd.remove_entity(garden[hidden])
garden[hidden] = nil
end
@ -132,7 +132,7 @@ BioInd.writeDebug("Removing hidden entity %s %s", {
local pole_type = "electric-pole"
for s, surface in pairs(game.surfaces) do
-- Find poles on surface
found_poles = surface.find_entities_filtered{
found_poles = surface.find_entities_filtered {
name = compound_entity.hidden[pole_type].name,
type = "electric-pole",
}
@ -145,7 +145,7 @@ BioInd.writeDebug("Removing hidden entity %s %s", {
-- Setting is on, so we need to create the hidden poles
if current then
BioInd.writeDebug("Need to create hidden poles for %s Bio Gardens!",
{table_size(storage.bi_bio_garden_table) })
{ table_size(storage.bi_bio_garden_table) })
-- Restore the list of hidden entities
storage.compound_entities["bi-bio-garden"] = BioInd.compound_entities["bi-bio-garden"]
@ -154,7 +154,7 @@ BioInd.writeDebug("Removing hidden entity %s %s", {
-- Make sure the base entity exists!
base = garden.base
pole = base and garden[pole_type]
BioInd.show("pole", pole)
BioInd.show("pole", pole)
-- There is a pole referenced in the table, and it is a valid entity
if pole and pole.valid then
-- Delete pole from list of removeable poles
@ -167,7 +167,7 @@ BioInd.show("pole", pole)
pole = BioInd.create_entities(
storage[compound_entity.tab],
base,
{pole = hidden_entities[pole_type].name}
{ pole = hidden_entities[pole_type].name }
)
-- Add the new pole to the table
@ -185,9 +185,9 @@ BioInd.show("pole", pole)
-- Setting is off -- disconnect and remove hidden poles!
else
BioInd.writeDebug("%s Bio Gardens found -- try to disconnect hidden poles!",
{table_size(storage.bi_bio_garden_table) })
{ table_size(storage.bi_bio_garden_table) })
-- Find hidden poles of registered gardens
BioInd.show("storage.bi_bio_garden_table", storage.bi_bio_garden_table)
BioInd.show("storage.bi_bio_garden_table", storage.bi_bio_garden_table)
for g, garden in pairs(storage.bi_bio_garden_table or {}) do
if garden[pole_type] then
-- Pole really exists: destroy the entity
@ -209,12 +209,12 @@ BioInd.show("storage.bi_bio_garden_table", storage.bi_bio_garden_table)
-- We don't want to create hidden poles if the setting is off,
-- so remove the pole from hidden entities!
storage.compound_entities["bi-bio-garden"].hidden[pole_type] = nil
BioInd.show("storage.compound_entities", storage.compound_entities)
BioInd.show("storage.compound_entities", storage.compound_entities)
end
-- Remove any hidden poles that are not associated with a garden
BioInd.writeDebug("Removing %s hidden poles not associated with a bio garden!",
{table_size(remove_poles)})
{ table_size(remove_poles) })
for p, pole in pairs(remove_poles) do
pole.destroy()
end