Fix runtime scripts
This commit is contained in:
parent
c1a4429c80
commit
447c47f0f3
7 changed files with 191 additions and 191 deletions
|
@ -119,7 +119,7 @@ return function(mod_name)
|
||||||
--~ log("Entered function get_tree_ignore_list!")
|
--~ log("Entered function get_tree_ignore_list!")
|
||||||
local ignore = {}
|
local ignore = {}
|
||||||
local trees = game and
|
local trees = game and
|
||||||
game.get_filtered_entity_prototypes({{filter = "type", type = "tree"}}) or
|
prototypes.get_entity_filtered({{filter = "type", type = "tree"}}) or
|
||||||
data.raw.tree
|
data.raw.tree
|
||||||
for tree_name, tree in pairs(trees) do
|
for tree_name, tree in pairs(trees) do
|
||||||
--~ log("tree_name: " .. tree_name)
|
--~ log("tree_name: " .. tree_name)
|
||||||
|
@ -281,7 +281,7 @@ return function(mod_name)
|
||||||
local ret = false
|
local ret = false
|
||||||
|
|
||||||
if game then
|
if game then
|
||||||
local AB = game.item_prototypes["fertilizer"].place_as_tile_result.result.name
|
local AB = prototypes.item["fertilizer"].place_as_tile_result.result.name
|
||||||
-- In data stage, place_as_tile is only changed to Alien Biomes tiles if
|
-- In data stage, place_as_tile is only changed to Alien Biomes tiles if
|
||||||
-- both "vegetation-green-grass-1" and "vegetation-green-grass-3" exist. Therefore,
|
-- both "vegetation-green-grass-1" and "vegetation-green-grass-3" exist. Therefore,
|
||||||
-- we only need to check for one tile in the control stage.
|
-- we only need to check for one tile in the control stage.
|
||||||
|
@ -316,7 +316,7 @@ return function(mod_name)
|
||||||
common.show("base_name", c_name)
|
common.show("base_name", c_name)
|
||||||
common.show("data", c_data)
|
common.show("data", c_data)
|
||||||
-- Is the base entity in the game?
|
-- Is the base entity in the game?
|
||||||
if c_data.base and c_data.base.name and game.entity_prototypes[c_data.base.name] then
|
if c_data.base and c_data.base.name and prototypes.entity[c_data.base.name] then
|
||||||
-- Make a copy of the compound-entity data
|
-- Make a copy of the compound-entity data
|
||||||
common.writeDebug("%s exists -- copying data", {c_name})
|
common.writeDebug("%s exists -- copying data", {c_name})
|
||||||
ret[c_name] = util.table.deepcopy(c_data)
|
ret[c_name] = util.table.deepcopy(c_data)
|
||||||
|
@ -326,7 +326,7 @@ common.show("data", c_data)
|
||||||
--~ h_type = common.HE_map[h_key]
|
--~ h_type = common.HE_map[h_key]
|
||||||
common.writeDebug("h_key: %s\th_data: %s", {h_key, h_data})
|
common.writeDebug("h_key: %s\th_data: %s", {h_key, h_data})
|
||||||
-- Remove hidden entity if it doesn't exist
|
-- Remove hidden entity if it doesn't exist
|
||||||
if not game.entity_prototypes[h_data.name] then
|
if not prototypes.entity[h_data.name] then
|
||||||
common.writeDebug("Removing %s (%s) from list of hidden entities!", {h_data.name, h_key})
|
common.writeDebug("Removing %s (%s) from list of hidden entities!", {h_data.name, h_key})
|
||||||
ret[c_name].hidden[h_key] = nil
|
ret[c_name].hidden[h_key] = nil
|
||||||
end
|
end
|
||||||
|
@ -338,7 +338,7 @@ common.writeDebug("h_key: %s\th_data: %s", {h_key, h_data})
|
||||||
if tab then
|
if tab then
|
||||||
-- Remove main table from global
|
-- Remove main table from global
|
||||||
common.writeDebug("Removing %s (%s obsolete entries)", {tab, #tab})
|
common.writeDebug("Removing %s (%s obsolete entries)", {tab, #tab})
|
||||||
global[tab] = nil
|
storage[tab] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If this compound entity requires additional tables in global, initialize
|
-- If this compound entity requires additional tables in global, initialize
|
||||||
|
@ -346,8 +346,8 @@ common.writeDebug("h_key: %s\th_data: %s", {h_key, h_data})
|
||||||
local related_tables = c_data.add_global_tables
|
local related_tables = c_data.add_global_tables
|
||||||
if related_tables then
|
if related_tables then
|
||||||
for t, tab in ipairs(related_tables or {}) do
|
for t, tab in ipairs(related_tables or {}) do
|
||||||
common.writeDebug("Removing global[%s] (%s values)", {tab, table_size(global[tab])})
|
common.writeDebug("Removing storage[%s] (%s values)", {tab, table_size(storage[tab])})
|
||||||
global[tab] = nil
|
storage[tab] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -355,9 +355,9 @@ common.writeDebug("h_key: %s\th_data: %s", {h_key, h_data})
|
||||||
local related_vars = c_data.add_global_values
|
local related_vars = c_data.add_global_values
|
||||||
if related_vars then
|
if related_vars then
|
||||||
for var_name, value in pairs(related_vars or {}) do
|
for var_name, value in pairs(related_vars or {}) do
|
||||||
common.writeDebug("Removing global[%s] (was: %s)",
|
common.writeDebug("Removing storage[%s] (was: %s)",
|
||||||
{var_name, var_name and global[var_name] or "nil"})
|
{var_name, var_name and storage[var_name] or "nil"})
|
||||||
global[var_name] = nil
|
storage[var_name] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -370,18 +370,18 @@ common.writeDebug("h_key: %s\th_data: %s", {h_key, h_data})
|
||||||
common.add_optional_data = function(base)
|
common.add_optional_data = function(base)
|
||||||
local f_name = "add_optional_data"
|
local f_name = "add_optional_data"
|
||||||
common.writeDebug("Entered function %s(%s)", {f_name, common.print_name_id(base)})
|
common.writeDebug("Entered function %s(%s)", {f_name, common.print_name_id(base)})
|
||||||
if not (base and base.valid and global.compound_entities[base.name]) then
|
if not (base and base.valid and storage.compound_entities[base.name]) then
|
||||||
common.arg_err(base, "base of a compound entity")
|
common.arg_err(base, "base of a compound entity")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add optional values to global table
|
-- Add optional values to global table
|
||||||
local data = global.compound_entities[base.name]
|
local data = storage.compound_entities[base.name]
|
||||||
common.show("data", data)
|
common.show("data", data)
|
||||||
local tab = data.tab
|
local tab = data.tab
|
||||||
common.show("tab", tab)
|
common.show("tab", tab)
|
||||||
common.show("global[tab]", global[tab] or "nil")
|
common.show("storage[tab]", storage[tab] or "nil")
|
||||||
|
|
||||||
local entry = global[tab][base.unit_number]
|
local entry = storage[tab][base.unit_number]
|
||||||
|
|
||||||
for k, v in pairs(data.optional or {}) do
|
for k, v in pairs(data.optional or {}) do
|
||||||
if entry[k] then
|
if entry[k] then
|
||||||
|
@ -399,15 +399,15 @@ common.show("global[tab]", global[tab] or "nil")
|
||||||
common.clean_global_compounds_table = function(entity_name)
|
common.clean_global_compounds_table = function(entity_name)
|
||||||
local f_name = "clean_table"
|
local f_name = "clean_table"
|
||||||
common.writeDebug("Entered function %s(%s)", {f_name, entity_name or "nil"})
|
common.writeDebug("Entered function %s(%s)", {f_name, entity_name or "nil"})
|
||||||
common.writeDebug("Entries in common.compound_entities[%s]: %s", {entity_name, table_size(global.compound_entities[entity_name])})
|
common.writeDebug("Entries in common.compound_entities[%s]: %s", {entity_name, table_size(storage.compound_entities[entity_name])})
|
||||||
|
|
||||||
--~ local entity_table = global[common.compound_entities[entity_name].tab]
|
--~ local entity_table = storage[common.compound_entities[entity_name].tab]
|
||||||
--~ local hidden_entities = common.compound_entities[entity_name].hidden
|
--~ local hidden_entities = common.compound_entities[entity_name].hidden
|
||||||
local entity_table = global.compound_entities[entity_name]
|
local entity_table = storage.compound_entities[entity_name]
|
||||||
common.show("entity_table", entity_table and entity_table.tab)
|
common.show("entity_table", entity_table and entity_table.tab)
|
||||||
entity_table = entity_table and entity_table.tab and global[entity_table.tab]
|
entity_table = entity_table and entity_table.tab and storage[entity_table.tab]
|
||||||
common.writeDebug("entity_table: %s", {entity_table}, "line")
|
common.writeDebug("entity_table: %s", {entity_table}, "line")
|
||||||
local hidden_entities = global.compound_entities[entity_name].hidden
|
local hidden_entities = storage.compound_entities[entity_name].hidden
|
||||||
common.show("hidden_entities", hidden_entities)
|
common.show("hidden_entities", hidden_entities)
|
||||||
local removed = 0
|
local removed = 0
|
||||||
-- Scan the whole table
|
-- Scan the whole table
|
||||||
|
@ -438,11 +438,11 @@ common.show("Pruned list size", table_size(entity_table))
|
||||||
common.restore_missing_entities = function(entity_name)
|
common.restore_missing_entities = function(entity_name)
|
||||||
local f_name = "restore_missing_entities"
|
local f_name = "restore_missing_entities"
|
||||||
common.writeDebug("Entered function %s(%s)", {f_name, entity_name or "nil"})
|
common.writeDebug("Entered function %s(%s)", {f_name, entity_name or "nil"})
|
||||||
--~ common.writeDebug("global.compound_entities[%s]: %s", {entity_name, global.compound_entities[entity_name]})
|
--~ common.writeDebug("storage.compound_entities[%s]: %s", {entity_name, storage.compound_entities[entity_name]})
|
||||||
common.writeDebug("global.compound_entities[%s]: %s entries", {entity_name, table_size(global.compound_entities[entity_name])})
|
common.writeDebug("storage.compound_entities[%s]: %s entries", {entity_name, table_size(storage.compound_entities[entity_name])})
|
||||||
|
|
||||||
local check = global.compound_entities[entity_name]
|
local check = storage.compound_entities[entity_name]
|
||||||
local entity_table = check and global[check.tab] or {}
|
local entity_table = check and storage[check.tab] or {}
|
||||||
local hidden_entities = check and check.hidden or {}
|
local hidden_entities = check and check.hidden or {}
|
||||||
|
|
||||||
local checked = 0
|
local checked = 0
|
||||||
|
@ -485,12 +485,12 @@ common.writeDebug("Restored %s entities", {restored})
|
||||||
|
|
||||||
local cnt = 0
|
local cnt = 0
|
||||||
local h_cnt = 0
|
local h_cnt = 0
|
||||||
local data = global.compound_entities[compound_name]
|
local data = storage.compound_entities[compound_name]
|
||||||
if not data then
|
if not data then
|
||||||
common.arg_err(compound_name, "name of a compound entity")
|
common.arg_err(compound_name, "name of a compound entity")
|
||||||
end
|
end
|
||||||
|
|
||||||
local g_tab = global[data.tab]
|
local g_tab = storage[data.tab]
|
||||||
local found, h_found ,created
|
local found, h_found ,created
|
||||||
|
|
||||||
-- Scan all surfaces
|
-- Scan all surfaces
|
||||||
|
@ -553,7 +553,7 @@ common.writeDebug("Restored %s entities", {restored})
|
||||||
common.writeDebug("Entered function %s()", {f_name})
|
common.writeDebug("Entered function %s()", {f_name})
|
||||||
|
|
||||||
local cnt = 0
|
local cnt = 0
|
||||||
for compound_entity, c in pairs(global.compound_entities) do
|
for compound_entity, c in pairs(storage.compound_entities) do
|
||||||
cnt = cnt + common.register_in_compound_entity_tab(compound_entity)
|
cnt = cnt + common.register_in_compound_entity_tab(compound_entity)
|
||||||
end
|
end
|
||||||
--~ common.writeDebug("Registered %s compound entities", {cnt})
|
--~ common.writeDebug("Registered %s compound entities", {cnt})
|
||||||
|
@ -647,7 +647,7 @@ common.show("new", {x = base_pos.x + offset.x, y = base_pos.y + offset.y})
|
||||||
for key, tab in pairs(hidden_entities) do
|
for key, tab in pairs(hidden_entities) do
|
||||||
common.writeDebug("key: %s\tname: %s", {key, tab})
|
common.writeDebug("key: %s\tname: %s", {key, tab})
|
||||||
--~ data = common.compound_entities[base_entity.name].hidden[key]
|
--~ data = common.compound_entities[base_entity.name].hidden[key]
|
||||||
data = global.compound_entities[base_entity.name].hidden[key]
|
data = storage.compound_entities[base_entity.name].hidden[key]
|
||||||
--~ common.show("common.compound_entities[base_entity.name].hidden",
|
--~ common.show("common.compound_entities[base_entity.name].hidden",
|
||||||
--~ common.compound_entities[base_entity.name].hidden)
|
--~ common.compound_entities[base_entity.name].hidden)
|
||||||
common.show("data", data)
|
common.show("data", data)
|
||||||
|
@ -671,7 +671,7 @@ common.show("data", data)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add optional values to global table
|
-- Add optional values to global table
|
||||||
--~ local optional = global.compound_entities[base_entity.name].optional
|
--~ local optional = storage.compound_entities[base_entity.name].optional
|
||||||
--~ for k, v in pairs(optional or {}) do
|
--~ for k, v in pairs(optional or {}) do
|
||||||
--~ g_table[base_entity.unit_number][k] = v
|
--~ g_table[base_entity.unit_number][k] = v
|
||||||
--~ end
|
--~ end
|
||||||
|
@ -688,7 +688,7 @@ common.show("data", data)
|
||||||
if common.get_startup_setting("BI_Easy_Bio_Gardens") then
|
if common.get_startup_setting("BI_Easy_Bio_Gardens") then
|
||||||
common.writeDebug("\"Easy gardens\": Compiling list of poles they can connect to!" )
|
common.writeDebug("\"Easy gardens\": Compiling list of poles they can connect to!" )
|
||||||
ret = {}
|
ret = {}
|
||||||
local poles = game.get_filtered_entity_prototypes({
|
local poles = prototypes.get_entity_filtered({
|
||||||
{filter = "type", type = "electric-pole"},
|
{filter = "type", type = "electric-pole"},
|
||||||
{filter = "name", name = {
|
{filter = "name", name = {
|
||||||
-- Poles named here will be ignored!
|
-- Poles named here will be ignored!
|
||||||
|
@ -713,23 +713,23 @@ common.writeDebug("\"Easy gardens\": Not active -- nothing to do!" )
|
||||||
-- added to the table yet if the pole has just been built. In this
|
-- added to the table yet if the pole has just been built. In this
|
||||||
-- case, we pass on the new pole explicitly!)
|
-- case, we pass on the new pole explicitly!)
|
||||||
common.connect_garden_pole = function(base, new_pole)
|
common.connect_garden_pole = function(base, new_pole)
|
||||||
local compound_entity = global.compound_entities["bi-bio-garden"]
|
local compound_entity = storage.compound_entities["bi-bio-garden"]
|
||||||
--~ local pole_type = "electric-pole"
|
--~ local pole_type = "electric-pole"
|
||||||
--~ local pole = global[compound_entity.tab][base.unit_number] and
|
--~ local pole = storage[compound_entity.tab][base.unit_number] and
|
||||||
--~ global[compound_entity.tab][base.unit_number][pole_type] or
|
--~ storage[compound_entity.tab][base.unit_number][pole_type] or
|
||||||
--~ new_pole
|
--~ new_pole
|
||||||
local pole = global[compound_entity.tab][base.unit_number] and
|
local pole = storage[compound_entity.tab][base.unit_number] and
|
||||||
global[compound_entity.tab][base.unit_number].pole or
|
storage[compound_entity.tab][base.unit_number].pole or
|
||||||
new_pole
|
new_pole
|
||||||
|
|
||||||
--~ if pole and pole.valid then
|
--~ if pole and pole.valid then
|
||||||
--~ local wire_reach = game.entity_prototypes[compound_entity.hidden[pole_type]] and
|
--~ local wire_reach = prototypes.entity[compound_entity.hidden[pole_type]] and
|
||||||
--~ game.entity_prototypes[compound_entity.hidden[pole_type]].max_wire_distance
|
--~ prototypes.entity[compound_entity.hidden[pole_type]].max_wire_distance
|
||||||
if pole and pole.valid and compound_entity.hidden and
|
if pole and pole.valid and compound_entity.hidden and
|
||||||
compound_entity.hidden.pole and
|
compound_entity.hidden.pole and
|
||||||
compound_entity.hidden.pole.name then
|
compound_entity.hidden.pole.name then
|
||||||
local wire_reach = game.entity_prototypes[compound_entity.hidden.pole.name] and
|
local wire_reach = prototypes.entity[compound_entity.hidden.pole.name] and
|
||||||
game.entity_prototypes[compound_entity.hidden.pole.name].max_wire_distance
|
prototypes.entity[compound_entity.hidden.pole.name].max_wire_distance
|
||||||
if not wire_reach then
|
if not wire_reach then
|
||||||
error("Prototype for hidden pole of Bio gardens doesn't exist!")
|
error("Prototype for hidden pole of Bio gardens doesn't exist!")
|
||||||
end
|
end
|
||||||
|
@ -758,14 +758,14 @@ common.writeDebug("Connected pole %g to %s %g: %s",
|
||||||
--~ -- Connect hidden poles to other poles that may be in reach.
|
--~ -- Connect hidden poles to other poles that may be in reach.
|
||||||
--~ common.garden_pole_connectors = common.garden_pole_connectors and next() or
|
--~ common.garden_pole_connectors = common.garden_pole_connectors and next() or
|
||||||
--~ common.get_garden_pole_connectors()
|
--~ common.get_garden_pole_connectors()
|
||||||
--~ common.show("Poles hidden bio-garden poles may connect to", global.mod_settings.garden_pole_connectors)
|
--~ common.show("Poles hidden bio-garden poles may connect to", storage.mod_settings.garden_pole_connectors)
|
||||||
|
|
||||||
-- Look for other poles around this one
|
-- Look for other poles around this one
|
||||||
neighbours = pole.surface.find_entities_filtered({
|
neighbours = pole.surface.find_entities_filtered({
|
||||||
position = pole.position,
|
position = pole.position,
|
||||||
radius = wire_reach,
|
radius = wire_reach,
|
||||||
type = "electric-pole",
|
type = "electric-pole",
|
||||||
name = global.mod_settings.garden_pole_connectors,
|
name = storage.mod_settings.garden_pole_connectors,
|
||||||
})
|
})
|
||||||
common.writeDebug("Pole %g has %s neighbours", {pole.unit_number, #neighbours})
|
common.writeDebug("Pole %g has %s neighbours", {pole.unit_number, #neighbours})
|
||||||
for n, neighbour in pairs(neighbours or{}) do
|
for n, neighbour in pairs(neighbours or{}) do
|
||||||
|
@ -785,7 +785,7 @@ common.writeDebug("Connected pole %g to neighbour %s (%g): %s",
|
||||||
common.connect_power_rail = function(base, new_pole)
|
common.connect_power_rail = function(base, new_pole)
|
||||||
--~ local pole_type = "electric-pole"
|
--~ local pole_type = "electric-pole"
|
||||||
|
|
||||||
local pole = global.bi_power_rail_table[base.unit_number].pole or new_pole
|
local pole = storage.bi_power_rail_table[base.unit_number].pole or new_pole
|
||||||
if pole and pole.valid then
|
if pole and pole.valid then
|
||||||
-- Remove all copper wires from new pole
|
-- Remove all copper wires from new pole
|
||||||
pole.disconnect_neighbour()
|
pole.disconnect_neighbour()
|
||||||
|
@ -806,7 +806,7 @@ common.writeDebug("Rail %s of %s (%s): %s (%s)", {direction, base.name, base.uni
|
||||||
|
|
||||||
-- Only make a connection if found rail is a powered rail
|
-- Only make a connection if found rail is a powered rail
|
||||||
-- (We'll know it's the right type if we find it in our table!)
|
-- (We'll know it's the right type if we find it in our table!)
|
||||||
neighbour = neighbour and neighbour.valid and global.bi_power_rail_table[neighbour.unit_number]
|
neighbour = neighbour and neighbour.valid and storage.bi_power_rail_table[neighbour.unit_number]
|
||||||
if neighbour and neighbour.pole and neighbour.pole.valid then
|
if neighbour and neighbour.pole and neighbour.pole.valid then
|
||||||
pole.connect_neighbour(neighbour.pole)
|
pole.connect_neighbour(neighbour.pole)
|
||||||
common.writeDebug("Connected poles!")
|
common.writeDebug("Connected poles!")
|
||||||
|
|
|
@ -48,7 +48,7 @@ end
|
||||||
local function get_bi_trees()
|
local function get_bi_trees()
|
||||||
local list = {}
|
local list = {}
|
||||||
|
|
||||||
local trees = game.get_filtered_entity_prototypes({{filter = "type", type = "tree"}})
|
local trees = prototypes.get_entity_filtered({{filter = "type", type = "tree"}})
|
||||||
for tree_name, tree in pairs(trees) do
|
for tree_name, tree in pairs(trees) do
|
||||||
if tree_name:match("^bio%-tree%-.+%-%d$") then
|
if tree_name:match("^bio%-tree%-.+%-%d$") then
|
||||||
BioInd.show("Found matching tree", tree_name)
|
BioInd.show("Found matching tree", tree_name)
|
||||||
|
@ -70,7 +70,7 @@ local tile_patterns = {
|
||||||
local function get_fixed_tiles()
|
local function get_fixed_tiles()
|
||||||
local list = {}
|
local list = {}
|
||||||
|
|
||||||
for tile_name, tile in pairs(game.tile_prototypes) do
|
for tile_name, tile in pairs(prototypes.tile) do
|
||||||
for p, pattern in ipairs(tile_patterns) do
|
for p, pattern in ipairs(tile_patterns) do
|
||||||
if tile_name:match(pattern) then
|
if tile_name:match(pattern) then
|
||||||
BioInd.show("Found matching tile", tile_name)
|
BioInd.show("Found matching tile", tile_name)
|
||||||
|
@ -89,7 +89,7 @@ end
|
||||||
local function get_arboretum_recipes()
|
local function get_arboretum_recipes()
|
||||||
local list = {}
|
local list = {}
|
||||||
|
|
||||||
local recipes = game.recipe_prototypes
|
local recipes = prototypes.recipe
|
||||||
local name
|
local name
|
||||||
|
|
||||||
for i = 1, 5 do
|
for i = 1, 5 do
|
||||||
|
@ -119,40 +119,40 @@ BioInd.writeDebug("Entered init!")
|
||||||
game.check_prototype_translations()
|
game.check_prototype_translations()
|
||||||
end
|
end
|
||||||
|
|
||||||
global = global or {}
|
storage = storage or {}
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- Settings
|
-- Settings
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- Global table for storing the last state of certain mod settings
|
-- Global table for storing the last state of certain mod settings
|
||||||
global.mod_settings = global.mod_settings or {}
|
storage.mod_settings = storage.mod_settings or {}
|
||||||
if BioInd.get_startup_setting("BI_Easy_Bio_Gardens") then
|
if BioInd.get_startup_setting("BI_Easy_Bio_Gardens") then
|
||||||
global.mod_settings.garden_pole_connectors = BioInd.get_garden_pole_connectors()
|
storage.mod_settings.garden_pole_connectors = BioInd.get_garden_pole_connectors()
|
||||||
else
|
else
|
||||||
global.mod_settings.garden_pole_connectors = nil
|
storage.mod_settings.garden_pole_connectors = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Global table for storing the data of compound entities. They may change between
|
-- Global table for storing the data of compound entities. They may change between
|
||||||
-- saves (e.g. Bio gardens only need hidden poles when the "Easy gardens" setting
|
-- saves (e.g. Bio gardens only need hidden poles when the "Easy gardens" setting
|
||||||
-- is active).
|
-- is active).
|
||||||
--~ global.compound_entities = global.compound_entities or BioInd.compound_entities
|
--~ storage.compound_entities = storage.compound_entities or BioInd.compound_entities
|
||||||
global.compound_entities = BioInd.rebuild_compound_entity_list()
|
storage.compound_entities = BioInd.rebuild_compound_entity_list()
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- Tree stuff!
|
-- Tree stuff!
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
global.bi = global.bi or {}
|
storage.bi = storage.bi or {}
|
||||||
global.bi.tree_growing = global.bi.tree_growing or {}
|
storage.bi.tree_growing = storage.bi.tree_growing or {}
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
global.bi["tree_growing_stage_" .. i] = global.bi["tree_growing_stage_" .. i] or {}
|
storage.bi["tree_growing_stage_" .. i] = storage.bi["tree_growing_stage_" .. i] or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- List of tree prototypes created by BI
|
-- List of tree prototypes created by BI
|
||||||
global.bi.trees = get_bi_trees()
|
storage.bi.trees = get_bi_trees()
|
||||||
|
|
||||||
-- List of tile prototypes that can't be fertilized
|
-- List of tile prototypes that can't be fertilized
|
||||||
global.bi.barren_tiles = get_fixed_tiles()
|
storage.bi.barren_tiles = get_fixed_tiles()
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- Compound entities
|
-- Compound entities
|
||||||
|
@ -160,7 +160,7 @@ BioInd.writeDebug("Entered init!")
|
||||||
-- Check what global tables we need for compound entities
|
-- Check what global tables we need for compound entities
|
||||||
local compound_entity_tables = {}
|
local compound_entity_tables = {}
|
||||||
--~ for compound, compound_data in pairs(BioInd.compound_entities) do
|
--~ for compound, compound_data in pairs(BioInd.compound_entities) do
|
||||||
for compound, compound_data in pairs(global.compound_entities) do
|
for compound, compound_data in pairs(storage.compound_entities) do
|
||||||
-- BioInd.compound_entities contains entries that point to the same table
|
-- BioInd.compound_entities contains entries that point to the same table
|
||||||
-- (e.g. straight/curved rails, or overlay entities), so we just overwrite
|
-- (e.g. straight/curved rails, or overlay entities), so we just overwrite
|
||||||
-- them to remove duplicates
|
-- them to remove duplicates
|
||||||
|
@ -172,37 +172,37 @@ BioInd.show("Need to check these tables in global", compound_entity_tables)
|
||||||
local result
|
local result
|
||||||
for compound_tab, compound_name in pairs(compound_entity_tables) do
|
for compound_tab, compound_name in pairs(compound_entity_tables) do
|
||||||
-- Init table
|
-- Init table
|
||||||
global[compound_tab] = global[compound_tab] or {}
|
storage[compound_tab] = storage[compound_tab] or {}
|
||||||
BioInd.writeDebug("Initialized global[%s] (%s entities stored)",
|
BioInd.writeDebug("Initialized storage[%s] (%s entities stored)",
|
||||||
{compound_name, table_size(global[compound_tab])})
|
{compound_name, table_size(storage[compound_tab])})
|
||||||
-- If this compound entity requires additional tables in global, initialize
|
-- If this compound entity requires additional tables in global, initialize
|
||||||
-- them now!
|
-- them now!
|
||||||
local related_tables = global.compound_entities[compound_name].add_global_tables
|
local related_tables = storage.compound_entities[compound_name].add_global_tables
|
||||||
if related_tables then
|
if related_tables then
|
||||||
for t, tab in ipairs(related_tables or {}) do
|
for t, tab in ipairs(related_tables or {}) do
|
||||||
global[tab] = global[tab] or {}
|
storage[tab] = storage[tab] or {}
|
||||||
BioInd.writeDebug("Initialized global[%s] (%s values)", {tab, table_size(global[tab])})
|
BioInd.writeDebug("Initialized storage[%s] (%s values)", {tab, table_size(storage[tab])})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- If this compound entity requires additional values in global, initialize
|
-- If this compound entity requires additional values in global, initialize
|
||||||
-- them now!
|
-- them now!
|
||||||
local related_vars = global.compound_entities[compound_name].add_global_values
|
local related_vars = storage.compound_entities[compound_name].add_global_values
|
||||||
if related_vars then
|
if related_vars then
|
||||||
for var_name, value in pairs(related_vars or {}) do
|
for var_name, value in pairs(related_vars or {}) do
|
||||||
global[var_name] = global[var_name] or value
|
storage[var_name] = storage[var_name] or value
|
||||||
BioInd.writeDebug("Set global[%s] to %s", {var_name, global[var_name]})
|
BioInd.writeDebug("Set storage[%s] to %s", {var_name, storage[var_name]})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clean up global tables (We can skip this for empty tables!)
|
-- Clean up global tables (We can skip this for empty tables!)
|
||||||
if next(global[compound_tab]) then
|
if next(storage[compound_tab]) then
|
||||||
-- Remove invalid entities
|
-- Remove invalid entities
|
||||||
result = BioInd.clean_global_compounds_table(compound_name)
|
result = BioInd.clean_global_compounds_table(compound_name)
|
||||||
BioInd.writeDebug("Removed %s invalid entries from global[%s]!",
|
BioInd.writeDebug("Removed %s invalid entries from storage[%s]!",
|
||||||
{result, compound_tab})
|
{result, compound_tab})
|
||||||
-- Restore missing hidden entities
|
-- Restore missing hidden entities
|
||||||
result = BioInd.restore_missing_entities(compound_name)
|
result = BioInd.restore_missing_entities(compound_name)
|
||||||
BioInd.writeDebug("Checked %s compound entities and restored %s missing hidden entries for global[\"%s\"]!",
|
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
|
||||||
end
|
end
|
||||||
|
@ -215,9 +215,9 @@ BioInd.show("Need to check these tables in global", compound_entity_tables)
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- Musk floor
|
-- Musk floor
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
global.bi_musk_floor_table = global.bi_musk_floor_table or {}
|
storage.bi_musk_floor_table = storage.bi_musk_floor_table or {}
|
||||||
global.bi_musk_floor_table.tiles = global.bi_musk_floor_table.tiles or {}
|
storage.bi_musk_floor_table.tiles = storage.bi_musk_floor_table.tiles or {}
|
||||||
global.bi_musk_floor_table.forces = global.bi_musk_floor_table.forces or {}
|
storage.bi_musk_floor_table.forces = storage.bi_musk_floor_table.forces or {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,17 +225,17 @@ BioInd.show("Need to check these tables in global", compound_entity_tables)
|
||||||
-- Arboretum
|
-- Arboretum
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- Global table for arboretum radars
|
-- Global table for arboretum radars
|
||||||
global.bi_arboretum_radar_table = global.bi_arboretum_radar_table or {}
|
storage.bi_arboretum_radar_table = storage.bi_arboretum_radar_table or {}
|
||||||
|
|
||||||
-- Global table of ingredients for terraformer recipes
|
-- Global table of ingredients for terraformer recipes
|
||||||
global.bi_arboretum_recipe_table = get_arboretum_recipes()
|
storage.bi_arboretum_recipe_table = get_arboretum_recipes()
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- Compatibility with other mods
|
-- Compatibility with other mods
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
global.compatible = global.compatible or {}
|
storage.compatible = storage.compatible or {}
|
||||||
global.compatible.AlienBiomes = BioInd.AB_tiles()
|
storage.compatible.AlienBiomes = BioInd.AB_tiles()
|
||||||
|
|
||||||
|
|
||||||
-- enable researched recipes
|
-- enable researched recipes
|
||||||
|
@ -279,11 +279,11 @@ BioInd.writeDebug("On Configuration changed: %s", {ConfigurationChangedData})
|
||||||
-- need to make sure that the lists of growing trees don't contain removed tree
|
-- need to make sure that the lists of growing trees don't contain removed tree
|
||||||
-- prototypes! (This fix is needed when "Alien Biomes" has been removed; it should
|
-- prototypes! (This fix is needed when "Alien Biomes" has been removed; it should
|
||||||
-- work with all other mods that create trees as well.)
|
-- work with all other mods that create trees as well.)
|
||||||
local trees = global.bi.trees
|
local trees = storage.bi.trees
|
||||||
local tab
|
local tab
|
||||||
-- Growing stages
|
-- Growing stages
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
tab = global.bi["tree_growing_stage_" .. i]
|
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, tree in pairs(tab) do
|
--~ for t, tree in pairs(tab) do
|
||||||
--~ if not trees[tree.tree_name] then
|
--~ if not trees[tree.tree_name] then
|
||||||
|
@ -352,7 +352,7 @@ Event.register(defines.events.on_trigger_created_entity, function(event)
|
||||||
--~ seed_planted_trigger(event)
|
--~ seed_planted_trigger(event)
|
||||||
BioInd.writeDebug("Seed Bomb Activated - Standard")
|
BioInd.writeDebug("Seed Bomb Activated - Standard")
|
||||||
local currTile = surface.get_tile(position).name
|
local currTile = surface.get_tile(position).name
|
||||||
if global.bi.barren_tiles[currTile] then
|
if storage.bi.barren_tiles[currTile] then
|
||||||
BioInd.writeDebug("Can't fertilize %s!", {currTile})
|
BioInd.writeDebug("Can't fertilize %s!", {currTile})
|
||||||
else
|
else
|
||||||
BioInd.writeDebug("Using fertilizer!")
|
BioInd.writeDebug("Using fertilizer!")
|
||||||
|
@ -369,7 +369,7 @@ Event.register(defines.events.on_trigger_created_entity, function(event)
|
||||||
--~ seed_planted_trigger(event)
|
--~ seed_planted_trigger(event)
|
||||||
BioInd.writeDebug("Seed Bomb Activated - Advanced")
|
BioInd.writeDebug("Seed Bomb Activated - Advanced")
|
||||||
local currTile = surface.get_tile(position).name
|
local currTile = surface.get_tile(position).name
|
||||||
if global.bi.barren_tiles[currTile] then
|
if storage.bi.barren_tiles[currTile] then
|
||||||
BioInd.writeDebug("Can't fertilize %s!", {currTile})
|
BioInd.writeDebug("Can't fertilize %s!", {currTile})
|
||||||
else
|
else
|
||||||
BioInd.writeDebug("Using fertilizer!")
|
BioInd.writeDebug("Using fertilizer!")
|
||||||
|
@ -406,7 +406,7 @@ local function On_Built(event)
|
||||||
|
|
||||||
BioInd.show("Built entity", BioInd.print_name_id(entity))
|
BioInd.show("Built entity", BioInd.print_name_id(entity))
|
||||||
|
|
||||||
local base_entry = global.compound_entities[entity.name]
|
local base_entry = storage.compound_entities[entity.name]
|
||||||
local base = base_entry and entity
|
local base = base_entry and entity
|
||||||
|
|
||||||
-- We've found a compound entity!
|
-- We've found a compound entity!
|
||||||
|
@ -448,7 +448,7 @@ BioInd.show("base_entry.optional", base_entry.optional)
|
||||||
BioInd.writeDebug("Second pass -- creating hidden entities!")
|
BioInd.writeDebug("Second pass -- creating hidden entities!")
|
||||||
BioInd.show("base_entry", base_entry)
|
BioInd.show("base_entry", base_entry)
|
||||||
|
|
||||||
BioInd.writeDebug("global[%s]: %s", {base_entry.tab, global[base_entry.tab]})
|
BioInd.writeDebug("storage[%s]: %s", {base_entry.tab, storage[base_entry.tab]})
|
||||||
BioInd.show("base.name", base.name)
|
BioInd.show("base.name", base.name)
|
||||||
BioInd.show("base.unit_number", base.unit_number)
|
BioInd.show("base.unit_number", base.unit_number)
|
||||||
BioInd.show("hidden_entities", hidden_entities)
|
BioInd.show("hidden_entities", hidden_entities)
|
||||||
|
@ -456,9 +456,9 @@ BioInd.show("hidden_entities", hidden_entities)
|
||||||
-- We must call create_entities even if there are no hidden entities (e.g. if
|
-- 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)
|
-- the "Easy Gardens" setting is disabled and no hidden poles are required)
|
||||||
-- because the compound entity gets registered there!
|
-- because the compound entity gets registered there!
|
||||||
BioInd.create_entities(global[base_entry.tab], base, hidden_entities)
|
BioInd.create_entities(storage[base_entry.tab], base, hidden_entities)
|
||||||
BioInd.writeDebug("Stored %s in table: %s",
|
BioInd.writeDebug("Stored %s in table: %s",
|
||||||
{BioInd.print_name_id(base), global[base_entry.tab][base.unit_number]})
|
{BioInd.print_name_id(base), storage[base_entry.tab][base.unit_number]})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The built entity isn't one of our compound entities.
|
-- The built entity isn't one of our compound entities.
|
||||||
|
@ -480,9 +480,9 @@ BioInd.show("Base entity", BioInd.print_name_id(base))
|
||||||
-- Arboretum radar -- we need to add it to the table!
|
-- Arboretum radar -- we need to add it to the table!
|
||||||
if entity.type == "radar" and
|
if entity.type == "radar" and
|
||||||
entity.name == entities["bi-arboretum-area"].hidden[h_key].name and base then
|
entity.name == entities["bi-arboretum-area"].hidden[h_key].name and base then
|
||||||
global.bi_arboretum_radar_table[entity.unit_number] = base.unit_number
|
storage.bi_arboretum_radar_table[entity.unit_number] = base.unit_number
|
||||||
entity.backer_name = ""
|
entity.backer_name = ""
|
||||||
BioInd.writeDebug("Added %s to global.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!
|
-- Electric poles -- we need to take care that they don't hook up to hidden poles!
|
||||||
elseif entity.type == "electric-pole" then
|
elseif entity.type == "electric-pole" then
|
||||||
|
@ -562,15 +562,15 @@ BioInd.writeDebug("Entered function On_Pre_Remove(%s)", {event})
|
||||||
end
|
end
|
||||||
|
|
||||||
--~ local compound_entity = BioInd.compound_entities[entity.name]
|
--~ local compound_entity = BioInd.compound_entities[entity.name]
|
||||||
local compound_entity = global.compound_entities[entity.name]
|
local compound_entity = storage.compound_entities[entity.name]
|
||||||
local base_entry = compound_entity and global[compound_entity.tab][entity.unit_number]
|
local base_entry = compound_entity and storage[compound_entity.tab][entity.unit_number]
|
||||||
BioInd.show("entity.name", entity.name)
|
BioInd.show("entity.name", entity.name)
|
||||||
BioInd.show("entity.unit_number", entity.unit_number)
|
BioInd.show("entity.unit_number", entity.unit_number)
|
||||||
|
|
||||||
BioInd.show("compound_entity", compound_entity)
|
BioInd.show("compound_entity", compound_entity)
|
||||||
BioInd.show("base_entry", base_entry)
|
BioInd.show("base_entry", base_entry)
|
||||||
BioInd.show("compound_entity.tab", compound_entity and compound_entity.tab or "nil")
|
BioInd.show("compound_entity.tab", compound_entity and compound_entity.tab or "nil")
|
||||||
BioInd.writeDebug("global[%s]: %s", {compound_entity and compound_entity.tab or "nil", compound_entity and global[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!
|
-- Found a compound entity from our list!
|
||||||
if base_entry then
|
if base_entry then
|
||||||
|
@ -579,8 +579,8 @@ BioInd.writeDebug("Found compound entity %s",
|
||||||
|
|
||||||
-- Arboretum: Need to separately remove the entry from the radar table
|
-- 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
|
if entity.name == "bi-arboretum" and base_entry.radar and base_entry.radar.valid then
|
||||||
global.bi_arboretum_radar_table[base_entry.radar.unit_number] = nil
|
storage.bi_arboretum_radar_table[base_entry.radar.unit_number] = nil
|
||||||
BioInd.show("Removed arboretum radar! Table", global.bi_arboretum_radar_table)
|
BioInd.show("Removed arboretum radar! Table", storage.bi_arboretum_radar_table)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Power rails: Connections must be explicitely removed, otherwise the poles
|
-- Power rails: Connections must be explicitely removed, otherwise the poles
|
||||||
|
@ -603,7 +603,7 @@ BioInd.writeDebug("Removing hidden entity %s", {BioInd.print_name_id(base_entry[
|
||||||
BioInd.remove_entity(base_entry[hidden])
|
BioInd.remove_entity(base_entry[hidden])
|
||||||
base_entry[hidden] = nil
|
base_entry[hidden] = nil
|
||||||
end
|
end
|
||||||
global[compound_entity.tab][entity.unit_number] = nil
|
storage[compound_entity.tab][entity.unit_number] = nil
|
||||||
|
|
||||||
-- Rail-to-power: Connections must be explicitely removed, otherwise the poles
|
-- Rail-to-power: Connections must be explicitely removed, otherwise the poles
|
||||||
-- from the different rail tracks hooked up to this connector will automatically
|
-- from the different rail tracks hooked up to this connector will automatically
|
||||||
|
@ -616,16 +616,16 @@ BioInd.writeDebug("Removing hidden entity %s", {BioInd.print_name_id(base_entry[
|
||||||
-- Removed seedling
|
-- Removed seedling
|
||||||
elseif entity.name == "seedling" then
|
elseif entity.name == "seedling" then
|
||||||
BioInd.writeDebug("Seedling has been removed")
|
BioInd.writeDebug("Seedling has been removed")
|
||||||
remove_plants(entity.position, global.bi.tree_growing)
|
remove_plants(entity.position, storage.bi.tree_growing)
|
||||||
|
|
||||||
-- Removed tree
|
-- Removed tree
|
||||||
elseif entity.type == "tree" and global.bi.trees[entity.name] then
|
elseif entity.type == "tree" and storage.bi.trees[entity.name] then
|
||||||
BioInd.show("Removed tree", entity.name)
|
BioInd.show("Removed tree", entity.name)
|
||||||
|
|
||||||
local tree_stage = entity.name:match('^.+%-(%d)$')
|
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
|
if tree_stage then
|
||||||
remove_plants(entity.position, global.bi["tree_growing_stage_" .. tree_stage])
|
remove_plants(entity.position, storage.bi["tree_growing_stage_" .. tree_stage])
|
||||||
else
|
else
|
||||||
error(string.format("Tree %s does not have a valid tree_stage: %s", entity.name, tree_stage or "nil"))
|
error(string.format("Tree %s does not have a valid tree_stage: %s", entity.name, tree_stage or "nil"))
|
||||||
end
|
end
|
||||||
|
@ -649,11 +649,11 @@ local function On_Damage(event)
|
||||||
|
|
||||||
-- Base was damaged: Find the radar associated with it!
|
-- Base was damaged: Find the radar associated with it!
|
||||||
if entity.name == arb then
|
if entity.name == arb then
|
||||||
associated = global.bi_arboretum_table[entity.unit_number].radar
|
associated = storage.bi_arboretum_table[entity.unit_number].radar
|
||||||
-- Radar was damaged: Find the base entity!
|
-- Radar was damaged: Find the base entity!
|
||||||
elseif entity.name == global.compound_entities[arb].hidden.radar.name then
|
elseif entity.name == storage.compound_entities[arb].hidden.radar.name then
|
||||||
local base_id = global.bi_arboretum_radar_table[entity.unit_number]
|
local base_id = storage.bi_arboretum_radar_table[entity.unit_number]
|
||||||
associated = global.bi_arboretum_table[base_id].base
|
associated = storage.bi_arboretum_table[base_id].base
|
||||||
end
|
end
|
||||||
|
|
||||||
if associated and associated.valid then
|
if associated and associated.valid then
|
||||||
|
@ -679,10 +679,10 @@ BioInd.writeDebug("Entered function %s(%s)", {f_name, event})
|
||||||
|
|
||||||
if
|
if
|
||||||
-- Table checks
|
-- Table checks
|
||||||
global.compound_entities[entity.name] or
|
storage.compound_entities[entity.name] or
|
||||||
global.bi.trees[entity.name] or
|
storage.bi.trees[entity.name] or
|
||||||
-- Entity checks
|
-- Entity checks
|
||||||
entity.name == global.compound_entities["bi-arboretum"].hidden.radar.name or
|
entity.name == storage.compound_entities["bi-arboretum"].hidden.radar.name or
|
||||||
entity.name == "bi-power-to-rail-pole" or
|
entity.name == "bi-power-to-rail-pole" or
|
||||||
entity.name == "seedling" then
|
entity.name == "seedling" then
|
||||||
|
|
||||||
|
@ -704,9 +704,9 @@ local function On_Sector_Scanned(event)
|
||||||
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 ----
|
---- Each time a Arboretum-Radar scans a sector ----
|
||||||
local arboretum = global.bi_arboretum_radar_table[event.radar.unit_number]
|
local arboretum = storage.bi_arboretum_radar_table[event.radar.unit_number]
|
||||||
if arboretum then
|
if arboretum then
|
||||||
Get_Arboretum_Recipe(global.bi_arboretum_table[arboretum], event)
|
Get_Arboretum_Recipe(storage.bi_arboretum_table[arboretum], event)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -740,21 +740,21 @@ BioInd.show("Removing", o.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove tile from global tables
|
-- Remove tile from global tables
|
||||||
local force_name = global.bi_musk_floor_table.tiles and
|
local force_name = storage.bi_musk_floor_table.tiles and
|
||||||
global.bi_musk_floor_table.tiles[x] and
|
storage.bi_musk_floor_table.tiles[x] and
|
||||||
global.bi_musk_floor_table.tiles[x][y]
|
storage.bi_musk_floor_table.tiles[x][y]
|
||||||
if force_name then
|
if force_name then
|
||||||
BioInd.writeDebug("Removing Musk floor tile from tables!")
|
BioInd.writeDebug("Removing Musk floor tile from tables!")
|
||||||
global.bi_musk_floor_table.tiles[x][y] = nil
|
storage.bi_musk_floor_table.tiles[x][y] = nil
|
||||||
if not next(global.bi_musk_floor_table.tiles[x]) then
|
if not next(storage.bi_musk_floor_table.tiles[x]) then
|
||||||
global.bi_musk_floor_table.tiles[x] = nil
|
storage.bi_musk_floor_table.tiles[x] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if global.bi_musk_floor_table.forces[force_name] and
|
if storage.bi_musk_floor_table.forces[force_name] and
|
||||||
global.bi_musk_floor_table.forces[force_name][x] then
|
storage.bi_musk_floor_table.forces[force_name][x] then
|
||||||
global.bi_musk_floor_table.forces[force_name][x][y] = nil
|
storage.bi_musk_floor_table.forces[force_name][x][y] = nil
|
||||||
if not next(global.bi_musk_floor_table.forces[force_name][x]) then
|
if not next(storage.bi_musk_floor_table.forces[force_name][x]) then
|
||||||
global.bi_musk_floor_table.forces[force_name][x] = nil
|
storage.bi_musk_floor_table.forces[force_name][x] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -783,12 +783,12 @@ local function place_musk_floor(force, position, surface)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add to global tables!
|
-- Add to global tables!
|
||||||
global.bi_musk_floor_table.tiles[x] = global.bi_musk_floor_table.tiles[x] or {}
|
storage.bi_musk_floor_table.tiles[x] = storage.bi_musk_floor_table.tiles[x] or {}
|
||||||
global.bi_musk_floor_table.tiles[x][y] = force
|
storage.bi_musk_floor_table.tiles[x][y] = force
|
||||||
|
|
||||||
global.bi_musk_floor_table.forces[force] = global.bi_musk_floor_table.forces[force] or {}
|
storage.bi_musk_floor_table.forces[force] = storage.bi_musk_floor_table.forces[force] or {}
|
||||||
global.bi_musk_floor_table.forces[force][x] = global.bi_musk_floor_table.forces[force][x] or {}
|
storage.bi_musk_floor_table.forces[force][x] = storage.bi_musk_floor_table.forces[force][x] or {}
|
||||||
global.bi_musk_floor_table.forces[force][x][y] = true
|
storage.bi_musk_floor_table.forces[force][x][y] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
|
@ -849,12 +849,12 @@ BioInd.show("index", index)
|
||||||
BioInd.show("t.old_tile.name", t.old_tile.name)
|
BioInd.show("t.old_tile.name", t.old_tile.name)
|
||||||
|
|
||||||
-- We want to restore removed tiles if nothing is supposed to grow on them!
|
-- We want to restore removed tiles if nothing is supposed to grow on them!
|
||||||
if global.bi.barren_tiles[t.old_tile.name] then
|
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})
|
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}
|
restore_tiles[#restore_tiles + 1] = {name = t.old_tile.name, position = t.position}
|
||||||
|
|
||||||
-- Is that tile minable?
|
-- Is that tile minable?
|
||||||
products = global.bi.barren_tiles[t.old_tile.name]
|
products = storage.bi.barren_tiles[t.old_tile.name]
|
||||||
if type(products) == "table" then
|
if type(products) == "table" then
|
||||||
--~ for p, product in ipairs(products) do
|
--~ for p, product in ipairs(products) do
|
||||||
--~ if player then
|
--~ if player then
|
||||||
|
@ -897,10 +897,10 @@ BioInd.show("restore_tiles", restore_tiles)
|
||||||
local removed_tiles = {}
|
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)
|
position = BioInd.normalize_position(t.position)
|
||||||
test = global.bi_musk_floor_table and
|
test = storage.bi_musk_floor_table and
|
||||||
global.bi_musk_floor_table.tiles and
|
storage.bi_musk_floor_table.tiles and
|
||||||
global.bi_musk_floor_table.tiles[position.x] and
|
storage.bi_musk_floor_table.tiles[position.x] and
|
||||||
global.bi_musk_floor_table.tiles[position.x][position.y]
|
storage.bi_musk_floor_table.tiles[position.x][position.y]
|
||||||
if test then
|
if test then
|
||||||
removed_tiles[#removed_tiles + 1] = {
|
removed_tiles[#removed_tiles + 1] = {
|
||||||
old_tile = {name = "bi-solar-mat"},
|
old_tile = {name = "bi-solar-mat"},
|
||||||
|
@ -937,8 +937,8 @@ local function Tile_Changed(event)
|
||||||
for t, tile in ipairs(event.tiles) do
|
for t, tile in ipairs(event.tiles) do
|
||||||
BioInd.show("t", t)
|
BioInd.show("t", t)
|
||||||
pos = BioInd.normalize_position(tile.position)
|
pos = BioInd.normalize_position(tile.position)
|
||||||
tile_force = global.bi_musk_floor_table.tiles[pos.x] and
|
tile_force = storage.bi_musk_floor_table.tiles[pos.x] and
|
||||||
global.bi_musk_floor_table.tiles[pos.x][pos.y]
|
storage.bi_musk_floor_table.tiles[pos.x][pos.y]
|
||||||
--~ -- Fall back to MuskForceName if it is available
|
--~ -- Fall back to MuskForceName if it is available
|
||||||
--~ UseMuskForce and MuskForceName or
|
--~ UseMuskForce and MuskForceName or
|
||||||
--~ -- Fall back to "neutral"
|
--~ -- Fall back to "neutral"
|
||||||
|
@ -1059,8 +1059,8 @@ Event.register(defines.events.on_entity_damaged, On_Damage, function(event)
|
||||||
-- Ignore damage without effect (invulnerable/resistant entities)
|
-- Ignore damage without effect (invulnerable/resistant entities)
|
||||||
if event.final_damage_amount ~= 0 and
|
if event.final_damage_amount ~= 0 and
|
||||||
-- Terraformer/Terraformer radar was damaged
|
-- Terraformer/Terraformer radar was damaged
|
||||||
(global.bi_arboretum_table[entity.unit_number] or
|
(storage.bi_arboretum_table[entity.unit_number] or
|
||||||
global.bi_arboretum_radar_table[entity.unit_number]) then
|
storage.bi_arboretum_radar_table[entity.unit_number]) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -1087,7 +1087,7 @@ setmetatable(_ENV, {
|
||||||
.. serpent.line{key = key or '<nil>', value = value or '<nil>'} .. '\n')
|
.. serpent.line{key = key or '<nil>', value = value or '<nil>'} .. '\n')
|
||||||
end,
|
end,
|
||||||
__index = function (self, key) --locked_global_read
|
__index = function (self, key) --locked_global_read
|
||||||
if not (key == "game" or key == "mods") then
|
if not (key == "game" or key == "mods" or key == "storage") then
|
||||||
error('\n\n[ER Global Lock] Forbidden global *read*:\n'
|
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
|
||||||
|
|
|
@ -49,7 +49,7 @@ end
|
||||||
-- Check that all ingredients are available!
|
-- Check that all ingredients are available!
|
||||||
local function check_ingredients(arboretum)
|
local function check_ingredients(arboretum)
|
||||||
local recipe = arboretum.get_recipe()
|
local recipe = arboretum.get_recipe()
|
||||||
local need = recipe and global.bi_arboretum_recipe_table[recipe.name]
|
local need = recipe and storage.bi_arboretum_recipe_table[recipe.name]
|
||||||
|
|
||||||
local function check(need, have)
|
local function check(need, have)
|
||||||
for name, amount in pairs(need or {}) do
|
for name, amount in pairs(need or {}) do
|
||||||
|
@ -111,7 +111,7 @@ function Get_Arboretum_Recipe(ArboretumTable, event)
|
||||||
|
|
||||||
-- 'AlienBiomes' is a bool value -- we don't want to read it again if it's false,
|
-- 'AlienBiomes' is a bool value -- we don't want to read it again if it's false,
|
||||||
-- but only if it hasn't been set yet!
|
-- but only if it hasn't been set yet!
|
||||||
AB = global.compatible.AlienBiomes
|
AB = storage.compatible.AlienBiomes
|
||||||
--~ terrain_name_g1 = terrain_name_g1 or (AB and "vegetation-green-grass-1" or "grass-1")
|
--~ terrain_name_g1 = terrain_name_g1 or (AB and "vegetation-green-grass-1" or "grass-1")
|
||||||
--~ terrain_name_g3 = terrain_name_g3 or (AB and "vegetation-green-grass-3" or "grass-3")
|
--~ terrain_name_g3 = terrain_name_g3 or (AB and "vegetation-green-grass-3" or "grass-3")
|
||||||
terrain_name_g1 = terrain_name_g1 or (AB and "vegetation-green-grass-1" or "grass-1")
|
terrain_name_g1 = terrain_name_g1 or (AB and "vegetation-green-grass-1" or "grass-1")
|
||||||
|
|
|
@ -317,7 +317,7 @@ BioInd.show("seedbomb", seedbomb)
|
||||||
surface = surface,
|
surface = surface,
|
||||||
seed_bomb = seedbomb
|
seed_bomb = seedbomb
|
||||||
}
|
}
|
||||||
plant_tree(global.bi.tree_growing, tree_data, false)
|
plant_tree(storage.bi.tree_growing, tree_data, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
function seed_planted(event)
|
function seed_planted(event)
|
||||||
|
@ -449,8 +449,8 @@ BioInd.show(growth_chance.." <= ("..fertility.." + 5)", growth_chance <= (fertil
|
||||||
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 (game.item_prototypes[stage_1_tree_name] or
|
if not (prototypes.item[stage_1_tree_name] or
|
||||||
game.entity_prototypes[stage_1_tree_name]) then
|
prototypes.entity[stage_1_tree_name]) then
|
||||||
stage_1_tree_name = tree_name
|
stage_1_tree_name = tree_name
|
||||||
end
|
end
|
||||||
BioInd.writeDebug("stage_1_tree_name: %s", {stage_1_tree_name})
|
BioInd.writeDebug("stage_1_tree_name: %s", {stage_1_tree_name})
|
||||||
|
@ -462,7 +462,7 @@ BioInd.writeDebug("stage_1_tree_name: %s", {stage_1_tree_name})
|
||||||
time = event.tick + grow_time,
|
time = event.tick + grow_time,
|
||||||
surface = surface
|
surface = surface
|
||||||
}
|
}
|
||||||
plant_tree(global.bi.tree_growing_stage_1, tree_data, true)
|
plant_tree(storage.bi.tree_growing_stage_1, tree_data, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -587,8 +587,8 @@ BioInd.writeDebug("Entered function Grow_tree_stage(%s, %s)", {stage_table, stag
|
||||||
local fertility, key = f.fertility, f.key
|
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 (game.item_prototypes[next_stage_tree_name] or
|
if not (prototypes.item[next_stage_tree_name] or
|
||||||
game.entity_prototypes[next_stage_tree_name]) then
|
prototypes.entity[next_stage_tree_name]) then
|
||||||
next_stage_tree_name = final_tree
|
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
|
else
|
||||||
|
@ -622,7 +622,7 @@ BioInd.writeDebug("Entered function Grow_tree_stage(%s, %s)", {stage_table, stag
|
||||||
time = time_planted + grow_time,
|
time = time_planted + grow_time,
|
||||||
surface = surface
|
surface = surface
|
||||||
}
|
}
|
||||||
plant_tree(global.bi["tree_growing_stage_"..next_stage], tree_data, true)
|
plant_tree(storage.bi["tree_growing_stage_"..next_stage], tree_data, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -636,32 +636,32 @@ end
|
||||||
---- Growing Tree
|
---- Growing Tree
|
||||||
--Event.register(-12, function(event)
|
--Event.register(-12, function(event)
|
||||||
Event.register(defines.events.on_tick, function(event)
|
Event.register(defines.events.on_tick, function(event)
|
||||||
if global.bi.tree_growing_stage_1 == nil then
|
if storage.bi.tree_growing_stage_1 == nil then
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
global.bi["tree_growing_stage_"..i] = global.bi["tree_growing_stage_"..i] or {}
|
storage.bi["tree_growing_stage_"..i] = storage.bi["tree_growing_stage_"..i] or {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tick = event.tick
|
local tick = event.tick
|
||||||
|
|
||||||
if global.bi.tree_growing[tick] then
|
if storage.bi.tree_growing[tick] then
|
||||||
for t, tree_data in pairs(global.bi.tree_growing[tick]) do
|
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)
|
Grow_tree_first_stage(tree_data, event)
|
||||||
end
|
end
|
||||||
BioInd.writeDebug("Removing global.bi.tree_growing[%s]!", {tick})
|
BioInd.writeDebug("Removing storage.bi.tree_growing[%s]!", {tick})
|
||||||
global.bi.tree_growing[tick] = nil
|
storage.bi.tree_growing[tick] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local stage_table
|
local stage_table
|
||||||
for stage = 1, 4 do
|
for stage = 1, 4 do
|
||||||
stage_table = global.bi["tree_growing_stage_"..stage]
|
stage_table = storage.bi["tree_growing_stage_"..stage]
|
||||||
if stage_table[tick] then
|
if stage_table[tick] then
|
||||||
for t, tree_data in pairs(stage_table[tick]) do
|
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)
|
Grow_tree_stage(tree_data, stage)
|
||||||
end
|
end
|
||||||
BioInd.writeDebug("Removing global.bi.tree_growing_stage_%s[%s]!",
|
BioInd.writeDebug("Removing storage.bi.tree_growing_stage_%s[%s]!",
|
||||||
{stage, tick})
|
{stage, tick})
|
||||||
stage_table[tick] = nil
|
stage_table[tick] = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,15 +73,15 @@ function ungroup(index_id, group_id)
|
||||||
end
|
end
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
function _init_group(index_id)
|
function _init_group(index_id)
|
||||||
if not global.group then
|
if not storage.group then
|
||||||
global.group = {}
|
storage.group = {}
|
||||||
end
|
end
|
||||||
if not global.group.default then
|
if not storage.group.default then
|
||||||
global.group.default = {}
|
storage.group.default = {}
|
||||||
end
|
end
|
||||||
if index_id and not global.group[index_id] then
|
if index_id and not storage.group[index_id] then
|
||||||
-- don't care if they name their group "default"
|
-- don't care if they name their group "default"
|
||||||
global.group[index_id] = {}
|
storage.group[index_id] = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ function _new_group(index_id)
|
||||||
local group_id_r = nil
|
local group_id_r = nil
|
||||||
|
|
||||||
while group_id_r == nil do
|
while group_id_r == nil do
|
||||||
local group_id_x = "gid-" .. (group_id_n + #global.group[index_id])
|
local group_id_x = "gid-" .. (group_id_n + #storage.group[index_id])
|
||||||
if global.group[index_id][group_id_x] then
|
if storage.group[index_id][group_id_x] then
|
||||||
-- collision
|
-- collision
|
||||||
group_id_n = group_id_n + 1
|
group_id_n = group_id_n + 1
|
||||||
else
|
else
|
||||||
|
@ -103,22 +103,22 @@ function _new_group(index_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _addto_group(index_id, group_id, member_id)
|
function _addto_group(index_id, group_id, member_id)
|
||||||
if global.group[index_id] then
|
if storage.group[index_id] then
|
||||||
if not global.group[index_id][group_id] then
|
if not storage.group[index_id][group_id] then
|
||||||
global.group[index_id][group_id] = {}
|
storage.group[index_id][group_id] = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(global.group[index_id][group_id], member_id)
|
table.insert(storage.group[index_id][group_id], member_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _get_group(index_id, group_id)
|
function _get_group(index_id, group_id)
|
||||||
return global.group[index_id][group_id]
|
return storage.group[index_id][group_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
function _of_group(index_id, member_id)
|
function _of_group(index_id, member_id)
|
||||||
--full scan
|
--full scan
|
||||||
for kx, vx in pairs(global.group[index_id]) do
|
for kx, vx in pairs(storage.group[index_id]) do
|
||||||
for ky, vy in pairs(vx) do
|
for ky, vy in pairs(vx) do
|
||||||
if member_id == vy then
|
if member_id == vy then
|
||||||
return vx
|
return vx
|
||||||
|
@ -129,7 +129,7 @@ function _of_group(index_id, member_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _clear_group(index_id, group_id)
|
function _clear_group(index_id, group_id)
|
||||||
global.group[index_id][group_id] = nil
|
storage.group[index_id][group_id] = nil
|
||||||
end
|
end
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -169,20 +169,20 @@ end
|
||||||
--~ data:extend({list})
|
--~ data:extend({list})
|
||||||
--[[
|
--[[
|
||||||
Types of settings:
|
Types of settings:
|
||||||
• startup - game must be restarted if changed (such a setting may affect prototypes' changes)
|
<EFBFBD> startup - game must be restarted if changed (such a setting may affect prototypes' changes)
|
||||||
• runtime-global - per-world setting
|
<EFBFBD> runtime-global - per-world setting
|
||||||
• runtime-per-user - per-user setting
|
<EFBFBD> runtime-per-user - per-user setting
|
||||||
|
|
||||||
Types of values:
|
Types of values:
|
||||||
• bool-setting
|
<EFBFBD> bool-setting
|
||||||
• double-setting
|
<EFBFBD> double-setting
|
||||||
• int-setting
|
<EFBFBD> int-setting
|
||||||
• string-setting
|
<EFBFBD> string-setting
|
||||||
|
|
||||||
Files being processed by the game:
|
Files being processed by the game:
|
||||||
• settings.lua
|
<EFBFBD> settings.lua
|
||||||
• settings-updates.lua
|
<EFBFBD> settings-updates.lua
|
||||||
• settings-final-fixes.lua
|
<EFBFBD> settings-final-fixes.lua
|
||||||
|
|
||||||
Using in DATA.lua:
|
Using in DATA.lua:
|
||||||
data:extend({
|
data:extend({
|
||||||
|
@ -230,7 +230,7 @@ Using in CONTROL.lua and in other code for reading:
|
||||||
event.player_index
|
event.player_index
|
||||||
event.setting
|
event.setting
|
||||||
GET: settings.startup["setting-name"].value - current value of startup setting; can be used in DATA.lua
|
GET: settings.startup["setting-name"].value - current value of startup setting; can be used in DATA.lua
|
||||||
GET: settings.global["setting-name"].value - current value of per-world setting
|
GET: settings.storage["setting-name"].value - current value of per-world setting
|
||||||
GET: set = settings.get_player_settings(LuaPlayer) - current values for per-player settings; then use set["setting-name"].value
|
GET: set = settings.get_player_settings(LuaPlayer) - current values for per-player settings; then use set["setting-name"].value
|
||||||
GET: settings.player - default values
|
GET: settings.player - default values
|
||||||
]]
|
]]
|
||||||
|
|
|
@ -99,10 +99,10 @@ settings_changed.bio_garden = function()
|
||||||
|
|
||||||
-- Has this setting been changed since the last time the game was run?
|
-- Has this setting been changed since the last time the game was run?
|
||||||
local current = BioInd.get_startup_setting("BI_Easy_Bio_Gardens")
|
local current = BioInd.get_startup_setting("BI_Easy_Bio_Gardens")
|
||||||
BioInd.show("Last state of BI_Easy_Bio_Gardens", global.mod_settings.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("Current state of BI_Easy_Bio_Gardens", current)
|
||||||
|
|
||||||
if global.mod_settings.BI_Easy_Bio_Gardens ~= current then
|
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
|
local pole, neighbours
|
||||||
-- This is the unmodified table!
|
-- This is the unmodified table!
|
||||||
|
@ -110,7 +110,7 @@ BioInd.writeDebug("Setting has been changed!")
|
||||||
local hidden_entities = compound_entity.hidden
|
local hidden_entities = compound_entity.hidden
|
||||||
|
|
||||||
-- Check that all gardens are still valid
|
-- Check that all gardens are still valid
|
||||||
for g, garden in pairs(global[compound_entity.tab]) do
|
for g, garden in pairs(storage[compound_entity.tab]) do
|
||||||
-- Base entity doesn't exist -- remove hidden entities!''
|
-- Base entity doesn't exist -- remove hidden entities!''
|
||||||
if not (garden.base and garden.base.valid) then
|
if not (garden.base and garden.base.valid) then
|
||||||
-- Remove all hidden entities!
|
-- Remove all hidden entities!
|
||||||
|
@ -122,7 +122,7 @@ BioInd.writeDebug("Removing hidden entity %s %s", {
|
||||||
BioInd.remove_entity(garden[hidden])
|
BioInd.remove_entity(garden[hidden])
|
||||||
garden[hidden] = nil
|
garden[hidden] = nil
|
||||||
end
|
end
|
||||||
global[compound_entity.tab][garden.entity.unit_number] = nil
|
storage[compound_entity.tab][garden.entity.unit_number] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,12 +148,12 @@ BioInd.writeDebug("Removing hidden entity %s %s", {
|
||||||
-- Setting is on, so we need to create the hidden poles
|
-- Setting is on, so we need to create the hidden poles
|
||||||
if current then
|
if current then
|
||||||
BioInd.writeDebug("Need to create hidden poles for %s Bio Gardens!",
|
BioInd.writeDebug("Need to create hidden poles for %s Bio Gardens!",
|
||||||
{table_size(global.bi_bio_garden_table) })
|
{table_size(storage.bi_bio_garden_table) })
|
||||||
|
|
||||||
-- Restore the list of hidden entities
|
-- Restore the list of hidden entities
|
||||||
global.compound_entities["bi-bio-garden"] = BioInd.compound_entities["bi-bio-garden"]
|
storage.compound_entities["bi-bio-garden"] = BioInd.compound_entities["bi-bio-garden"]
|
||||||
local base
|
local base
|
||||||
for g, garden in pairs(global.bi_bio_garden_table or {}) do
|
for g, garden in pairs(storage.bi_bio_garden_table or {}) do
|
||||||
-- Make sure the base entity exists!
|
-- Make sure the base entity exists!
|
||||||
base = garden.base
|
base = garden.base
|
||||||
pole = base and garden[pole_type]
|
pole = base and garden[pole_type]
|
||||||
|
@ -168,7 +168,7 @@ BioInd.show("pole", pole)
|
||||||
elseif base then
|
elseif base then
|
||||||
-- Create hidden poles
|
-- Create hidden poles
|
||||||
pole = BioInd.create_entities(
|
pole = BioInd.create_entities(
|
||||||
global[compound_entity.tab],
|
storage[compound_entity.tab],
|
||||||
base,
|
base,
|
||||||
{pole = hidden_entities[pole_type].name}
|
{pole = hidden_entities[pole_type].name}
|
||||||
--~ base.position
|
--~ base.position
|
||||||
|
@ -176,11 +176,11 @@ BioInd.show("pole", pole)
|
||||||
|
|
||||||
-- Add the new pole to the table
|
-- Add the new pole to the table
|
||||||
if pole then
|
if pole then
|
||||||
global[compound_entity.tab][base.unit_number][pole_type] = pole
|
storage[compound_entity.tab][base.unit_number][pole_type] = pole
|
||||||
BioInd.writeDebug("Stored %s %g in table: %s", {
|
BioInd.writeDebug("Stored %s %g in table: %s", {
|
||||||
base.name,
|
base.name,
|
||||||
base.unit_number,
|
base.unit_number,
|
||||||
global[compound_entity.tab][base.unit_number]
|
storage[compound_entity.tab][base.unit_number]
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -189,10 +189,10 @@ BioInd.show("pole", pole)
|
||||||
-- Setting is off -- disconnect and remove hidden poles!
|
-- Setting is off -- disconnect and remove hidden poles!
|
||||||
else
|
else
|
||||||
BioInd.writeDebug("%s Bio Gardens found -- try to disconnect hidden poles!",
|
BioInd.writeDebug("%s Bio Gardens found -- try to disconnect hidden poles!",
|
||||||
{table_size(global.bi_bio_garden_table) })
|
{table_size(storage.bi_bio_garden_table) })
|
||||||
-- Find hidden poles of registered gardens
|
-- Find hidden poles of registered gardens
|
||||||
BioInd.show("global.bi_bio_garden_table", global.bi_bio_garden_table)
|
BioInd.show("storage.bi_bio_garden_table", storage.bi_bio_garden_table)
|
||||||
for g, garden in pairs(global.bi_bio_garden_table or {}) do
|
for g, garden in pairs(storage.bi_bio_garden_table or {}) do
|
||||||
if garden[pole_type] then
|
if garden[pole_type] then
|
||||||
-- Pole really exists: destroy the entity
|
-- Pole really exists: destroy the entity
|
||||||
if garden[pole_type].valid then
|
if garden[pole_type].valid then
|
||||||
|
@ -212,8 +212,8 @@ BioInd.show("global.bi_bio_garden_table", global.bi_bio_garden_table)
|
||||||
|
|
||||||
-- We don't want to create hidden poles if the setting is off,
|
-- We don't want to create hidden poles if the setting is off,
|
||||||
-- so remove the pole from hidden entities!
|
-- so remove the pole from hidden entities!
|
||||||
global.compound_entities["bi-bio-garden"].hidden[pole_type] = nil
|
storage.compound_entities["bi-bio-garden"].hidden[pole_type] = nil
|
||||||
BioInd.show("global.compound_entities", global.compound_entities)
|
BioInd.show("storage.compound_entities", storage.compound_entities)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove any hidden poles that are not associated with a garden
|
-- Remove any hidden poles that are not associated with a garden
|
||||||
|
@ -224,8 +224,8 @@ BioInd.show("global.compound_entities", global.compound_entities)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update setting!
|
-- Update setting!
|
||||||
global.mod_settings.BI_Easy_Bio_Gardens = current
|
storage.mod_settings.BI_Easy_Bio_Gardens = current
|
||||||
BioInd.show("Updated setting to", global.mod_settings.BI_Easy_Bio_Gardens)
|
BioInd.show("Updated setting to", storage.mod_settings.BI_Easy_Bio_Gardens)
|
||||||
else
|
else
|
||||||
BioInd.writeDebug("Nothing to do!")
|
BioInd.writeDebug("Nothing to do!")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue