Page 1 of 1
Where will build_from_cursor() build?
Posted: Wed Apr 22, 2026 11:26 pm
by BeBoxer
Is there a lua function that will tell you the coordinates where build_from_cursor() will try and build something? In the game, you can visually see the cursor snap to the possible placements. But via the API I don't see a way to do this. In my MCP code, a successful placement results in a callback and you can see where the entity ended up. But if the call fails, there's no feedback about why. And without knowing the coordinates that the build_from_cursor() was actually trying to place the entity, it's hard to figure out why it failed. In my case, it's usually something in the way but without knowing what coordinates the build was snapped to I can't just do a find_entity() of some fashion on the bounding box. Thanks in advance!
Re: Where will build_from_cursor() build?
Posted: Wed Apr 22, 2026 11:49 pm
by Loewchen
Re: Where will build_from_cursor() build?
Posted: Thu Apr 23, 2026 2:27 pm
by BeBoxer
Yes, the LuaPlayer->build_from_cursor() function. In the UI, as you move the cursor it's constantly refreshed showing the exact location the build will happen and whether it will succeed. In the API though there doesn't seem to be any way to get that information that I can find.
Re: Where will build_from_cursor() build?
Posted: Thu Apr 23, 2026 2:49 pm
by robot256
Re: Where will build_from_cursor() build?
Posted: Thu Apr 23, 2026 9:58 pm
by BeBoxer
I'm already using that but the issue is that the coordinates that are used to determine placement aren't necessarily the ones passed in. And if you don't know the coordinates actually being used to determine if placement is valid, it's hard to figure out why a given spot won't work.
Simple example, if you have a drill placed it will have a drop_position coordinate. A chest won't actually fit at that location because it's a bit off center, but you can build_from_cursor() at the drop position with a chest because it will snap to the right location. If you try to do the same thing and place a furnace at the drop_position for the drill it will fail because whatever coordinates the game snaps to result in the furnace overlapping with the drill. That would be easy enough to check if I knew what coordinates the build was actually trying to use but I can't figure out how to get that information.
In the common / simple case I could write my own code that would probably figure it out. Drills and chests and simple square entities I can figure out I'm sure. Some things like water pumps are rectangular and it's less obvious what the internal logic is. So it would be helpful to have an 'official' way to get the info.