Allow LuaPlayer.cursor_stack_temporary write for all selection tools

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
LeonSkills
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 11, 2019 12:37 pm
Contact:

Allow LuaPlayer.cursor_stack_temporary write for all selection tools

Post by LeonSkills »

Currently writing to LuaPlayer.cursor_stack_temporary is ignored for everything that is not a blueprint, blueprint-book, deconstruction-planner or upgrade-planner.
I request to make this check one level higher, make it work for all selection tools.

Most modded selection tools, like the vanilla ones, are free to create using the shortcut bar. If they are created this way this value will already be set to true even though it is not one of the above types:
Image

So would be nice to have this same behaviour when the item is created elsewhere.

Usecase:

The following code

Code: Select all

      
player.clear_cursor()
local inventory = player.get_main_inventory()
local item_stack = inventory.find_item_stack(selection_tool)
if item_stack then
  item_stack.swap_stack(player.cursor_stack)
else
  player.cursor_stack.set_stack({name=selection_tool})
end
can turn into

Code: Select all

      
player.clear_cursor()
player.cursor_stack.set_stack({name=selection_tool})
player.cursor_stack_temporary=true
The selection_tool item enters the inventory in the first case, but not in the second. It never has to be in the inventory.

Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: Allow LuaPlayer.cursor_stack_temporary write for all selection tools

Post by Xorimuth »

Are you aware of the "only-in-cursor" flag on item prototypes? https://wiki.factorio.com/Types/ItemPro ... -cursor%22

Although personally I'd like `cursor_stack_temporary` write for all items, as I currently attempt to implement a similar thing for the wires in Wire Shortcuts X. My workaround works ok, but it is far from perfect as I can't easily stop the player from manually placing the 'temporary' wires into their inventory.
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

LeonSkills
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 11, 2019 12:37 pm
Contact:

Re: Allow LuaPlayer.cursor_stack_temporary write for all selection tools

Post by LeonSkills »

Xorimuth wrote:
Wed Feb 01, 2023 2:01 am
Are you aware of the "only-in-cursor" flag on item prototypes? https://wiki.factorio.com/Types/ItemPro ... -cursor%22
I was aware, yes. But good point.

That flag conflicts with the "mod-openable" flag as I still want it to have a settings menu pop up on right click when in inventory/toolbar. With only-in-cursor you can't do that.
I guess I can just stick with only allowing the settings menu to be opened from the top left menu button. (Although apparently that button doesn't pop up for some people with certain mods)
Xorimuth wrote:
Wed Feb 01, 2023 2:01 am
Although personally I'd like `cursor_stack_temporary` write for all items, as I currently attempt to implement a similar thing for the wires in Wire Shortcuts X. My workaround works ok, but it is far from perfect as I can't easily stop the player from manually placing the 'temporary' wires into their inventory.
Also a good point, I don't see why it should be limited to just selection tools.

Post Reply

Return to “Modding interface requests”