on_pre_player_cursor_stack_changed

Things that we aren't going to implement
Xorimuth
Filter Inserter
Filter Inserter
Posts: 708
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

on_pre_player_cursor_stack_changed

Post by Xorimuth »

Similar to viewtopic.php?f=221&t=86422&p=500583

I'd like to change the item that a player is holding (triggered by `on_player_cursor_stack_changed` or some other event), but I want to be able to change it back again when the player returns it to their inventory _or any other inventory_. I can listen to `on_player_main_inventory_changed` for the player's inventory, but not for arbitrary inventories. I can't just look at LuaControl::cursor_stack because it doesn't exist at the point that `on_player_cursor_stack_changed` is triggered in this scenario.

The alternative is to let `on_player_cursor_stack_changed` also return the `LuaItemStack` of the replaced item.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Rseding91
Factorio Staff
Factorio Staff
Posts: 14591
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_pre_player_cursor_stack_changed

Post by Rseding91 »

This isn't really possible. The event fires long after the item has been changed and any number of other things could have happened to the item. The game simply sets a flag that the cursor stack was changed this or last tick and when it next updates it sends the event.
If you want to get ahold of me I'm almost always on Discord.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 708
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: on_pre_player_cursor_stack_changed

Post by Xorimuth »

Rseding91 wrote: Mon Aug 31, 2020 8:07 pm This isn't really possible. The event fires long after the item has been changed and any number of other things could have happened to the item. The game simply sets a flag that the cursor stack was changed this or last tick and when it next updates it sends the event.
Thanks for the response. Presumably `on_player_inserted_into_inventory -> player_index, inventory` wouldn't be possible either? That would pretty much solve the same problem for me.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Post Reply

Return to “Won't implement”