Method to get "selected" entity while player is holding a blueprint.

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Method to get "selected" entity while player is holding a blueprint.

Post by eradicator »

The problem:

While the player is holding a blueprint entity selection is neither updated (read), nor updatable (write) and LuaControl.update_selected_entity(position) has no effect. I need to know which entity would theoretically be selected if the player wasn't holding a blueprint during a custom-input event.

Possible solutions:

Things that I think could solve my problem, in preferred order.

1) A new method that simply gets the entity. I.e. LuaControl.get_selectable_entity(position).

2) A parameter to make update_selected_entity work even while holding a blueprint. Something like:

Code: Select all

function get_selectable_entity(player, pos)
  player.update_selected_entity(pos, {enforce = true}) 
  return player.selected end
3) A modification to LuaSurface.find_entities(_filtered) that allows searching entities by selection_box instead of collision_box. This isn't optimal as a working lua-side solution would then still need to filter for selectibility (i.e. is it rendered to this force?), selection_priority, etcpp. But still better than doing an over-sized area search and then doing lua-side position<->selection_box collision checking.
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.

Post Reply

Return to “Modding interface requests”