Page 1 of 1

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

Posted: Sun Aug 01, 2021 8:11 pm
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.