I assume that if I'm given a Position chunk_position, I can convert that to a bounding box by doing x * 32, y * 32, x * 32 + 31, y * 32 + 31. However, it seems kind of hacky to hardcode those numbers, even if the size of a chunk is not likely to ever change.
Ultimately, what I want is a way to get the BoundingBox for on_chunk_charted
https://lua-api.factorio.com/latest/eve ... nk_charted
It's a little unfortunate that on_chunk_charted and on_chunk_generated have different attributes. Is it possible to unify that somehow? Preferably by having the bounding box in both, or at perhaps by adding the bounding box to on_chunk_charted without removing any of its existing attributes.
Canonical way to convert ChunkPosition -> BoundingBox?
-
- Fast Inserter
- Posts: 187
- Joined: Fri Jan 05, 2018 5:18 pm
- Contact:
-
- Smart Inserter
- Posts: 1459
- Joined: Sun Jun 15, 2014 11:39 am
- Contact:
Re: Canonical way to convert ChunkPosition -> BoundingBox?
seems to be the current way to handle it. for that last part it would need to be a modding interface request and unless there is some particular reason for it the devs should add it.
i would suggest going to viewforum.php?f=28 and clearly explain exactly what your requesting they add and why. at that point they should take a look at it soonish compared to here where its buried under a sort of question even though its more a feature request
i would suggest going to viewforum.php?f=28 and clearly explain exactly what your requesting they add and why. at that point they should take a look at it soonish compared to here where its buried under a sort of question even though its more a feature request
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Canonical way to convert ChunkPosition -> BoundingBox?
Code: Select all
for chunk in surface.get_chunks() do
local area = {
left_top = {x = chunk.x*32 , y = chunk.y*32 },
right_bottom = {x = chunk.x*32+32, y = chunk.y*32+32}
}
--dostuff
end
Btw, why are you using +31? When i tested with rendering.draw_rectangle the above code seemed to perfectly match the tile grid.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
-
- Fast Inserter
- Posts: 187
- Joined: Fri Jan 05, 2018 5:18 pm
- Contact:
Re: Canonical way to convert ChunkPosition -> BoundingBox?
Wasn't sure if it would use < or <= at the end of the range. 32 makes more sense now that you mention it. Thanks!eradicator wrote: ↑Fri Aug 02, 2019 1:33 pmBtw, why are you using +31? When i tested with rendering.draw_rectangle the above code seemed to perfectly match the tile grid.
Re: Canonical way to convert ChunkPosition -> BoundingBox?
I have added the area to the event for the next version.AngledLuffa wrote: ↑Mon Jul 29, 2019 3:13 amUltimately, what I want is a way to get the BoundingBox for on_chunk_charted
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
-
- Fast Inserter
- Posts: 187
- Joined: Fri Jan 05, 2018 5:18 pm
- Contact:
Re: Canonical way to convert ChunkPosition -> BoundingBox?
Thank you, that's perfect!