You've already forked ComfyFactorio
							
							
				mirror of
				https://github.com/ComfyFactory/ComfyFactorio.git
				synced 2025-10-30 23:47:41 +02:00 
			
		
		
		
	Fix vanilla error start
This commit is contained in:
		| @@ -21,19 +21,13 @@ local this = { | ||||
|     insert_into_wagon = false, | ||||
|     bottom_button = false, | ||||
|     small_radius = 2, | ||||
|     limit_containers = 50 | ||||
|     limit_containers = 50, | ||||
|     enabled = true | ||||
| } | ||||
|  | ||||
| local Public = { | ||||
|     enable_autostash_module = true | ||||
| } | ||||
|  | ||||
| --- Set the state of the module | ||||
| ---@param state any | ||||
| function Public.set_enable_autostash_module(state) | ||||
|     Public.enable_autostash_module = state | ||||
| end | ||||
|  | ||||
| Global.register( | ||||
|     this, | ||||
|     function (t) | ||||
| @@ -737,6 +731,9 @@ local function create_gui_button(player, bottom_frame_data) | ||||
| end | ||||
|  | ||||
| local function do_whitelist() | ||||
|     if not this.enabled then | ||||
|         return | ||||
|     end | ||||
|     Task.delay(on_init_token, {}) | ||||
|     local resources = game.entity_prototypes | ||||
|     local items = game.item_prototypes | ||||
| @@ -762,6 +759,10 @@ local function do_whitelist() | ||||
| end | ||||
|  | ||||
| local function on_player_joined_game(event) | ||||
|     if not this.enabled then | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     local player = game.get_player(event.player_index) | ||||
|     create_gui_button(player) | ||||
|     if this.bottom_button then | ||||
| @@ -809,28 +810,33 @@ function Public.set_dungeons_initial_level(value) | ||||
|     this.dungeons_initial_level = value | ||||
| end | ||||
|  | ||||
| if Public.enable_autostash_module then | ||||
|     Event.on_configuration_changed(do_whitelist) | ||||
|  | ||||
|     Event.on_init(do_whitelist) | ||||
|     Event.add(defines.events.on_player_joined_game, on_player_joined_game) | ||||
|  | ||||
|     Event.add( | ||||
|         BottomFrame.events.bottom_quickbar_location_changed, | ||||
|         function (event) | ||||
|             local player_index = event.player_index | ||||
|             if not player_index then | ||||
|                 return | ||||
|             end | ||||
|             local player = game.get_player(player_index) | ||||
|             if not player or not player.valid then | ||||
|                 return | ||||
|             end | ||||
|  | ||||
|             local bottom_frame_data = event.data | ||||
|             create_gui_button(player, bottom_frame_data) | ||||
|         end | ||||
|     ) | ||||
| function Public.set_enabled(value) | ||||
|     this.enabled = value or false | ||||
| end | ||||
|  | ||||
| Event.on_configuration_changed(do_whitelist) | ||||
|  | ||||
| Event.on_init(do_whitelist) | ||||
| Event.add(defines.events.on_player_joined_game, on_player_joined_game) | ||||
|  | ||||
| Event.add( | ||||
|     BottomFrame.events.bottom_quickbar_location_changed, | ||||
|     function (event) | ||||
|         if not this.enabled then | ||||
|             return | ||||
|         end | ||||
|         local player_index = event.player_index | ||||
|         if not player_index then | ||||
|             return | ||||
|         end | ||||
|         local player = game.get_player(player_index) | ||||
|         if not player or not player.valid then | ||||
|             return | ||||
|         end | ||||
|  | ||||
|         local bottom_frame_data = event.data | ||||
|         create_gui_button(player, bottom_frame_data) | ||||
|     end | ||||
| ) | ||||
|  | ||||
| return Public | ||||
|   | ||||
| @@ -12,6 +12,7 @@ local Discord = require 'utils.discord_handler' | ||||
| local Commands = require 'utils.commands' | ||||
|  | ||||
| local this = { | ||||
|     enabled = false, | ||||
|     players = {}, | ||||
|     bottom_button = false | ||||
| } | ||||
| @@ -24,13 +25,8 @@ Global.register( | ||||
| ) | ||||
|  | ||||
| local Public = { | ||||
|     enable_clear_corpse_button = true | ||||
| } | ||||
|  | ||||
| function Public.set_enable_clear_corpse_button(value) | ||||
|     Public.enable_clear_corpse_button = value or false | ||||
| end | ||||
|  | ||||
| local clear_corpse_button_name = Gui.uid_name() | ||||
|  | ||||
| Commands.new('playtime', 'Fetches a player total playtime or nil.') | ||||
| @@ -507,24 +503,29 @@ function Public.bottom_button(value) | ||||
|     this.bottom_button = value or false | ||||
| end | ||||
|  | ||||
| if Public.enable_clear_corpse_button then | ||||
|     Event.add( | ||||
|         defines.events.on_player_joined_game, | ||||
|         function (event) | ||||
|             local player = game.players[event.player_index] | ||||
|             on_player_joined_game(player) | ||||
|             create_clear_corpse_frame(player) | ||||
|  | ||||
|             if this.bottom_button then | ||||
|                 BottomFrame.add_inner_frame({ player = player, element_name = clear_corpse_button_name, tooltip = { 'commands.clear_corpse' }, sprite = 'entity/behemoth-biter' }) | ||||
|             end | ||||
| Event.add( | ||||
|     defines.events.on_player_joined_game, | ||||
|     function (event) | ||||
|         if not this.enabled then | ||||
|             return | ||||
|         end | ||||
|     ) | ||||
| end | ||||
|  | ||||
|         local player = game.players[event.player_index] | ||||
|         on_player_joined_game(player) | ||||
|         create_clear_corpse_frame(player) | ||||
|  | ||||
|         if this.bottom_button then | ||||
|             BottomFrame.add_inner_frame({ player = player, element_name = clear_corpse_button_name, tooltip = { 'commands.clear_corpse' }, sprite = 'entity/behemoth-biter' }) | ||||
|         end | ||||
|     end | ||||
| ) | ||||
|  | ||||
| Gui.on_click( | ||||
|     clear_corpse_button_name, | ||||
|     function (event) | ||||
|         if not this.enabled then | ||||
|             return | ||||
|         end | ||||
|         local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Clear Corpse') | ||||
|         if is_spamming then | ||||
|             return | ||||
| @@ -536,6 +537,9 @@ Gui.on_click( | ||||
| Event.add( | ||||
|     BottomFrame.events.bottom_quickbar_location_changed, | ||||
|     function (event) | ||||
|         if not this.enabled then | ||||
|             return | ||||
|         end | ||||
|         local player_index = event.player_index | ||||
|         if not player_index then | ||||
|             return | ||||
| @@ -550,6 +554,10 @@ Event.add( | ||||
|     end | ||||
| ) | ||||
|  | ||||
| function Public.set_enabled(value) | ||||
|     this.enabled = value or false | ||||
| end | ||||
|  | ||||
| Public.clear_corpses = clear_corpses | ||||
|  | ||||
| return Public | ||||
|   | ||||
| @@ -8,7 +8,7 @@ local Public = {} | ||||
| local this = { | ||||
|     created_items = {}, | ||||
|     respawn_items = {}, | ||||
|     disabled = true, | ||||
|     enabled = true, | ||||
|     skip_intro = true, | ||||
|     chart_distance = 0, | ||||
|     disable_crashsite = false, | ||||
| @@ -111,7 +111,7 @@ local on_player_joined_game = function (event) | ||||
| end | ||||
|  | ||||
| local on_player_created = function (event) | ||||
|     if this.disabled then | ||||
|     if this.enabled then | ||||
|         return | ||||
|     end | ||||
|  | ||||
| @@ -148,7 +148,7 @@ local on_player_created = function (event) | ||||
| end | ||||
|  | ||||
| local on_player_respawned = function (event) | ||||
|     if this.disabled then | ||||
|     if this.enabled then | ||||
|         return | ||||
|     end | ||||
|     local player = game.players[event.player_index] | ||||
| @@ -156,7 +156,7 @@ local on_player_respawned = function (event) | ||||
| end | ||||
|  | ||||
| local on_cutscene_waypoint_reached = function (event) | ||||
|     if this.disabled then | ||||
|     if this.enabled then | ||||
|         return | ||||
|     end | ||||
|     if not crash_site.is_crash_site_cutscene(event) then | ||||
| @@ -181,7 +181,7 @@ local on_cutscene_waypoint_reached = function (event) | ||||
| end | ||||
|  | ||||
| local skip_crash_site_cutscene = function (event) | ||||
|     if this.disabled then | ||||
|     if this.enabled then | ||||
|         return | ||||
|     end | ||||
|  | ||||
| @@ -210,7 +210,7 @@ local skip_crash_site_cutscene = function (event) | ||||
| end | ||||
|  | ||||
| local on_cutscene_cancelled = function (event) | ||||
|     if this.disabled then | ||||
|     if this.enabled then | ||||
|         return | ||||
|     end | ||||
|  | ||||
| @@ -253,7 +253,7 @@ local freeplay_interface = { | ||||
|         this.skip_intro = bool | ||||
|     end, | ||||
|     set_disabled = function (bool) | ||||
|         this.disabled = bool | ||||
|         this.enabled = bool | ||||
|     end, | ||||
|     set_custom_surface_name = function (str) | ||||
|         this.custom_surface_name = str or error('Remote call parameter to freeplay set custom_surface_name must be string') | ||||
| @@ -335,4 +335,8 @@ Event.add(defines.events.on_cutscene_waypoint_reached, on_cutscene_waypoint_reac | ||||
| Event.add('crash-site-skip-cutscene', skip_crash_site_cutscene) | ||||
| Event.add(defines.events.on_cutscene_cancelled, on_cutscene_cancelled) | ||||
|  | ||||
| function Public.set_enabled(value) | ||||
|     this.enabled = value or false | ||||
| end | ||||
|  | ||||
| return Public | ||||
|   | ||||
| @@ -1,12 +1,17 @@ | ||||
| require 'utils.start' | ||||
| require 'utils.freeplay'.set('disabled', false) | ||||
|  | ||||
| require 'modules.autostash'.set_enable_autostash_module(false) | ||||
| require 'utils.commands.misc'.set_enable_clear_corpse_button(false) | ||||
|  | ||||
| local Freeplay = require 'utils.freeplay' | ||||
| local Autostash = require 'modules.autostash' | ||||
| local Misc = require 'utils.commands.misc' | ||||
| local Gui = require 'utils.gui' | ||||
| local Event = require 'utils.event' | ||||
|  | ||||
| Gui.mod_gui_button_enabled = true | ||||
| Gui.button_style = 'mod_gui_button' | ||||
| Gui.set_toggle_button(true) | ||||
| Gui.set_mod_gui_top_frame(true) | ||||
|  | ||||
| Event.on_init(function () | ||||
| 	Freeplay.set_enabled(false) | ||||
| 	Autostash.set_enabled(false) | ||||
| 	Misc.set_enabled(false) | ||||
| end) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user