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