I am currently trying to add a furnace-type entity to my mod and accessing it's fluid_boxes property. I have created this entity in one lua file:
Code: Select all
local cooling_tower = table.deepcopy(data.raw["furnace"]["electric-furnace"])
cooling_tower.type = "furnace"
cooling_tower.name = "cooling-tower"
cooling_tower.icon = graphics.."icons/cooling-tower.png"
cooling_tower.icon_size = 32
cooling_tower.flags = {"hide-alt-info", "placeable-player", "player-creation"}
cooling_tower.minable = {hardness = 0.2, mining_time = 0.5, result = "cooling-tower"}
cooling_tower.max_health = 500
cooling_tower.corpse = "medium-remnants"
cooling_tower.resistances =
{
{
type = "fire",
percent = 70
}
}
cooling_tower.collision_box = {{-1.5, -1.5}, {1.5, 1.5}}
cooling_tower.selection_box = {{-1.5, -1.5}, {1.5, 1.5}}
cooling_tower.drawing_box = {{-1.5, -1.5}, {1.5, 1.5}}
cooling_tower.fluid_boxes =
{
{
production_type = "input",
volume = 1000,
pipe_covers = pipecoverspictures(),
pipe_picture = nil,
pipe_connections = {
{position = {-1, -1}, flow_direction = "input", direction = defines.direction.west},
{position = {-1, -1}, flow_direction = "input", direction = defines.direction.north},
{position = {1, -1}, flow_direction = "input", direction = defines.direction.north},
{position = {1, -1}, flow_direction = "input", direction = defines.direction.east}
},
secondary_draw_orders = { north = -1 }
},
{
production_type = "output",
volume = 1000,
pipe_covers = pipecoverspictures(),
pipe_picture = nil,
pipe_connections =
{
{position = {-1, 1}, flow_direction = "output", direction = defines.direction.west},
{position = {-1, 1}, flow_direction = "output", direction = defines.direction.south},
{position = {1, 1}, flow_direction = "output", direction = defines.direction.south},
{position = {1, 1}, flow_direction = "output", direction = defines.direction.east}
},
secondary_draw_orders = { north = -1 }
}
}
cooling_tower.fluid_boxes_off_when_no_fluid_recipe = false
cooling_tower.source_inventory_size = 0
cooling_tower.result_inventory_size = 0
cooling_tower.crafting_categories = {"water-cooling"}
cooling_tower.energy_usage = "200kW" -- will be increased during active water cooling
cooling_tower.graphics_set =
{
animation =
{
layers =
{
{
filename = graphics.."entity/cooling-tower/cooling-tower.png",
width = 308, height = 310,
shift = {0.695, -0.66},
scale = 0.505
}
},
{
{
filename = graphics.."entity/cooling-tower/cooling-tower-shadow.png",
width = 430, height = 310,
shift = util.by_pixel(52, -21),
scale = 0.5,
draw_as_shadow = true,
flags = {"shadow"}
}
}
},
working_visualisations =
{
{
filename = graphics.."entity/cooling-tower/cooling-tower-light.png",
scale = 0.505,
width = 308, height = 310,
shift = {0.695, -0.66},
tint = {r = 1, g = 0, b = 0},
draw_as_light = true,
priority = "extra-high",
flags = {"light"}
}
},
{
{
filename = graphics.."entity/cooling-tower/cooling-tower-glow.png",
scale = 0.505,
width = 308, height = 310,
shift = {0.695, -0.66},
tint = {r = 1, g = 0, b = 0},
draw_as_light = true,
priority = "extra-high",
flags = {"light"}
}
}
}
data:extend({cooling_tower})
Code: Select all
script.on_event({ defines.events.on_built_entity, defines.events.on_robot_built_entity, defines.events.script_raised_built, defines.events.script_raised_revive }, function(event)
local entity = event.created_entity or event.entity
if entity and entity.valid and entity.name == cooling_tower_name then
cooling_tower_placed(entity)
end
end)
Code: Select all
function cooling_tower_placed(entity)
table.insert(cooling_tower_entities, entity)
game.print(#cooling_tower_entities)
game.print(entity.name)
game.print(entity.type)
game.print(entity.fluid_boxes[1].amount)
end
Code: Select all
1
cooling-tower
furnace
. But it should, right? The entity seemingly gets added correctly to the array "cooling-tower-entities", and I can access it's name and type. Does anyone know, what I am doing wrong? I am using Factorio Space Age 2.0.15.LuaEntity doesn't contain key fluid_boxes
Any help is appreciated!