Hello all,
I am trying to figure out how to reliably calculate the bounding box of a blueprint on the surface when it is being placed down by the player during the on_pre_build event. The reason for this is that I need to apply some operations on any number of ghost entities that occupy the affected area to ensure consistency.
So far I have managed to calculate the blueprint width/height and to then use the event's position and direction to calculate the bounding box on top of the surface. This is based around treating the event position as center of the blueprint and doing some iteration over blueprint entities (using their positions within the blueprint) to calculate the blueprint width/height. This works reliably so long as the player is not using a blueprint with snap to grid (either relative or absolute). Current implementation I have for this can be found at:
- https://github.com/azaghal/Factorio-Con ... .lua#L1455 (event handler)
- https://github.com/azaghal/Factorio-Con ... l.lua#L959 (bounding box calculation based on blueprint dimensions, position, and orientation)
- https://github.com/azaghal/Factorio-Con ... l.lua#L918 (blueprint dimensions calculation)
- https://github.com/azaghal/Factorio-Con ... .lua#L1001 (individual entity bounding box calculation within blueprint itself)
The problem when using snap to grid and dragging the blueprint is that the event position will no longer denote the placed blueprint's center (-ish) position on the surface past the first blueprint placed in this manner. The event position will instead usually point to the "edge" where the player has crossed with the cursor outside of the bounds of previously placed blueprint borders.
Does anyone have an idea on how to reliably get the center position of placed blueprint during the on_pre_build event - including the above edge case when using blueprints that snap to grid?
Blueprint bounding box during on_pre_build event with relative snap-to-grid
Place to get help with not working mods / modding interface.
Jump to
- General
- ↳ Releases
- ↳ News
- ↳ General discussion
- ↳ Multiplayer
- ↳ Find Servers / Tools / Guides
- ↳ Show your Creations
- ↳ Videos
- ↳ Combinator Creations
- ↳ Mechanical Throughput Magic (circuit-free)
- ↳ Railway Setups
- ↳ Energy Production
- ↳ Medium/Big/Gigantic Sized Structures
- ↳ Fan Art
- ↳ Gameplay Help
- ↳ Spread the Word
- ↳ Off topic
- ↳ This Forum
- ↳ Celebration Party
- Support
- ↳ Gameplay Help
- ↳ Discover Factorio Wiki
- ↳ Discover Others Creations
- ↳ Discover Mods
- ↳ Discover Tools Around Factorio
- ↳ Technical Help
- ↳ Bug Reports
- ↳ Resolved for the next release
- ↳ Assigned
- ↳ Not a bug
- ↳ Pending
- ↳ 1 / 0 magic
- ↳ Duplicates
- ↳ Minor issues
- ↳ Desyncs with mods
- ↳ Won't fix.
- ↳ Resolved Problems and Bugs
- Factorio Direction
- ↳ Ideas and Suggestions
- ↳ Outdated/Not implemented
- ↳ Frequently Suggested / Link Collections
- ↳ Implemented Suggestions
- ↳ Development Proposals
- ↳ Balancing
- Contributions
- ↳ Mods
- ↳ Download mods
- ↳ Mod portal Discussion
- ↳ Mods
- ↳ Mod Packs / Libs / Special Interest
- ↳ 5dim's mod
- ↳ Angels Mods
- ↳ Atomic Power
- ↳ Bob's mods
- ↳ DyWorld
- ↳ F.A.R.L
- ↳ Fentus Challenge & Tool Mods
- ↳ Logistic Train Network
- ↳ MoMods
- ↳ Reika's Mods
- ↳ Resource Spawner Overhaul
- ↳ Yuoki Industries
- ↳ PyMods
- ↳ Questions, reviews and ratings
- ↳ Modding Discussions
- ↳ Modding discussion
- ↳ Modding help
- ↳ Ideas and Requests For Mods
- ↳ Modding interface requests
- ↳ Implemented mod requests
- ↳ Already exists
- ↳ Won't implement
- ↳ Documentation Improvement Requests
- ↳ Resolved Requests
- ↳ Development tools
- ↳ Tools
- ↳ Mod and installation managers
- ↳ Cheatsheets / Calculators / Viewers
- ↳ Development tools
- ↳ Special interest mods and libraries
- ↳ Modding Development
- ↳ Multiplayer / Dedicated Server
- ↳ Multiplayer Board
- ↳ Archive
- ↳ Maps and Scenarios
- ↳ Translations
- ↳ Texture Packs
- ↳ Fan Art
- ↳ Wiki Talk
- ↳ To be sorted
- ↳ Campaign / Scenario suggestions