z_mirror/EditorExtensions
git clone https://git.raiguard.me/z_mirror/EditorExtensions
cabb4ba
trunk
1local content = 2[[Editor Extensions has been updated to 2.0. This version is a BREAKING CHANGE, meaning that your testing setups may not function as they did before. 3 4The infinity loader has been overhauled to fix belt saturation issues, solve edge cases with blueprints, and make them much more UPS efficient. Due to this, [font=default-bold][color=255,50,50]all previously placed infinity loaders will no longer function.[/color][/font] You will need to replace them in order for your testing setups to work again. 5 6Due to game engine limitations, the new infinity loader only supports a single item filter. To put different items on each side of a belt, use two infinity loaders. 7 8Each legacy infinity loader has been located and put into your alerts panel. If you wish to remove them, press the button below, or use the [font=default-bold]/ee-remove-legacy-loaders[/font] command. 9 10There are many other changes, improvements, and new features as well. Please consult the changelog for more details. 11 12Finally, the mod's control scripting has been rewritten from scratch, so there may be a few crashes. Please report any crashes you run into, and I will fix them posthaste. Thank you for your patience, and thank you for using Editor Extensions! 13 14- raiguard]] 15 16local flib_gui =require ( "__flib__.gui" ) 17 18local function remove_legacy_loaders () 19for _ , loader in pairs ( storage . legacy_infinity_loaders or {} ) do 20if loader . valid then 21loader . destroy () 22end 23end 24storage . legacy_infinity_loaders =nil 25end 26 27local function on_notification_confirm_clicked ( e ) 28local player =game . get_player ( e . player_index ) 29if not player then 30return 31end 32 33local window =player . gui . screen . ee_update_notification_window 34if not window then 35return 36end 37 38window . destroy () 39end 40 41flib_gui . add_handlers ( { 42on_notification_confirm_clicked =on_notification_confirm_clicked , 43on_notification_remove_legacy_loaders_clicked =remove_legacy_loaders , 44} ) 45 46--- @param player LuaPlayer 47local function create_gui ( player ) 48if player . gui . screen . ee_update_notification_window then 49return 50end 51 52flib_gui . add ( player . gui . screen , { 53type ="frame" , 54name ="ee_update_notification_window" , 55style_mods ={ width =500 } , 56direction ="vertical" , 57caption ="Editor Extensions 2.0" , 58elem_mods ={ auto_center =true } , 59{ 60type ="frame" , 61style ="inside_shallow_frame_with_padding" , 62{ type ="label" , style_mods ={ single_line =false } , caption =content } , 63} , 64{ 65type ="flow" , 66style ="dialog_buttons_horizontal_flow" , 67drag_target ="ee_update_notification_window" , 68{ 69type ="button" , 70style ="red_button" , 71style_mods ={ height =32 , bottom_padding =2 , font ="default-dialog-button" } , 72caption ="[img=utility/warning] Destroy all legacy loaders" , 73handler ={ 74[ defines . events . on_gui_click ] =remove_legacy_loaders , 75} , 76} , 77{ type ="empty-widget" , style ="flib_dialog_footer_drag_handle" , ignored_by_interaction =true } , 78{ 79type ="button" , 80style ="confirm_button" , 81caption ={ "gui.confirm" } , 82handler ={ [ defines . events . on_gui_click ] =on_notification_confirm_clicked } , 83} , 84} , 85} ) 86end 87 88--- @param e BuiltEvent 89local function on_entity_built ( e ) 90local entity =e . entity or e . destination 91if not entity . valid or entity . name ~= "ee-infinity-loader-dummy-combinator" then 92return 93end 94local loaders =storage . legacy_infinity_loaders 95if not loaders then 96loaders ={} 97storage . legacy_infinity_loaders =loaders 98end 99loaders [ entity . unit_number ] =entity 100end 101 102local update_notification ={} 103 104--- @param e ConfigurationChangedData 105update_notification . on_configuration_changed =function ( e ) 106local ee_changes =e . mod_changes [ "EditorExtensions" ] 107if 108not ee_changes 109or not ee_changes . old_version 110or helpers . compare_versions ( ee_changes . old_version , "1.99.99" ) > 0 111then 112return 113end 114 115for _ , player in pairs ( game . players ) do 116create_gui ( player ) 117end 118 119--- @type table<uint64, LuaEntity> 120local loaders ={} 121for _ , surface in pairs ( game . surfaces ) do 122for _ , loader in pairs ( surface . find_entities_filtered ( { name ="ee-infinity-loader-dummy-combinator" } )) do 123loaders [ loader . unit_number ] =loader 124end 125for _ , chest in pairs ( surface . find_entities_filtered ( { name ="ee-infinity-loader-chest" } )) do 126chest . destroy () 127end 128end 129storage . legacy_infinity_loaders =loaders 130end 131 132update_notification . on_nth_tick ={ 133[ 180 ] =function () 134if not storage . legacy_infinity_loaders then 135return 136end 137 138for i , legacy in pairs ( storage . legacy_infinity_loaders ) do 139if not legacy . valid then 140storage . legacy_infinity_loaders [ i ] =nil 141goto continue 142end 143 144for _ , player in pairs ( legacy . force . players ) do 145player . add_custom_alert ( 146legacy , 147{ type ="item" , name ="ee-infinity-loader" } , 148"Remove legacy infinity loader" , 149true 150) 151end 152 153:: continue :: 154end 155 156if not next ( storage . legacy_infinity_loaders ) then 157storage . legacy_infinity_loaders =nil 158end 159end , 160} 161 162commands . add_command ( "ee-remove-legacy-loaders" , nil , function () 163remove_legacy_loaders () 164end ) 165 166update_notification . events ={ 167[ defines . events . on_built_entity ] =on_entity_built , 168[ defines . events . on_entity_cloned ] =on_entity_built , 169[ defines . events . on_robot_built_entity ] =on_entity_built , 170[ defines . events . script_raised_built ] =on_entity_built , 171[ defines . events . script_raised_revive ] =on_entity_built , 172[ defines . events . on_space_platform_built_entity ] =on_entity_built , 173} 174 175return update_notification