on_pre_player_cursor_stack_changed
Posted: Sun Aug 30, 2020 9:45 pm
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.
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.