Fix Musk floor

This commit is contained in:
Simon Brodtmann 2025-07-06 11:02:48 +02:00
parent 721f6f271f
commit 7ca55d0e7a
3 changed files with 203 additions and 23 deletions

View file

@ -459,34 +459,12 @@ BioInd.show("Base entity", BioInd.print_name_id(base))
-- Electric poles -- we need to take care that they don't hook up to hidden poles!
elseif entity.type == "electric-pole" then
BioInd.show("entities[\"bi-straight-rail-power\"].hidden[h_key].name", entities["bi-straight-rail-power"].hidden[h_key].name)
local pole = entity
-- Make sure hidden poles of the Bio gardens are connected correctly!
if pole.name == entities["bi-bio-garden"].hidden[h_key].name and base then
BioInd.writeDebug("Bio garden!")
BioInd.connect_garden_pole(base, pole)
BioInd.writeDebug("Connected %s (%s)", {pole.name, pole.unit_number or "nil"})
-- Make sure hidden poles for powered rails are connected correctly!
elseif pole.name == entities["bi-straight-rail-power"].hidden[h_key].name and base then
BioInd.writeDebug("Powered rail!")
BioInd.connect_power_rail(base, pole)
BioInd.writeDebug("Connected %s", {BioInd.print_name_id(pole)})
-- Do nothing for rail-to-power connectors
elseif pole.name == "bi-power-to-rail-pole" then
BioInd.writeDebug("Nothing to do for %s", {BioInd.print_name_id(pole)})
-- Disconnect other poles from hidden poles on powered rails
else
BioInd.writeDebug("Must disconnect!")
for n, neighbour in ipairs(pole.neighbours["copper"] or {}) do
if neighbour.name == entities["bi-straight-rail-power"].hidden[h_key].name then
pole.disconnect_neighbour(neighbour)
BioInd.writeDebug("Disconnected %s from %s",
{BioInd.print_name_id(pole), BioInd.print_name_id(neighbour)})
end
end
end
-- A seedling has been planted

View file

@ -201,4 +201,5 @@ end
require(HIDDENPATH .. "hidden_lamps")
require(HIDDENPATH .. "hidden_panels")
require(HIDDENPATH .. "hidden_poles")
require(HIDDENPATH .. "hidden_radars")

View file

