You've already forked ComfyFactorio
							
							
				mirror of
				https://github.com/ComfyFactory/ComfyFactorio.git
				synced 2025-10-30 23:47:41 +02:00 
			
		
		
		
	Feat: remove compilatron and rename group_number -> unique_id
This commit is contained in:
		| @@ -7,7 +7,6 @@ mana_casting_too_fast=There was a lot more to magic, as __1__ quickly found out, | ||||
| low_level=You lack the level to cast this spell. | ||||
| not_inside_pos=You wave your wand but realize that it´s out of reach. | ||||
| no_mana=You don´t have enough mana to cast this spell. | ||||
| suicidal_comfylatron=You wave your wand and __1__ is on the run! | ||||
| detonate_chest=You wave your wand and chesty makes big BOOM! | ||||
| detonate_chest_failed=You wave your wand but no not enough explosives were found inside the chest! | ||||
| repair_aoe=You wave your wand and repaired __1__ entities! | ||||
|   | ||||
| @@ -7,7 +7,6 @@ mana_casting_too_fast=Как быстро выяснил __1__, в магии б | ||||
| low_level=Вам не хватает уровня для произнесения этого заклинания. | ||||
| not_inside_pos=Вы машете палочкой, но понимаете, что это вне досягаемости. | ||||
| no_mana=У вас недостаточно маны для сотворения этого заклинания. | ||||
| suicidal_comfylatron=Вы машете палочкой, и __1__ в бегах! | ||||
| detonate_chest=Вы взмахиваете палочкой, и сундук делает большой БУМ! | ||||
| detonate_chest_failed=Вы взмахиваете палочкой, но внутри сундука не было обнаружено достаточно взрывчатки! | ||||
| repair_aoe=Вы взмахнули палочкой и починили __1__ сущностей! | ||||
|   | ||||
| @@ -7,7 +7,6 @@ mana_casting_too_fast= __1__ 魔法还有很多, 像 __2__ 迅速创建出, 然 | ||||
| low_level=等级不够. | ||||
| not_inside_pos=你挥动你的魔杖, 但意识到它不能达到. | ||||
| no_mana=你没有足够的魔力. | ||||
| suicidal_comfylatron=您挥舞着魔杖,__1__在运行! | ||||
| warped_ok=回城给自己造成了一些伤害. | ||||
| object_spawned= 正在施法!.\n 你挥动你的魔杖和 __1__ 出现. | ||||
| out_of_reach=无法在给指定位置创建物体. | ||||
|   | ||||
| @@ -433,7 +433,7 @@ local function create_attack_group(surface, force_name, biter_force_name) | ||||
|  | ||||
|     send_group(unit_group, force_name, side_target) | ||||
|  | ||||
|     storage.unit_groups[unit_group.group_number] = unit_group | ||||
|     storage.unit_groups[unit_groupunique_id] = unit_group | ||||
| end | ||||
|  | ||||
| Public.pre_main_attack = function () | ||||
|   | ||||
| @@ -486,24 +486,6 @@ Public.mining_events = { | ||||
|         128, | ||||
|         'Worms' | ||||
|     }, | ||||
|     { | ||||
|         function (cave_miner, entity, player_index) | ||||
|             local position = entity.position | ||||
|             local surface = entity.surface | ||||
|             surface.create_entity({ name = 'compilatron', position = position, force = 'player' }) | ||||
|         end, | ||||
|         64, | ||||
|         'Friendly Compilatron' | ||||
|     }, | ||||
|     { | ||||
|         function (cave_miner, entity, player_index) | ||||
|             local position = entity.position | ||||
|             local surface = entity.surface | ||||
|             surface.create_entity({ name = 'compilatron', position = position, force = 'enemy' }) | ||||
|         end, | ||||
|         128, | ||||
|         'Enemy Compilatron' | ||||
|     }, | ||||
|     { | ||||
|         function (cave_miner, entity, player_index) | ||||
|             local position = entity.position | ||||
|   | ||||
| @@ -718,8 +718,8 @@ local biter_attack_wave = function () | ||||
|             unit_groups[i] = surface.create_unit_group({ position = { x = x_raffle[i], y = y_raffle[i] } }) | ||||
|             local unit_group = unit_groups[i] | ||||
|             if unit_group and unit_group.valid then | ||||
|                 if not this.unit_groups[unit_group.group_number] then | ||||
|                     this.unit_groups[unit_group.group_number] = unit_group | ||||
|                 if not this.unit_groups[unit_groupunique_id] then | ||||
|                     this.unit_groups[unit_groupunique_id] = unit_group | ||||
|                 end | ||||
|                 Task.set_timeout_in_ticks(i, spawn_biters_token, { attack_wave_threat = this.attack_wave_threat, unit_group = unit_group, surface = surface, biter_pool = biter_pool }) | ||||
|             end | ||||
| @@ -729,8 +729,8 @@ local biter_attack_wave = function () | ||||
|             unit_groups[i] = surface.create_unit_group({ position = { x = x_raffle[i], y = y_raffle[i] } }) | ||||
|             local unit_group = unit_groups[i] | ||||
|             if unit_group and unit_group.valid then | ||||
|                 if not this.unit_groups[unit_group.group_number] then | ||||
|                     this.unit_groups[unit_group.group_number] = unit_group | ||||
|                 if not this.unit_groups[unit_groupunique_id] then | ||||
|                     this.unit_groups[unit_groupunique_id] = unit_group | ||||
|                 end | ||||
|                 Task.set_timeout_in_ticks(i, spawn_biters_token, { attack_wave_threat = this.attack_wave_threat, unit_group = unit_group, surface = surface, biter_pool = biter_pool }) | ||||
|             end | ||||
|   | ||||
| @@ -729,10 +729,11 @@ function Public.draw_mothership(journey) | ||||
|         protect(chest, false) | ||||
|     end | ||||
|  | ||||
|     for _ = 1, 3, 1 do | ||||
|         local comp = surface.create_entity({ name = 'compilatron', position = Constants.mothership_teleporter_position, force = 'player' }) | ||||
|         comp.destructible = false | ||||
|     end | ||||
|     -- removed for 1.2/2.0 | ||||
|     -- for _ = 1, 3, 1 do | ||||
|     --     local comp = surface.create_entity({ name = 'compilatron', position = Constants.mothership_teleporter_position, force = 'player' }) | ||||
|     --     comp.destructible = false | ||||
|     -- end | ||||
|     Public.draw_gui(journey) | ||||
|     surface.daytime = 0.5 | ||||
|  | ||||
|   | ||||
| @@ -141,14 +141,10 @@ local scrap_entities = { | ||||
|     'crash-site-assembling-machine-1-broken', | ||||
|     'crash-site-assembling-machine-2-broken', | ||||
|     'crash-site-lab-broken', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'crash-site-spaceship-wreck-medium-1', | ||||
|     'crash-site-spaceship-wreck-medium-1', | ||||
|     'crash-site-spaceship-wreck-medium-2', | ||||
|     'crash-site-spaceship-wreck-medium-2', | ||||
|     'crash-site-chest-1', | ||||
|     'crash-site-chest-2', | ||||
|     'crash-site-chest-1', | ||||
|   | ||||
| @@ -240,15 +240,10 @@ local scrap_entities = { | ||||
|     'crash-site-assembling-machine-2-broken', | ||||
|     'crash-site-assembling-machine-1-broken', | ||||
|     'crash-site-assembling-machine-2-broken', | ||||
|     'crash-site-lab-broken', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'crash-site-spaceship-wreck-medium-1', | ||||
|     'crash-site-spaceship-wreck-medium-1', | ||||
|     'crash-site-spaceship-wreck-medium-1', | ||||
|     'crash-site-spaceship-wreck-medium-1', | ||||
|     'crash-site-chest-1', | ||||
|     'crash-site-chest-2', | ||||
|     'crash-site-chest-1', | ||||
|   | ||||
| @@ -139,7 +139,7 @@ local function on_entity_died(event) | ||||
|         end | ||||
|         if not Public.get('final_battle') then | ||||
|             if entities_that_earn_coins[cause.name] then | ||||
|                 event.entity.surface.spill_item_stack(cause.position, { name = 'coin', count = coin_count }, true) | ||||
|                 event.entity.surface.spill_item_stack({ position = cause.position, stack = { name = 'coin', count = coin_count }, enable_looted = true }) | ||||
|                 reward_has_been_given = true | ||||
|             end | ||||
|         end | ||||
| @@ -150,7 +150,7 @@ local function on_entity_died(event) | ||||
|     end | ||||
|  | ||||
|     if reward_has_been_given == false then | ||||
|         event.entity.surface.spill_item_stack(event.entity.position, { name = 'coin', count = coin_count }, true) | ||||
|         event.entity.surface.spill_item_stack({ position = event.entity.position, stack = { name = 'coin', count = coin_count }, enable_looted = true }) | ||||
|     end | ||||
| end | ||||
|  | ||||
|   | ||||
| @@ -126,6 +126,7 @@ Commands.new('mtn_reverse_map', 'Usable only for admins - reverses the map!') | ||||
|             Public.set_stateful_settings('reversed', not reversed) | ||||
|             Discord.send_notification_raw(scenario_name, player.name .. ' reversed the map.') | ||||
|             Public.reset_map() | ||||
|             log(serpent.block('resetting map')) | ||||
|             game.print(mapkeeper .. player.name .. ', has reverse the map and reset the game!', | ||||
|                 { r = 0.98, g = 0.66, b = 0.22 }) | ||||
|             player.print('Map reversed.') | ||||
|   | ||||
| @@ -38,12 +38,12 @@ local function get_position(data) | ||||
|         data.xv = data.xv + 1 | ||||
|     end | ||||
|  | ||||
|     data.position = {x = (data.top_x + data.xv), y = (data.top_y + data.yv)} | ||||
|     data.position = { x = (data.top_x + data.xv), y = (data.top_y + data.yv) } | ||||
| end | ||||
|  | ||||
| local function do_tile_inner(tiles, tile, pos) | ||||
|     if type(tile) == 'string' then | ||||
|         tiles[#tiles + 1] = {name = tile, position = pos} | ||||
|         tiles[#tiles + 1] = { name = tile, position = pos } | ||||
|     end | ||||
| end | ||||
|  | ||||
| @@ -56,7 +56,7 @@ local function do_row(row, data, shape) | ||||
|  | ||||
|     for x = top_x, top_x + 31 do | ||||
|         data.x = x | ||||
|         local pos = {data.x, data.y} | ||||
|         local pos = { data.x, data.y } | ||||
|  | ||||
|         get_position(data) | ||||
|  | ||||
| @@ -68,7 +68,7 @@ local function do_row(row, data, shape) | ||||
|  | ||||
|             local hidden_tile = tile.hidden_tile | ||||
|             if hidden_tile then | ||||
|                 data.hidden_tiles[#data.hidden_tiles + 1] = {tile = hidden_tile, position = pos} | ||||
|                 data.hidden_tiles[#data.hidden_tiles + 1] = { tile = hidden_tile, position = pos } | ||||
|             end | ||||
|  | ||||
|             local entities = tile.entities | ||||
| @@ -143,11 +143,11 @@ local function do_place_treasure(data) | ||||
|         end | ||||
|         if | ||||
|             surface.count_entities_filtered { | ||||
|                 area = {{e.position.x - 2, e.position.y - 2}, {e.position.x + 2, e.position.y + 2}}, | ||||
|                 area = { { e.position.x - 2, e.position.y - 2 }, { e.position.x + 2, e.position.y + 2 } }, | ||||
|                 name = 'market', | ||||
|                 limit = 1 | ||||
|             } == 0 | ||||
|          then | ||||
|         then | ||||
|             Public.add_loot(surface, e.position, e.chest) | ||||
|         else | ||||
|             Public.add_loot(surface, e.position, e.chest, true) | ||||
| @@ -169,11 +169,11 @@ local function do_place_markets(data) | ||||
|     local pos = markets[random(1, #markets)] | ||||
|     if | ||||
|         surface.count_entities_filtered { | ||||
|             area = {{pos.x - 96, pos.y - 96}, {pos.x + 96, pos.y + 96}}, | ||||
|             area = { { pos.x - 96, pos.y - 96 }, { pos.x + 96, pos.y + 96 } }, | ||||
|             name = 'market', | ||||
|             limit = 1 | ||||
|         } == 0 | ||||
|      then | ||||
|     then | ||||
|         local market = Public.mountain_market(surface, pos, abs(pos.y) * 0.004) | ||||
|         market.destructible = false | ||||
|     end | ||||
| @@ -202,12 +202,12 @@ local function do_place_decoratives(data) | ||||
|         return | ||||
|     end | ||||
|     if regen_decoratives then | ||||
|         surface.regenerate_decorative(nil, {{data.top_x / 32, data.top_y / 32}}) | ||||
|         surface.regenerate_decorative(nil, { { data.top_x / 32, data.top_y / 32 } }) | ||||
|     end | ||||
|  | ||||
|     local dec = data.decoratives | ||||
|     if #dec > 0 then | ||||
|         surface.create_decoratives({check_collision = true, decoratives = dec}) | ||||
|         surface.create_decoratives({ check_collision = true, decoratives = dec }) | ||||
|     end | ||||
| end | ||||
|  | ||||
| @@ -223,11 +223,11 @@ local function do_place_buildings(data) | ||||
|             local p = e.position | ||||
|             if | ||||
|                 surface.count_entities_filtered { | ||||
|                     area = {{p.x - 32, p.y - 32}, {p.x + 32, p.y + 32}}, | ||||
|                     area = { { p.x - 32, p.y - 32 }, { p.x + 32, p.y + 32 } }, | ||||
|                     type = e.e_type, | ||||
|                     limit = 1 | ||||
|                 } == 0 | ||||
|              then | ||||
|             then | ||||
|                 e.create_build_effect_smoke = false | ||||
|                 entity = surface.create_entity(e) | ||||
|                 if entity and entity.valid then | ||||
| @@ -240,7 +240,7 @@ local function do_place_buildings(data) | ||||
|                     if e.callback then | ||||
|                         local c = e.callback.callback | ||||
|                         if c then | ||||
|                             local d = {callback_data = e.callback.data} | ||||
|                             local d = { callback_data = e.callback.data } | ||||
|                             if not d then | ||||
|                                 callback = Task.get(c) | ||||
|                                 callback(entity) | ||||
| @@ -260,7 +260,7 @@ local function wintery(ent, extra_lights) | ||||
|     if not winter_mode then | ||||
|         return false | ||||
|     end | ||||
|     local colors = {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}} | ||||
|     local colors = { { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 } } | ||||
|     local function add_light(e) | ||||
|         local color = colors[math.random(1, 3)] | ||||
|         local scale = extra_lights or 1 | ||||
| @@ -274,7 +274,7 @@ local function wintery(ent, extra_lights) | ||||
|                 oriented = false, | ||||
|                 color = color, | ||||
|                 target = e, | ||||
|                 target_offset = {0, -0.5}, | ||||
|                 target_offset = { 0, -0.5 }, | ||||
|                 surface = e.surface | ||||
|             } | ||||
|         ) | ||||
| @@ -332,7 +332,7 @@ local function do_place_entities(data) | ||||
|                         if not c then | ||||
|                             return | ||||
|                         end | ||||
|                         local d = {callback_data = e.callback.data} | ||||
|                         local d = { callback_data = e.callback.data } | ||||
|                         if not d then | ||||
|                             callback = Task.get(c) | ||||
|                             callback(entity) | ||||
| @@ -369,7 +369,7 @@ local function do_place_entities(data) | ||||
|                 if e.callback then | ||||
|                     local c = e.callback.callback | ||||
|                     if c then | ||||
|                         local d = {callback_data = e.callback.data} | ||||
|                         local d = { callback_data = e.callback.data } | ||||
|                         if not d then | ||||
|                             callback = Task.get(c) | ||||
|                             callback(entity) | ||||
| @@ -391,13 +391,13 @@ local function run_chart_update(data) | ||||
|     if not surface or not surface.valid then | ||||
|         return | ||||
|     end | ||||
|     if game.forces.player.is_chunk_charted(surface, {x, y}) then | ||||
|     if game.forces.player.is_chunk_charted(surface, { x, y }) then | ||||
|         -- Don't use full area, otherwise adjacent chunks get charted | ||||
|         game.forces.player.chart( | ||||
|             surface, | ||||
|             { | ||||
|                 {data.top_x, data.top_y}, | ||||
|                 {data.top_x + 1, data.top_y + 1} | ||||
|                 { data.top_x,     data.top_y }, | ||||
|                 { data.top_x + 1, data.top_y + 1 } | ||||
|             } | ||||
|         ) | ||||
|     end | ||||
|   | ||||
| @@ -494,6 +494,9 @@ local function validate_index() | ||||
|  | ||||
|     local icw_table = ICW.get_table() | ||||
|     local icw_locomotive = Public.get('icw_locomotive') | ||||
|     if not icw_locomotive or not icw_locomotive.valid then | ||||
|         return | ||||
|     end | ||||
|     local loco_surface = icw_locomotive.surface | ||||
|     local unit_surface = locomotive.unit_number | ||||
|     local locomotive_surface = game.surfaces[icw_table.wagons[unit_surface].surface.index] | ||||
| @@ -834,6 +837,9 @@ function Public.transfer_pollution() | ||||
|     end | ||||
|  | ||||
|     local icw_locomotive = Public.get('icw_locomotive') | ||||
|     if not icw_locomotive or not icw_locomotive.valid then | ||||
|         return | ||||
|     end | ||||
|     local surface = icw_locomotive.surface | ||||
|     if not surface or not surface.valid then | ||||
|         return | ||||
|   | ||||
| @@ -302,6 +302,8 @@ function Public.reset_map() | ||||
|     end | ||||
|  | ||||
|     game.speed = 1 | ||||
|     surface.destroy_decoratives({ name = "brown-cup", invert = true }) | ||||
|     surface.destroy_decoratives({ name = "small-sand-rock", invert = true }) | ||||
|  | ||||
|     Task.set_queue_speed(16) | ||||
|  | ||||
|   | ||||
| @@ -10,7 +10,7 @@ local this = { | ||||
|  | ||||
| Global.register( | ||||
|     this, | ||||
|     function(tbl) | ||||
|     function (tbl) | ||||
|         this = tbl | ||||
|     end | ||||
| ) | ||||
| @@ -21,22 +21,22 @@ function Public.create_surface() | ||||
|         ['width'] = zone_settings.zone_width, | ||||
|         ['water'] = 0.001, | ||||
|         ['starting_area'] = 1, | ||||
|         ['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, | ||||
|         ['cliff_settings'] = { cliff_elevation_interval = 0, cliff_elevation_0 = 0 }, | ||||
|         ['default_enable_all_autoplace_controls'] = true, | ||||
|         ['autoplace_settings'] = { | ||||
|             ['entity'] = {treat_missing_as_default = false}, | ||||
|             ['entity'] = { treat_missing_as_default = false }, | ||||
|             ['tile'] = { | ||||
|                 settings = { | ||||
|                     ['deepwater'] = {frequency = 1, size = 0, richness = 1}, | ||||
|                     ['deepwater-green'] = {frequency = 1, size = 0, richness = 1}, | ||||
|                     ['water'] = {frequency = 1, size = 0, richness = 1}, | ||||
|                     ['water-green'] = {frequency = 1, size = 0, richness = 1}, | ||||
|                     ['water-mud'] = {frequency = 1, size = 0, richness = 1}, | ||||
|                     ['water-shallow'] = {frequency = 1, size = 0, richness = 1} | ||||
|                     ['deepwater'] = { frequency = 1, size = 0, richness = 1 }, | ||||
|                     ['deepwater-green'] = { frequency = 1, size = 0, richness = 1 }, | ||||
|                     ['water'] = { frequency = 1, size = 0, richness = 1 }, | ||||
|                     ['water-green'] = { frequency = 1, size = 0, richness = 1 }, | ||||
|                     ['water-mud'] = { frequency = 1, size = 0, richness = 1 }, | ||||
|                     ['water-shallow'] = { frequency = 1, size = 0, richness = 1 } | ||||
|                 }, | ||||
|                 treat_missing_as_default = true | ||||
|             }, | ||||
|             ['decorative'] = {treat_missing_as_default = true} | ||||
|             ['decorative'] = { treat_missing_as_default = false } | ||||
|         }, | ||||
|         property_expression_names = { | ||||
|             cliffiness = 0, | ||||
|   | ||||
| @@ -71,14 +71,14 @@ local tree_raffle = { | ||||
| local size_of_tree_raffle = #tree_raffle | ||||
|  | ||||
| local scrap_entities = { | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck' | ||||
|     'crash-site-spaceship-wreck-small-1', | ||||
|     'crash-site-spaceship-wreck-small-6', | ||||
|     'crash-site-spaceship-wreck-small-1', | ||||
|     'crash-site-spaceship-wreck-small-6', | ||||
|     'crash-site-spaceship-wreck-small-1', | ||||
|     'crash-site-spaceship-wreck-small-6', | ||||
|     'crash-site-spaceship-wreck-small-1', | ||||
|     'crash-site-spaceship-wreck-small-6' | ||||
| } | ||||
|  | ||||
| local scrap_entities_index = #scrap_entities | ||||
| @@ -2814,6 +2814,18 @@ local function border_chunk(p, data) | ||||
|     local tiles = data.tiles | ||||
|     local surface = data.surface | ||||
|  | ||||
|     local game_decoratives = prototypes.decorative | ||||
|     local dec_tbl = {} | ||||
|     local taken = 0 | ||||
|  | ||||
|     for _, decorative in pairs(game_decoratives) do | ||||
|         taken = taken + 1 | ||||
|         dec_tbl[#dec_tbl + 1] = decorative.name | ||||
|         if taken > 4 then | ||||
|             break | ||||
|         end | ||||
|     end | ||||
|  | ||||
|     local pos = p | ||||
|  | ||||
|     if data.reversed then | ||||
| @@ -2850,26 +2862,15 @@ local function border_chunk(p, data) | ||||
|             } | ||||
|         end | ||||
|  | ||||
|         if random(1, abs(pos.y) + 3) == 1 then | ||||
|             decoratives[#decoratives + 1] = { | ||||
|                 name = 'small-rock', | ||||
|                 position = pos, | ||||
|                 amount = random(1, 32) | ||||
|             } | ||||
|         end | ||||
|         if random(1, abs(pos.y) + 2) == 1 then | ||||
|             decoratives[#decoratives + 1] = { | ||||
|                 name = 'tiny-rock', | ||||
|                 position = pos, | ||||
|                 amount = random(1, 32) | ||||
|             } | ||||
|         end | ||||
|         if random(1, abs(pos.y) + 1) == 1 then | ||||
|             decoratives[#decoratives + 1] = { | ||||
|                 name = 'tiny-rock-cluster', | ||||
|                 position = pos, | ||||
|                 amount = random(1, 32) | ||||
|             } | ||||
|  | ||||
|         for _, decorative in pairs(dec_tbl) do | ||||
|             if random(1, abs(pos.y) + 3) == 1 then | ||||
|                 decoratives[#decoratives + 1] = { | ||||
|                     name = decorative, | ||||
|                     position = pos, | ||||
|                     amount = random(1, 32) | ||||
|                 } | ||||
|             end | ||||
|         end | ||||
|     end | ||||
| end | ||||
|   | ||||
| @@ -70,8 +70,8 @@ function Public.fleeing_biteys(entity, cause) | ||||
|         local unit_group = unit.unit_group | ||||
|         if unit_group then | ||||
|             if unit_group.valid then | ||||
|                 if not unit_groups[unit_group.group_number] then | ||||
|                     unit_groups[unit_group.group_number] = unit_group | ||||
|                 if not unit_groups[unit_groupunique_id] then | ||||
|                     unit_groups[unit_groupunique_id] = unit_group | ||||
|                 end | ||||
|             end | ||||
|         else | ||||
|   | ||||
| @@ -21,8 +21,6 @@ local pollution_index = { | ||||
|     ['biter-spawner'] = {min = 0.5, max = 2.5}, | ||||
|     ['spitter-spawner'] = {min = 0.5, max = 2.5}, | ||||
|     ['mineable-wreckage'] = {min = 0.1, max = 0.1}, | ||||
|     ['small-ship-wreck'] = {min = 0.1, max = 0.1}, | ||||
|     ['medium-ship-wreck'] = {min = 0.1, max = 0.1}, | ||||
|     ['crash-site-spaceship-wreck-small-1'] = {min = 0.1, max = 0.1}, | ||||
|     ['crash-site-spaceship-wreck-small-2'] = {min = 0.1, max = 0.1}, | ||||
|     ['crash-site-spaceship-wreck-small-3'] = {min = 0.1, max = 0.1}, | ||||
|   | ||||
| @@ -1,10 +1,6 @@ | ||||
| local Public = {} | ||||
|  | ||||
| local scrapable = { | ||||
|     -- simple entity | ||||
|     ['small-ship-wreck'] = true, | ||||
|     ['medium-ship-wreck'] = true, | ||||
|     -- simple entity with owner | ||||
|     ['crash-site-spaceship-wreck-small-1'] = true, | ||||
|     ['crash-site-spaceship-wreck-small-2'] = true, | ||||
|     ['crash-site-spaceship-wreck-small-3'] = true, | ||||
|   | ||||
| @@ -59,7 +59,7 @@ function get_ammo() | ||||
|     end | ||||
| end | ||||
|  | ||||
| local special_scraps = { 'crash-site-assembling-machine-1-broken', 'crash-site-assembling-machine-2-broken', 'crash-site-lab-broken', 'medium-ship-wreck' } | ||||
| local special_scraps = { 'crash-site-assembling-machine-1-broken', 'crash-site-assembling-machine-2-broken', 'crash-site-lab-broken' } | ||||
| function get_scrap() | ||||
|     if math.random(1, 128) == 1 then | ||||
|         return special_scraps[math.random(1, 4)] | ||||
|   | ||||
| @@ -694,7 +694,7 @@ end | ||||
|  | ||||
| local function on_unit_group_created(event) | ||||
|     if event and event.group and event.group.valid then | ||||
|         storage.biter_command.active_unit_groups[event.group.group_number] = { id = event.group.group_number, group = event.group } | ||||
|         storage.biter_command.active_unit_groups[event.groupunique_id] = { id = event.groupunique_id, group = event.group } | ||||
|         refresh_panel() | ||||
|     end | ||||
| end | ||||
| @@ -702,7 +702,7 @@ end | ||||
| local function on_unit_removed_from_group(event) | ||||
|     if event and event.group and event.group.valid then | ||||
|         if #event.group.members == 1 then | ||||
|             storage.biter_command.active_unit_groups[event.group.group_number] = nil | ||||
|             storage.biter_command.active_unit_groups[event.groupunique_id] = nil | ||||
|             refresh_panel() | ||||
|         end | ||||
|     end | ||||
|   | ||||
| @@ -33,18 +33,6 @@ local main_frame_name = Public.main_frame_name | ||||
| local spell_gui_frame_name = Public.spell_gui_frame_name | ||||
| local cooldown_indicator_name = Public.cooldown_indicator_name | ||||
|  | ||||
| local travelings = { | ||||
|     'bzzZZrrt', | ||||
|     'WEEEeeeeeee', | ||||
|     'out of my way son', | ||||
|     'on my way', | ||||
|     'i need to leave', | ||||
|     'comfylatron seeking target', | ||||
|     'gotta go fast', | ||||
|     'gas gas gas', | ||||
|     'comfylatron coming through' | ||||
| } | ||||
|  | ||||
| local restore_crafting_boost_token = | ||||
|     Token.register( | ||||
|         function (event) | ||||
| @@ -58,34 +46,6 @@ local restore_crafting_boost_token = | ||||
|         end | ||||
|     ) | ||||
|  | ||||
| local desync = | ||||
|     Token.register( | ||||
|         function (data) | ||||
|             local entity = data.entity | ||||
|             if not entity or not entity.valid then | ||||
|                 return | ||||
|             end | ||||
|             local surface = data.surface | ||||
|             local fake_shooter = surface.create_entity({ name = 'character', position = entity.position, force = 'enemy' }) | ||||
|             for _ = 1, 3 do | ||||
|                 surface.create_entity( | ||||
|                     { | ||||
|                         name = 'explosive-rocket', | ||||
|                         position = entity.position, | ||||
|                         force = 'enemy', | ||||
|                         speed = 1, | ||||
|                         max_range = 1, | ||||
|                         target = entity, | ||||
|                         source = fake_shooter | ||||
|                     } | ||||
|                 ) | ||||
|             end | ||||
|             if fake_shooter and fake_shooter.valid then | ||||
|                 fake_shooter.destroy() | ||||
|             end | ||||
|         end | ||||
|     ) | ||||
|  | ||||
| local function create_healthbar(player, size) | ||||
|     return rendering.draw_sprite( | ||||
|         { | ||||
| @@ -322,58 +282,6 @@ function Public.repair_aoe(player, position) | ||||
|     return count | ||||
| end | ||||
|  | ||||
| function Public.suicidal_comfylatron(pos, surface) | ||||
|     local str = travelings[random(1, #travelings)] | ||||
|     local symbols = { '', '!', '!', '!!', '..' } | ||||
|     str = str .. symbols[random(1, #symbols)] | ||||
|     local text = str | ||||
|     local e = | ||||
|         surface.create_entity( | ||||
|             { | ||||
|                 name = 'compilatron', | ||||
|                 position = { x = pos.x, y = pos.y + 2 }, | ||||
|                 force = 'neutral' | ||||
|             } | ||||
|         ) | ||||
|     surface.create_entity( | ||||
|         { | ||||
|             name = 'compi-speech-bubble', | ||||
|             position = e.position, | ||||
|             source = e, | ||||
|             text = text, | ||||
|             lifetime = 30 | ||||
|         } | ||||
|     ) | ||||
|     local nearest_player_unit = surface.find_nearest_enemy({ position = e.position, max_distance = 512, force = 'player' }) | ||||
|  | ||||
|     if nearest_player_unit and nearest_player_unit.active and nearest_player_unit.force.name ~= 'player' then | ||||
|         e.set_command( | ||||
|             { | ||||
|                 type = defines.command.attack, | ||||
|                 target = nearest_player_unit, | ||||
|                 distraction = defines.distraction.none | ||||
|             } | ||||
|         ) | ||||
|         local data = { | ||||
|             entity = e, | ||||
|             surface = surface | ||||
|         } | ||||
|         Task.set_timeout_in_ticks(600, desync, data) | ||||
|     else | ||||
|         e.surface.create_entity({ name = 'medium-explosion', position = e.position }) | ||||
|         e.surface.create_entity( | ||||
|             { | ||||
|                 name = 'compi-speech-bubble', | ||||
|                 position = e.position, | ||||
|                 text = 'DeSyyNC - no target found!', | ||||
|                 source = e, | ||||
|                 lifetime = 30 | ||||
|             } | ||||
|         ) | ||||
|         e.die() | ||||
|     end | ||||
| end | ||||
|  | ||||
| function Public.validate_player(player) | ||||
|     if not player then | ||||
|         return false | ||||
|   | ||||
| @@ -1022,37 +1022,6 @@ spells[#spells + 1] = { | ||||
|         return insert_onto(data) | ||||
|     end | ||||
| } | ||||
| spells[#spells + 1] = { | ||||
|     name = {'spells.comfylatron'}, | ||||
|     entityName = 'suicidal_comfylatron', | ||||
|     target = false, | ||||
|     amount = 4, | ||||
|     damage = false, | ||||
|     range = 30, | ||||
|     force = 'player', | ||||
|     level = 60, | ||||
|     type = 'special', | ||||
|     mana_cost = 150, | ||||
|     enforce_cooldown = true, | ||||
|     cooldown = 150, | ||||
|     enabled = true, | ||||
|     log_spell = true, | ||||
|     sprite = 'entity/compilatron', | ||||
|     tooltip = 'Spawns a suicide comfylatron', | ||||
|     callback = function(data) | ||||
|         local self = data.self | ||||
|         local player = data.player | ||||
|         Public.register_cooldown_for_spell(player) | ||||
|  | ||||
|         local position = data.position | ||||
|         local surface = data.surface | ||||
|  | ||||
|         Public.suicidal_comfylatron(position, surface) | ||||
|         Public.cast_spell(player) | ||||
|         Public.remove_mana(player, self.mana_cost) | ||||
|         return true | ||||
|     end | ||||
| } | ||||
| spells[#spells + 1] = { | ||||
|     name = {'spells.distractor'}, | ||||
|     entityName = 'distractor-capsule', | ||||
|   | ||||
| @@ -814,22 +814,22 @@ local function reform_group(group) | ||||
|             new_group.add_member(biter) | ||||
|         end | ||||
|         Public.debug_print('Creating new unit group, because old one was stuck.') | ||||
|         generated_units.unit_groups[new_group.group_number] = new_group | ||||
|         generated_units.unit_groups[new_group.unique_id] = new_group | ||||
|         local unit_groups_size = Public.get('unit_groups_size') | ||||
|         Public.set('unit_groups_size', unit_groups_size + 1) | ||||
|  | ||||
|         return new_group | ||||
|     else | ||||
|         Public.debug_print('Destroying stuck group.') | ||||
|         if generated_units.unit_groups[group.group_number] then | ||||
|             if generated_units.unit_group_last_command[group.group_number] then | ||||
|                 generated_units.unit_group_last_command[group.group_number] = nil | ||||
|         if generated_units.unit_groups[group.unique_id] then | ||||
|             if generated_units.unit_group_last_command[group.unique_id] then | ||||
|                 generated_units.unit_group_last_command[group.unique_id] = nil | ||||
|             end | ||||
|             local positions = generated_units.unit_group_pos.positions | ||||
|             if positions[group.group_number] then | ||||
|                 positions[group.group_number] = nil | ||||
|             if positions[group.unique_id] then | ||||
|                 positions[group.unique_id] = nil | ||||
|             end | ||||
|             table.remove(generated_units.unit_groups, group.group_number) | ||||
|             table.remove(generated_units.unit_groups, group.unique_id) | ||||
|             local unit_groups_size = Public.get('unit_groups_size') | ||||
|             Public.set('unit_groups_size', unit_groups_size - 1) | ||||
|         end | ||||
| @@ -972,12 +972,12 @@ local function command_to_main_target(group, bypass) | ||||
|     local generated_units = Public.get('generated_units') | ||||
|     local unit_group_command_delay = Public.get('unit_group_command_delay') | ||||
|     if not bypass then | ||||
|         if not generated_units.unit_group_last_command[group.group_number] then | ||||
|             generated_units.unit_group_last_command[group.group_number] = game.tick - (unit_group_command_delay + 1) | ||||
|         if not generated_units.unit_group_last_command[group.unique_id] then | ||||
|             generated_units.unit_group_last_command[group.unique_id] = game.tick - (unit_group_command_delay + 1) | ||||
|         end | ||||
|  | ||||
|         if generated_units.unit_group_last_command[group.group_number] then | ||||
|             if generated_units.unit_group_last_command[group.group_number] + unit_group_command_delay > game.tick then | ||||
|         if generated_units.unit_group_last_command[group.unique_id] then | ||||
|             if generated_units.unit_group_last_command[group.unique_id] + unit_group_command_delay > game.tick then | ||||
|                 return | ||||
|             end | ||||
|         end | ||||
| @@ -1015,19 +1015,19 @@ local function command_to_main_target(group, bypass) | ||||
|     ) | ||||
|     Public.debug_print('get_main_command - sent commands') | ||||
|     if valid(group) then | ||||
|         generated_units.unit_group_last_command[group.group_number] = game.tick | ||||
|         generated_units.unit_group_last_command[group.unique_id] = game.tick | ||||
|     end | ||||
| end | ||||
|  | ||||
| local function command_to_side_target(group) | ||||
|     local generated_units = Public.get('generated_units') | ||||
|     local unit_group_command_delay = Public.get('unit_group_command_delay') | ||||
|     if not generated_units.unit_group_last_command[group.group_number] then | ||||
|         generated_units.unit_group_last_command[group.group_number] = game.tick - (unit_group_command_delay + 1) | ||||
|     if not generated_units.unit_group_last_command[group.unique_id] then | ||||
|         generated_units.unit_group_last_command[group.unique_id] = game.tick - (unit_group_command_delay + 1) | ||||
|     end | ||||
|  | ||||
|     if generated_units.unit_group_last_command[group.group_number] then | ||||
|         if generated_units.unit_group_last_command[group.group_number] + unit_group_command_delay > game.tick then | ||||
|     if generated_units.unit_group_last_command[group.unique_id] then | ||||
|         if generated_units.unit_group_last_command[group.unique_id] + unit_group_command_delay > game.tick then | ||||
|             return | ||||
|         end | ||||
|     end | ||||
| @@ -1050,7 +1050,7 @@ local function command_to_side_target(group) | ||||
|         } | ||||
|     ) | ||||
|  | ||||
|     generated_units.unit_group_last_command[group.group_number] = game.tick | ||||
|     generated_units.unit_group_last_command[group.unique_id] = game.tick | ||||
| end | ||||
|  | ||||
| local function give_side_commands_to_group() | ||||
| @@ -1175,12 +1175,12 @@ local function spawn_unit_group(fs, only_bosses) | ||||
|  | ||||
|     local generated_units = Public.get('generated_units') | ||||
|  | ||||
|     local unit_group = surface.create_unit_group({ position = spawn_position, force = force }) | ||||
|     local unit_group = surface.create_unit_group({ position = spawn_position, force = force }) --[[@as UnitGroup]] | ||||
|  | ||||
|     event_data.unit_group = unit_group | ||||
|  | ||||
|     generated_units.unit_group_pos.index = generated_units.unit_group_pos.index + 1 | ||||
|     generated_units.unit_group_pos.positions[unit_group.group_number] = { position = unit_group.position, index = 0 } | ||||
|     generated_units.unit_group_pos.positions[unit_group.unique_id] = { position = unit_group.position, index = 0 } | ||||
|     local average_unit_group_size = Public.get('average_unit_group_size') | ||||
|     local unit_settings = Public.get('unit_settings') | ||||
|     event_data.unit_settings = unit_settings | ||||
| @@ -1248,7 +1248,7 @@ local function spawn_unit_group(fs, only_bosses) | ||||
|         end | ||||
|     end | ||||
|  | ||||
|     generated_units.unit_groups[unit_group.group_number] = unit_group | ||||
|     generated_units.unit_groups[unit_group.unique_id] = unit_group | ||||
|     local unit_groups_size = Public.get('unit_groups_size') | ||||
|     Public.set('unit_groups_size', unit_groups_size + 1) | ||||
|     if random(1, 2) == 1 then | ||||
| @@ -1292,7 +1292,7 @@ local function spawn_unit_group_simple(fs) | ||||
|  | ||||
|  | ||||
|     generated_units.unit_group_pos.index = generated_units.unit_group_pos.index + 1 | ||||
|     generated_units.unit_group_pos.positions[unit_group.group_number] = { position = unit_group.position, index = 0 } | ||||
|     generated_units.unit_group_pos.positions[unit_group.unique_id] = { position = unit_group.position, index = 0 } | ||||
|     local unit_settings = Public.get('unit_settings') | ||||
|  | ||||
|  | ||||
| @@ -1320,7 +1320,7 @@ local function spawn_unit_group_simple(fs) | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     generated_units.unit_groups[unit_group.group_number] = unit_group | ||||
|     generated_units.unit_groups[unit_group.unique_id] = unit_group | ||||
|     local unit_groups_size = Public.get('unit_groups_size') | ||||
|     Public.set('unit_groups_size', unit_groups_size + 1) | ||||
|     if random(1, 2) == 1 then | ||||
| @@ -1347,17 +1347,17 @@ local function check_group_positions() | ||||
|             if group.state == defines.group_state.finished then | ||||
|                 return command_to_main_target(group, true) | ||||
|             end | ||||
|             if ugp[group.group_number] then | ||||
|                 local success = is_position_near(group.position, ugp[group.group_number].position) | ||||
|             if ugp[group.unique_id] then | ||||
|                 local success = is_position_near(group.position, ugp[group.unique_id].position) | ||||
|                 if success then | ||||
|                     ugp[group.group_number].index = ugp[group.group_number].index + 1 | ||||
|                     if ugp[group.group_number].index >= 2 then | ||||
|                     ugp[group.unique_id].index = ugp[group.unique_id].index + 1 | ||||
|                     if ugp[group.unique_id].index >= 2 then | ||||
|                         command_to_main_target(group, true) | ||||
|                         fill_tiles(group, 30) | ||||
|                         remove_rocks(group) | ||||
|                         remove_trees(group) | ||||
|                         if valid(group) and ugp[group.group_number].index >= 4 then | ||||
|                             generated_units.unit_group_pos.positions[group.group_number] = nil | ||||
|                         if valid(group) and ugp[group.unique_id].index >= 4 then | ||||
|                             generated_units.unit_group_pos.positions[group.unique_id] = nil | ||||
|                             reform_group(group) | ||||
|                         end | ||||
|                     end | ||||
|   | ||||
| @@ -73,7 +73,7 @@ local place_nest_near_unit_group = function () | ||||
|     local disable_spawn_near_target = Public.get('disable_spawn_near_target') | ||||
|  | ||||
|     local generated_units = Public.get('generated_units') | ||||
|     local group = generated_units.unit_groups[random_group.group_number] | ||||
|     local group = generated_units.unit_groups[random_groupunique_id] | ||||
|     if not group then | ||||
|         return | ||||
|     end | ||||
| @@ -234,7 +234,7 @@ function Public.build_worm() | ||||
|         return | ||||
|     end | ||||
|     local generated_units = Public.get('generated_units') | ||||
|     local group = generated_units.unit_groups[random_group.group_number] | ||||
|     local group = generated_units.unit_groups[random_groupunique_id] | ||||
|     if not group then | ||||
|         return | ||||
|     end | ||||
|   | ||||
| @@ -110,8 +110,8 @@ market.logistic = { | ||||
|     ['pump'] = { value = 16, rarity = 4 }, | ||||
|     ['logistic-robot'] = { value = 28, rarity = 5 }, | ||||
|     ['construction-robot'] = { value = 28, rarity = 3 }, | ||||
|     ['active-chest-provider'] = { value = 128, rarity = 7 }, | ||||
|     ['passive-chest-provider'] = { value = 128, rarity = 6 }, | ||||
|     ['active-provider-chest'] = { value = 128, rarity = 7 }, | ||||
|     ['passive-provider-chest'] = { value = 128, rarity = 6 }, | ||||
|     ['storage-chest'] = { value = 128, rarity = 6 }, | ||||
|     ['buffer-chest'] = { value = 128, rarity = 7 }, | ||||
|     ['requester-chest'] = { value = 128, rarity = 7 }, | ||||
|   | ||||
| @@ -52,8 +52,8 @@ local item_worths = { | ||||
|     ['tank'] = 4096, | ||||
|     ['logistic-robot'] = 256, | ||||
|     ['construction-robot'] = 256, | ||||
|     ['active-chest-provider'] = 256, | ||||
|     ['passive-chest-provider'] = 256, | ||||
|     ['active-provider-chest'] = 256, | ||||
|     ['passive-provider-chest'] = 256, | ||||
|     ['storage-chest'] = 256, | ||||
|     ['buffer-chest'] = 512, | ||||
|     ['requester-chest'] = 512, | ||||
|   | ||||
| @@ -12,7 +12,7 @@ local this = { | ||||
|  | ||||
| Global.register( | ||||
|     this, | ||||
|     function(t) | ||||
|     function (t) | ||||
|         this = t | ||||
|     end | ||||
| ) | ||||
| @@ -52,29 +52,29 @@ local sections = { | ||||
|  | ||||
| local check_bottom_buttons_token = | ||||
|     Task.register( | ||||
|     function(event) | ||||
|         local player_index = event.player_index | ||||
|         local player = game.get_player(player_index) | ||||
|         if not player or not player.valid then | ||||
|             return | ||||
|         end | ||||
|         function (event) | ||||
|             local player_index = event.player_index | ||||
|             local player = game.get_player(player_index) | ||||
|             if not player or not player.valid then | ||||
|                 return | ||||
|             end | ||||
|  | ||||
|         local player_data, storage_data = get_player_data(player) | ||||
|         if not player_data or not storage_data or not next(storage_data) then | ||||
|             destroy_frame(player) | ||||
|             remove_player(player.index) | ||||
|             return | ||||
|             local player_data, storage_data = get_player_data(player) | ||||
|             if not player_data or not storage_data or not next(storage_data) then | ||||
|                 destroy_frame(player) | ||||
|                 remove_player(player.index) | ||||
|                 return | ||||
|             end | ||||
|         end | ||||
|     end | ||||
| ) | ||||
|     ) | ||||
|  | ||||
| remove_player = function(index) | ||||
| remove_player = function (index) | ||||
|     this.players[index] = nil | ||||
|     this.storage[index] = nil | ||||
|     this.bottom_quickbar_button[index] = nil | ||||
| end | ||||
|  | ||||
| get_player_data = function(player, remove_user_data) | ||||
| get_player_data = function (player, remove_user_data) | ||||
|     if remove_user_data then | ||||
|         this.players[player.index] = nil | ||||
|         this.storage[player.index] = nil | ||||
| @@ -106,13 +106,13 @@ local function refresh_inner_frames(player) | ||||
|  | ||||
|     local main_frame = player_data.frame | ||||
|  | ||||
|     local horizontal_flow = main_frame.add {type = 'flow', direction = 'horizontal'} | ||||
|     local horizontal_flow = main_frame.add { type = 'flow', direction = 'horizontal' } | ||||
|     horizontal_flow.style.horizontal_spacing = 0 | ||||
|  | ||||
|     for row_index, row_index_data in pairs(storage_data) do | ||||
|         if row_index_data and type(row_index_data) == 'table' then | ||||
|             local section_row_index = player_data.section[row_index] | ||||
|             local vertical_flow = horizontal_flow.add {type = 'flow', direction = 'vertical'} | ||||
|             local vertical_flow = horizontal_flow.add { type = 'flow', direction = 'vertical' } | ||||
|             vertical_flow.style.vertical_spacing = 0 | ||||
|  | ||||
|             if not section_row_index then | ||||
| @@ -131,12 +131,12 @@ local function refresh_inner_frames(player) | ||||
|  | ||||
|                 section_row_index[row_selection] = | ||||
|                     section_row_index.inner_frame.add { | ||||
|                     type = 'sprite-button', | ||||
|                     sprite = row_selection_data.sprite, | ||||
|                     name = row_selection_data.name, | ||||
|                     tooltip = row_selection_data.tooltip or '', | ||||
|                     style = 'quick_bar_page_button' | ||||
|                 } | ||||
|                         type = 'sprite-button', | ||||
|                         sprite = row_selection_data.sprite, | ||||
|                         name = row_selection_data.name, | ||||
|                         tooltip = row_selection_data.tooltip or '', | ||||
|                         style = 'quick_bar_page_button' | ||||
|                     } | ||||
|             end | ||||
|         end | ||||
|     end | ||||
| @@ -144,16 +144,16 @@ end | ||||
|  | ||||
| local refresh_inner_frames_token = | ||||
|     Task.register( | ||||
|     function(event) | ||||
|         local player_index = event.player_index | ||||
|         local player = game.get_player(player_index) | ||||
|         if not player or not player.valid then | ||||
|             return | ||||
|         end | ||||
|         function (event) | ||||
|             local player_index = event.player_index | ||||
|             local player = game.get_player(player_index) | ||||
|             if not player or not player.valid then | ||||
|                 return | ||||
|             end | ||||
|  | ||||
|         refresh_inner_frames(player) | ||||
|     end | ||||
| ) | ||||
|             refresh_inner_frames(player) | ||||
|         end | ||||
|     ) | ||||
|  | ||||
| ---Adds a new inner frame to the bottom frame | ||||
| -- local BottomFrame = require 'utils.gui.bottom_frame' | ||||
| @@ -217,10 +217,10 @@ local function add_inner_frame(data) | ||||
|     player_data.row_selection = player_data.row_selection + 1 | ||||
|     player_data.row_selection_added = player_data.row_selection_added + 1 | ||||
|     player_data.row_selection = player_data.row_selection > 2 and 1 or player_data.row_selection | ||||
|     Task.priority_delay(2, refresh_inner_frames_token, {player_index = player.index}) | ||||
|     Task.priority_delay(2, refresh_inner_frames_token, { player_index = player.index }) | ||||
| end | ||||
|  | ||||
| destroy_frame = function(player) | ||||
| destroy_frame = function (player) | ||||
|     local gui = player.gui | ||||
|     local frame = gui.screen[main_frame_name] | ||||
|     if frame and frame.valid then | ||||
| @@ -245,10 +245,10 @@ local function create_frame(player, alignment, location, data) | ||||
|  | ||||
|     frame = | ||||
|         player.gui.screen.add { | ||||
|         type = 'frame', | ||||
|         name = main_frame_name, | ||||
|         direction = alignment | ||||
|     } | ||||
|             type = 'frame', | ||||
|             name = main_frame_name, | ||||
|             direction = alignment | ||||
|         } | ||||
|  | ||||
|     if data.visible ~= nil then | ||||
|         if data.visible then | ||||
| @@ -266,9 +266,9 @@ local function create_frame(player, alignment, location, data) | ||||
|  | ||||
|     local inner_frame = | ||||
|         frame.add { | ||||
|         type = 'frame', | ||||
|         direction = alignment | ||||
|     } | ||||
|             type = 'frame', | ||||
|             direction = alignment | ||||
|         } | ||||
|     inner_frame.style = 'quick_bar_inner_panel' | ||||
|  | ||||
|     frame.location = location | ||||
| @@ -288,12 +288,12 @@ local function create_frame(player, alignment, location, data) | ||||
|     data.section_data = data.section_data or {} | ||||
|     data.alignment = alignment | ||||
|  | ||||
|     Task.priority_delay(5, check_bottom_buttons_token, {player_index = player.index}) | ||||
|     Task.priority_delay(5, check_bottom_buttons_token, { player_index = player.index }) | ||||
|  | ||||
|     return frame | ||||
| end | ||||
|  | ||||
| set_location = function(player, state) | ||||
| set_location = function (player, state) | ||||
|     local data = get_player_data(player) | ||||
|     local alignment = 'vertical' | ||||
|  | ||||
| @@ -328,7 +328,7 @@ set_location = function(player, state) | ||||
|             alignment = 'horizontal' | ||||
|         else | ||||
|             location = { | ||||
|                 x = (resolution.width / 2) - ((54 + -528) * scale), | ||||
|                 x = (resolution.width / 2) - ((54 + -689) * scale), | ||||
|                 y = (resolution.height - (96 * scale)) | ||||
|             } | ||||
|         end | ||||
| @@ -340,7 +340,7 @@ set_location = function(player, state) | ||||
|         } | ||||
|     end | ||||
|  | ||||
|     Event.raise(Public.events.bottom_quickbar_location_changed, {player_index = player.index, data = data}) | ||||
|     Event.raise(Public.events.bottom_quickbar_location_changed, { player_index = player.index, data = data }) | ||||
|  | ||||
|     data.state = state | ||||
|     create_frame(player, alignment, location, data) | ||||
| @@ -459,7 +459,7 @@ end | ||||
|  | ||||
| Event.add( | ||||
|     defines.events.on_player_joined_game, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         if this.activate_custom_buttons then | ||||
|             local player = game.get_player(event.player_index) | ||||
|             local data = get_player_data(player) | ||||
| @@ -470,7 +470,7 @@ Event.add( | ||||
|  | ||||
| Event.add( | ||||
|     defines.events.on_player_display_resolution_changed, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         if this.activate_custom_buttons then | ||||
|             local player = game.get_player(event.player_index) | ||||
|             local data = get_player_data(player) | ||||
| @@ -481,7 +481,7 @@ Event.add( | ||||
|  | ||||
| Event.add( | ||||
|     defines.events.on_player_display_scale_changed, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         local player = game.get_player(event.player_index) | ||||
|         if this.activate_custom_buttons then | ||||
|             local data = get_player_data(player) | ||||
| @@ -492,7 +492,7 @@ Event.add( | ||||
|  | ||||
| Event.add( | ||||
|     defines.events.on_pre_player_left_game, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         local player = game.get_player(event.player_index) | ||||
|         destroy_frame(player) | ||||
|         if this.activate_custom_buttons then | ||||
| @@ -503,7 +503,7 @@ Event.add( | ||||
|  | ||||
| Event.add( | ||||
|     defines.events.on_player_left_game, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         local player = game.get_player(event.player_index) | ||||
|         destroy_frame(player) | ||||
|         if this.activate_custom_buttons then | ||||
| @@ -514,7 +514,7 @@ Event.add( | ||||
|  | ||||
| Event.add( | ||||
|     defines.events.on_pre_player_died, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         if this.activate_custom_buttons then | ||||
|             local player = game.get_player(event.player_index) | ||||
|             destroy_frame(player) | ||||
| @@ -524,7 +524,7 @@ Event.add( | ||||
|  | ||||
| Event.add( | ||||
|     defines.events.on_player_respawned, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         if this.activate_custom_buttons then | ||||
|             local player = game.get_player(event.player_index) | ||||
|             local data = get_player_data(player) | ||||
| @@ -535,14 +535,14 @@ Event.add( | ||||
|  | ||||
| Event.add( | ||||
|     defines.events.on_player_removed, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         remove_player(event.player_index) | ||||
|     end | ||||
| ) | ||||
|  | ||||
| Event.add( | ||||
|     Public.events.bottom_quickbar_respawn_raise, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         if not event or not event.player_index then | ||||
|             return | ||||
|         end | ||||
| @@ -557,7 +557,7 @@ Event.add( | ||||
|  | ||||
| Event.add( | ||||
|     Public.events.bottom_quickbar_location_changed, | ||||
|     function(event) | ||||
|     function (event) | ||||
|         if not event or not event.player_index then | ||||
|             return | ||||
|         end | ||||
|   | ||||
| @@ -106,7 +106,7 @@ Public.raw_print = raw_print | ||||
| local function output_data(primary, secondary) | ||||
|     local secs = server_time.secs | ||||
|     if secs == nil then | ||||
|         return false | ||||
|         return raw_print(primary .. (secondary or '')) | ||||
|     end | ||||
|  | ||||
|     secondary = type(secondary) == 'table' and '' or secondary | ||||
|   | ||||
| @@ -10,23 +10,12 @@ local scrap_entities = { | ||||
|     'crash-site-assembling-machine-1-broken', | ||||
|     'crash-site-assembling-machine-2-broken', | ||||
|     'crash-site-lab-broken', | ||||
|     'medium-ship-wreck', | ||||
|     'small-ship-wreck', | ||||
|     'crash-site-chest-1', | ||||
|     'crash-site-chest-2', | ||||
|     'crash-site-chest-1', | ||||
|     'crash-site-chest-2', | ||||
|     'crash-site-chest-1', | ||||
|     'crash-site-chest-2', | ||||
|     'big-ship-wreck-1', | ||||
|     'big-ship-wreck-2', | ||||
|     'big-ship-wreck-3', | ||||
|     'big-ship-wreck-1', | ||||
|     'big-ship-wreck-2', | ||||
|     'big-ship-wreck-3', | ||||
|     'big-ship-wreck-1', | ||||
|     'big-ship-wreck-2', | ||||
|     'big-ship-wreck-3' | ||||
| } | ||||
| local scrap_entities_index = #scrap_entities | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user