z_mirror/CursorEnhancements
git clone https://git.raiguard.me/z_mirror/CursorEnhancements
aa43e4b
smart-quickbar
1local util =require ( "__CursorEnhancements__/scripts/util" ) 2 3--- @param e EventData.on_player_cursor_stack_changed 4local function on_player_cursor_stack_changed ( e ) 5local player =game . get_player ( e . player_index ) 6if not player then 7return 8end 9local item =util . get_cursor_item ( player ) 10if not item then 11return 12end 13 14for i =1 , 100 do 15local slot =player . get_quick_bar_slot ( i ) 16if slot and slot . name == item then 17player . set_active_quick_bar_page ( 1 , math . floor ( i / 10 ) + 1 ) 18end 19end 20end 21 22--- @param e EventData.CustomInputEvent 23local function on_smart_pipette ( e ) 24global . pipetting [ e . player_index ] =true 25end 26 27local function init () 28--- @type table<uint, boolean> 29global . pipetting ={} 30end 31 32local smart_quickbar ={} 33 34smart_quickbar . on_init =init 35smart_quickbar . on_configuration_changed =init 36 37smart_quickbar . events ={ 38[ "cen-linked-smart-pipette" ] =on_smart_pipette , 39[ defines . events . on_player_cursor_stack_changed ] =on_player_cursor_stack_changed , 40} 41 42return smart_quickbar