@ -0,0 +1,201 @@
-- Add functions that are also used in other files (debugging output etc.)
local BioInd = require('common')('Bio_Industries')
BioInd.writeDebug("Entered prototypes.hidden_poles.lua of \"%s\".", {BioInd.modName})
local ICONPATH = BioInd.modRoot .. "/graphics/icons/"
------------------------------------------------------------------------------------
-- Create the main prototype for hidden poles. All others will be based on this! --
------------------------------------------------------------------------------------
--~ local h_type = "electric-pole"
--~ local h_entity = table.deepcopy(data.raw[h_type]["small-electric-pole"])
-- The short name of the hidden entity (e.g. "lamp" or "pole")
local h_key = "pole"
-- The actual prototype type, identified by h_key
local h_type = BioInd.HE_map[h_key]
local h_entity = table.deepcopy(data.raw[h_type]["small-electric-pole"])
BI.set_common_properties(h_entity)
------------------------------------------------------------------------------------
-- Pole specific attributes!
h_entity.draw_copper_wires = BioInd.is_debug
h_entity.draw_circuit_wires = BioInd.is_debug
h_entity.maximum_wire_distance = 10
h_entity.supply_area_distance = 5
--~ hidden_pole.resistances = {}
--~ for damage, d in pairs(data.raw["damage-type"]) do
--~ hidden_pole.resistances[#hidden_pole.resistances +1] = {
--~ type = damage,
--~ percent = 100
--~ }
--~ end
--~ BioInd.show("hidden_pole.resistances", hidden_pole.resistances)
h_entity.connection_points = BioInd.is_debug and
h_entity.connection_points or {
{
shadow = {},
wire = { copper_wire_tweak = {0, 0} }
}
}
--~ h_entity.connection_points = h_entity.connection_points
h_entity.radius_visualisation_picture = BioInd.is_debug and
h_entity.radius_visualisation_picture or
BI.hidden_entities.picture
h_entity.energy_source = {
type = "electric",
usage_priority = "solar"
}
------------------------------------------------------------------------------------
-- Make a copy of the hidden-entity prototype for each compound entity! --
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
-- Compile a list of the hidden entities we'll need
BI.make_hidden_entity_list(h_key)
-- Musk floor is not an entity, but a tile, so we don't have a compound-entity table
-- for it and must add it manually!
local Musk_name = "bi-musk-mat-hidden-pole"
BI.hidden_entities.types[h_key][Musk_name] = "bi-solar-mat"
-- We only have one "connector" at the moment. No need to add another file just for that,
-- so let's add this connector manually to the list!
BI.hidden_entities.types[h_key]["bi-bio-farm-hidden-connector_pole"] = "bi-bio-farm"
local function shift_picture(pole, offset)
if not BioInd.is_debug then
pole.pictures.shift = offset or {0, 0}
end
end
------------------------------------------------------------------------------------
-- Make the copies!
local tmp, pole
local c_entities = BioInd.compound_entities
BioInd.writeDebug("BI.hidden_entities.types[%s]: %s", {h_key, BI.hidden_entities.types[h_key]})
--~ for pole_name, locale_name in pairs(pole_list) do
for pole_name, locale_name in pairs(BI.hidden_entities.types[h_key]) do
BioInd.show("pole_name", pole_name)
BioInd.show("locale_name", locale_name)
--~ pole = table.deepcopy(data.raw["electric-pole"]["bi-hidden-power-pole"])
pole = table.deepcopy(h_entity)
pole.name = pole_name
pole.localised_name = {"entity-name." .. locale_name}
pole.localised_description = {"entity-description." .. locale_name}
pole.icon_size = BioInd.is_debug and pole.icon_size or 64
------------------------------------------------------------------------------------
-- Adjust properties for hidden biofarm poles
------------------------------------------------------------------------------------
--~ if c_entities["bi-bio-farm"] then
--~ -- We have connectors on the roof of Bio farms, so we want to display connections
--~ if c_entities["bi-bio-farm"].hidden["connector"] and
--~ pole_name == c_entities["bi-bio-farm"].hidden["connector"].name then
local biofarm_connector = c_entities["bi-bio-farm"].hidden["connector"] and
pole_name == c_entities["bi-bio-farm"].hidden["connector"].name
local biofarm_pole = (c_entities["bi-bio-farm"].hidden[h_key] and
pole_name == c_entities["bi-bio-farm"].hidden[h_key].name)
if c_entities["bi-bio-farm"] and biofarm_connector or biofarm_pole then
-- We have connectors on the roof of Bio farms, so we want to display connections
--~ if (c_entities["bi-bio-farm"].hidden["connector"] and
--~ pole_name == c_entities["bi-bio-farm"].hidden["connector"].name) then
if biofarm_connector then
pole.draw_copper_wires = true
local vanilla = table.deepcopy(data.raw[h_type]["small-electric-pole"])
local cp = vanilla.connection_points[1]
local offset_y = 2.7
for img, img_data in ipairs({"shadow", "wire"}) do
cp[img_data].green = nil
cp[img_data].red = nil
cp[img_data].copper[1] = cp[img_data].copper[1] + (offset_x or 0)
cp[img_data].copper[2] = cp[img_data].copper[2] + (offset_y or 0)
end
pole.connection_points = BioInd.is_debug and vanilla.connection_points or {cp}
pole.pictures = BioInd.is_debug and vanilla.pictures or pole.pictures
--~ pole.supply_area_distance = 1
pole.supply_area_distance = 5
pole.maximum_wire_distance = 5
shift_picture(pole)
BioInd.show("Adjusted properties of", pole_name)
-- Hidden center pole for supplying the area around the building
--~ elseif pole_name == c_entities["bi-bio-farm"].hidden[h_key].name then
--~ elseif (c_entities["bi-bio-farm"].hidden[h_key] and
--~ pole_name == c_entities["bi-bio-farm"].hidden[h_key].name) then
else
--~ pole.draw_copper_wires = true
pole.maximum_wire_distance = 2
pole.supply_area_distance = 5
--~ pole.selection_box = {{-.25, -.25}, {.25, .25}}
--~ pole.selectable_in_game = true
shift_picture(pole)
BioInd.show("Adjusted properties of", pole_name)
end
------------------------------------------------------------------------------------
-- Adjust properties for hidden power-rail pole
------------------------------------------------------------------------------------
elseif (c_entities["bi-straight-rail-power"] and
c_entities["bi-straight-rail-power"].hidden[h_key] and
pole_name == c_entities["bi-straight-rail-power"].hidden[h_key].name) or
(c_entities["bi-curved-rail-power"] and
c_entities["bi-curved-rail-power"].hidden[h_key] and
pole_name == c_entities["bi-curved-rail-power"].hidden[h_key].name) then
--~ elseif pole_name == c_entities["bi-straight-rail-power"].hidden[h_key].name then
--~ pole.localised_name = {"entity-name.bi-rail-power"}
--~ pole.localised_description = {"entity-description.bi-rail-power"}
pole.maximum_wire_distance = 9
pole.supply_area_distance = 2
shift_picture(pole)
BioInd.show("Adjusted properties of", pole_name)
------------------------------------------------------------------------------------
-- Adjust properties for hidden pole of bio gardens
------------------------------------------------------------------------------------
elseif c_entities["bi-bio-garden"] and
-- This pole may have been removed because "Easy Gardens" is disabled!
c_entities["bi-bio-garden"].hidden[h_key] and
pole_name == c_entities["bi-bio-garden"].hidden[h_key].name then
pole.maximum_wire_distance = 4
pole.supply_area_distance = 1
shift_picture(pole)
BioInd.show("Adjusted properties of", pole_name)
------------------------------------------------------------------------------------
-- Adjust properties for hidden pole of Musk floor
------------------------------------------------------------------------------------
elseif pole_name == Musk_name then
pole.icon = ICONPATH .. "solar-mat.png"
pole.icon_size = 64
pole.maximum_wire_distance = 1
pole.supply_area_distance = 3
BioInd.show("Adjusted properties of", pole_name)
end
data:extend({pole})
BioInd.show("Created", pole_name)
end
------------------------------------------------------------------------------------
--~ -- Testing
--~ for k, v in pairs(data.raw[h_entity.type]) do
--~ BioInd.writeDebug("%s: %s", {k, v})
--~ end