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.
on_pre_player_cursor_stack_changed
on_pre_player_cursor_stack_changed
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: on_pre_player_cursor_stack_changed
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.
Re: on_pre_player_cursor_stack_changed
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.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.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings