Page 1 of 1

Allow temporary cursor stack for selection tool

Posted: Wed Apr 16, 2025 7:55 pm
by Cooldude2606
As title says, allow LuaPlayer::cursor_stack_temporary for "selection-tool".

Reason: it behaves like a blueprint / deconstruction planner / upgrade planner in how it selects things and that it is not expected to return to the inventory if it was given to the player via a commond or gui interaction.

Use case: I have players use a command which provides them with a selection tool to select an area, using "on_player_selected_area" I can listen for this action to perform my logic then clear the cursor. But if the player presses Q to clear the cursor then it returns to the inventory, which causes issues if the player's inventory is full. My current solution is to use "character_inventory_slots_bonus" but this has many edge cases such as entering and exiting remote view, the player dieing, needing to set hand location in the inventory, etc. These would not exist if I could set the stack as temporary like is possible with a deconstruction planner.

Re: Allow temporary cursor stack for selection tool

Posted: Thu Apr 17, 2025 11:35 pm
by LazyManiac13
AFAIK you can achieve what you want by setting "only-in-cursor" flag in your "selection-tool" item prototype flags

Re: Allow temporary cursor stack for selection tool

Posted: Fri Apr 18, 2025 11:38 pm
by Cooldude2606
That solution would work for some selection tools, but some others are created with extra command arguments (tacked with LuaItemCommon.item_number) and it can be useful to keep these in your inventory to avoid needing to re-use the command. This is the same behaviour as a decon planner where pressing Q will delete it, but you can manually place it into your inventory.