z_mirror/EditorExtensions
git clone https://git.raiguard.me/z_mirror/EditorExtensions
f07b347
hidden-items
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-lite" ) 17local flib_migration =require ( "__flib__/migration" ) 18 19local function remove_legacy_loaders () 20for _ , loader in pairs ( global . legacy_infinity_loaders or {} ) do 21if loader . valid then 22loader . destroy () 23end 24end 25global . legacy_infinity_loaders =nil 26end 27 28local function on_notification_confirm_clicked ( e ) 29local player =game . get_player ( e . player_index ) 30if not player then 31return 32end 33 34local window =player . gui . screen . ee_update_notification_window 35if not window then 36return 37end 38 39window . destroy () 40end 41 42flib_gui . add_handlers ( { 43on_notification_confirm_clicked =on_notification_confirm_clicked , 44on_notification_remove_legacy_loaders_clicked =remove_legacy_loaders , 45} ) 46 47--- @param player LuaPlayer 48local function create_gui ( player ) 49if player . gui . screen . ee_update_notification_window then 50return 51end 52 53flib_gui . add ( player . gui . screen , { 54type ="frame" , 55name ="ee_update_notification_window" , 56style_mods ={ width =500 } , 57direction ="vertical" , 58caption ="Editor Extensions 2.0" , 59elem_mods ={ auto_center =true } , 60{ 61type ="frame" , 62style ="inside_shallow_frame_with_padding" , 63{ type ="label" , style_mods ={ single_line =false } , caption =content } , 64} , 65{ 66type ="flow" , 67style ="dialog_buttons_horizontal_flow" , 68drag_target ="ee_update_notification_window" , 69{ 70type ="button" , 71style ="red_button" , 72style_mods ={ height =32 , bottom_padding =2 , font ="default-dialog-button" } , 73caption ="[img=utility/warning] Destroy all legacy loaders" , 74handler ={ 75[ defines . events . on_gui_click ] =remove_legacy_loaders , 76} , 77} , 78{ type ="empty-widget" , style ="flib_dialog_footer_drag_handle" , ignored_by_interaction =true } , 79{ 80type ="button" , 81style ="confirm_button" , 82caption ={ "gui.confirm" } , 83handler ={ [ defines . events . on_gui_click ] =on_notification_confirm_clicked } , 84} , 85} , 86} ) 87end 88 89--- @param e BuiltEvent 90local function on_entity_built ( e ) 91local entity =e . entity or e . created_entity or e . destination 92if not entity . valid or entity . name ~= "ee-infinity-loader-dummy-combinator" then 93return 94end 95local loaders =global . legacy_infinity_loaders 96if not loaders then 97loaders ={} 98global . legacy_infinity_loaders =loaders 99end 100loaders [ entity . unit_number ] =entity 101end 102 103local update_notification ={} 104 105--- @param e ConfigurationChangedData 106update_notification . on_configuration_changed =function ( e ) 107local ee_changes =e . mod_changes [ "EditorExtensions" ] 108if 109not ee_changes 110or not ee_changes . old_version 111or flib_migration . is_newer_version ( "1.99.99" , ee_changes . old_version ) 112then 113return 114end 115 116for _ , player in pairs ( game . players ) do 117create_gui ( player ) 118end 119 120--- @type table<uint64, LuaEntity> 121local loaders ={} 122for _ , surface in pairs ( game . surfaces ) do 123for _ , loader in pairs ( surface . find_entities_filtered ( { name ="ee-infinity-loader-dummy-combinator" } )) do 124loaders [ loader . unit_number ] =loader 125end 126for _ , chest in pairs ( surface . find_entities_filtered ( { name ="ee-infinity-loader-chest" } )) do 127chest . destroy () 128end 129end 130global . legacy_infinity_loaders =loaders 131end 132 133update_notification . on_nth_tick ={ 134[ 180 ] =function () 135if not global . legacy_infinity_loaders then 136return 137end 138 139for i , legacy in pairs ( global . legacy_infinity_loaders ) do 140if not legacy . valid then 141global . legacy_infinity_loaders [ i ] =nil 142goto continue 143end 144 145for _ , player in pairs ( legacy . force . players ) do 146player . add_custom_alert ( 147legacy , 148{ type ="item" , name ="ee-infinity-loader" } , 149"Remove legacy infinity loader" , 150true 151) 152end 153 154:: continue :: 155end 156 157if not next ( global . legacy_infinity_loaders ) then 158global . legacy_infinity_loaders =nil 159end 160end , 161} 162 163commands . add_command ( "ee-remove-legacy-loaders" , nil , function () 164remove_legacy_loaders () 165end ) 166 167update_notification . events ={ 168[ defines . events . on_built_entity ] =on_entity_built , 169[ defines . events . on_entity_cloned ] =on_entity_built , 170[ defines . events . on_robot_built_entity ] =on_entity_built , 171[ defines . events . script_raised_built ] =on_entity_built , 172[ defines . events . script_raised_revive ] =on_entity_built , 173} 174 175return update_notification