Mapping entity to occupied tiles for processing blueprint in Python script
Posted: Fri Dec 24, 2021 6:59 am
I'm not actually trying to write a mod, but I thought this forum might be able to help. I'm planning to write a Python script for my own use which will take as input a blueprint string, and output another blueprint string, formed by adding some entities to the input blueprint based on some logic. For this, I need to know the set of grid cells occupied by entities in the input blueprint. For example, when I see
I want to be able to get the coordinates of the grid cells occupied by the flamethrower turret. It seems for this one needs to know that "flamethrower-turret" is a 2x3 or 3x2 thing. So maybe it would suffice to have or be able to derive a mapping from each possible entity name to its size, as a pair of integers. Is there a way to get this data, in a form which can be read by Python easily? It's fine if this is only for the base game, without mod support.
I'm not looking for the collision box, or the size of the graphics, or such details - I'm only looking for the integer grid cell size from the player's point of view - eg 2x2 for accumulator, 2x3 for boiler, 5x5 for refinery, 1x1 for inserter, etc.
So far I took a look at https://wiki.factorio.com/Modding and the data.raw file but I'm not sure if I'm looking at the right place. Also I'm not familiar with Lua.
Code: Select all
{
"entity_number": 1,
"name": "flamethrower-turret",
"position": {
"x": -687.5,
"y": 86
},
"direction": 6
},
I'm not looking for the collision box, or the size of the graphics, or such details - I'm only looking for the integer grid cell size from the player's point of view - eg 2x2 for accumulator, 2x3 for boiler, 5x5 for refinery, 1x1 for inserter, etc.
So far I took a look at https://wiki.factorio.com/Modding and the data.raw file but I'm not sure if I'm looking at the right place. Also I'm not familiar with Lua.