I need to access to the area tiles an entity will take when built, and I can't get to find a way to get the entity size in my event handler,
I tried to use the collision_box property but it returns a () instead of a bounding_box,
I also tried to use the tile_width and tile_height properties but cannot seem to access it neither,
the bounding_box seems to be a nil in the on_built_event,
I can't get any access to the position of the player's cursor neither, I can't find any other solution..
I need help, is there a way to get the size of an entity being built?
Can't get to access to the area an entity is covering
-
- Burner Inserter
- Posts: 11
- Joined: Mon May 15, 2017 11:20 pm
- Contact:
Re: Can't get to access to the area an entity is covering
You should be able to get the collision box through the entity prototype:Helldragger wrote:I need to access to the area tiles an entity will take when built, and I can't get to find a way to get the entity size in my event handler,
I tried to use the collision_box property but it returns a () instead of a bounding_box,
I also tried to use the tile_width and tile_height properties but cannot seem to access it neither,
the bounding_box seems to be a nil in the on_built_event,
I can't get any access to the position of the player's cursor neither, I can't find any other solution..
I need help, is there a way to get the size of an entity being built?
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.created_entity
local prototype = game.entity_prototypes[entity.name]
game.print(serpent.line(prototype.collision_box))
end)
Re: Can't get to access to the area an entity is covering
If you are using the on_built event then you have an entity you can work with and get the bounding_box with the correct position offset using
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.created_entity
local area = entity.bounding_box
game.print(serpent.line(area))
end)
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.created_entity
local area = entity.bounding_box
game.print(serpent.line(area))
end)
-
- Burner Inserter
- Posts: 11
- Joined: Mon May 15, 2017 11:20 pm
- Contact:
Re: Can't get to access to the area an entity is covering
OMG I am so so so stupid, I tried Nexela approach before and got a nil because I used regular indexes instead of the x and y key values...
Thanks to both of you for your quick and helpful answers, kudos to both of you! It works!
Let's see if I can make biomes more interesting now!
Edit: btw, thanks to you I discovered the serpent library
so useful damn!
Thanks to both of you for your quick and helpful answers, kudos to both of you! It works!

Edit: btw, thanks to you I discovered the serpent library
