diff --git a/maps/cave_choppy/forest_world.lua b/maps/cave_choppy/forest_world.lua index 1fbe2c2a..9465f3c3 100644 --- a/maps/cave_choppy/forest_world.lua +++ b/maps/cave_choppy/forest_world.lua @@ -439,7 +439,7 @@ local function on_player_joined_game() ['rock-huge'] = { 'uranium-ore' } } - if game.item_prototypes['angels-ore1'] then + if prototypes.item['angels-ore1'] then storage.entity_yield['tree-01'] = { 'angels-ore1', 'angels-ore2' } storage.entity_yield['tree-02-red'] = { 'angels-ore5', 'angels-ore6' } storage.entity_yield['tree-04'] = { 'coal' } @@ -448,7 +448,7 @@ local function on_player_joined_game() game.map_settings.pollution.ageing = 0 end - if game.item_prototypes['thorium-ore'] then + if prototypes.item['thorium-ore'] then storage.entity_yield['rock-big'] = { 'uranium-ore', 'thorium-ore' } storage.entity_yield['rock-huge'] = { 'uranium-ore', 'thorium-ore' } end diff --git a/maps/cave_choppy/infinity_chest.lua b/maps/cave_choppy/infinity_chest.lua index 7899bc52..7db62d97 100644 --- a/maps/cave_choppy/infinity_chest.lua +++ b/maps/cave_choppy/infinity_chest.lua @@ -12,8 +12,8 @@ local chests = {} local chests_next = {} Global.register( - {chests = chests, chests_next = chests_next}, - function(tbl) + { chests = chests, chests_next = chests_next }, + function (tbl) chests = tbl.chests chests_next = tbl.chests_next end @@ -23,8 +23,8 @@ local chest_gui_frame_name = Gui.uid_name() local chest_content_table_name = Gui.uid_name() function Public.create_chest(surface, position, storage) - local entity = surface.create_entity {name = 'infinity-chest', position = position, force = 'neutral'} - chests[entity.unit_number] = {entity = entity, storage = storage} + local entity = surface.create_entity { name = 'infinity-chest', position = position, force = 'neutral' } + chests[entity.unit_number] = { entity = entity, storage = storage } return entity end @@ -36,11 +36,11 @@ local function built_entity(event) entity.active = false - chests[entity.unit_number] = {entity = entity, storage = {}} + chests[entity.unit_number] = { entity = entity, storage = {} } end local function get_stack_size(name) - local proto = game.item_prototypes[name] + local proto = prototypes.item[name] if not proto then log('item prototype ' .. name .. ' not found') return 1 @@ -60,7 +60,7 @@ local function do_item(name, count, inv, storage) local new_amount = 0 if diff > 0 then - inv.remove({name = name, count = diff}) + inv.remove({ name = name, count = diff }) local prev = storage[name] or 0 new_amount = prev + diff elseif diff < 0 then @@ -70,7 +70,7 @@ local function do_item(name, count, inv, storage) end diff = math.min(prev, -diff) - local inserted = inv.insert({name = name, count = diff}) + local inserted = inv.insert({ name = name, count = diff }) new_amount = prev - inserted end @@ -119,7 +119,7 @@ local function create_chest_gui_content(frame, player, chest) if grid then grid.clear() else - grid = frame.add {type = 'table', name = chest_content_table_name, column_count = 10, style = 'slot_table'} + grid = frame.add { type = 'table', name = chest_content_table_name, column_count = 10, style = 'slot_table' } end for name, count in pairs(storage) do @@ -153,36 +153,36 @@ end local chest_gui_content_callback chest_gui_content_callback = Token.register( - function(data) - local player = data.player + function (data) + local player = data.player - if not player or not player.valid then - return + if not player or not player.valid then + return + end + + local opened = data.opened + if not opened or not opened.valid then + return + end + + local entity = data.chest.entity + if not entity.valid then + player.opened = nil + opened.destroy() + return + end + + if not player.connected then + player.opened = nil + opened.destroy() + return + end + + create_chest_gui_content(opened, player, data.chest) + + Task.set_timeout_in_ticks(60, chest_gui_content_callback, data) end - - local opened = data.opened - if not opened or not opened.valid then - return - end - - local entity = data.chest.entity - if not entity.valid then - player.opened = nil - opened.destroy() - return - end - - if not player.connected then - player.opened = nil - opened.destroy() - return - end - - create_chest_gui_content(opened, player, data.chest) - - Task.set_timeout_in_ticks(60, chest_gui_content_callback, data) - end -) + ) local function gui_opened(event) if not event.gui_type == defines.gui_type.entity then @@ -207,27 +207,27 @@ local function gui_opened(event) local frame = player.gui.center.add { - type = 'frame', - name = chest_gui_frame_name, - caption = 'Infinite Storage Chest', - direction = 'vertical' - } + type = 'frame', + name = chest_gui_frame_name, + caption = 'Infinite Storage Chest', + direction = 'vertical' + } local text = frame.add { - type = 'label', - caption = format( - 'This chest stores unlimited quantity of items (up to 48 different item types).\nThe chest is best used with an inserter to add / remove items.\nIf the chest is mined or destroyed the items are lost.' - ) - } + type = 'label', + caption = format( + 'This chest stores unlimited quantity of items (up to 48 different item types).\nThe chest is best used with an inserter to add / remove items.\nIf the chest is mined or destroyed the items are lost.' + ) + } text.style.single_line = false - local content_header = frame.add {type = 'label', caption = 'Content'} + local content_header = frame.add { type = 'label', caption = 'Content' } content_header.style.font = 'default-listbox' create_chest_gui_content(frame, player, chest) - Task.set_timeout_in_ticks(60, chest_gui_content_callback, {player = player, chest = chest, opened = frame}) + Task.set_timeout_in_ticks(60, chest_gui_content_callback, { player = player, chest = chest, opened = frame }) end Event.add(defines.events.on_built_entity, built_entity) @@ -237,7 +237,7 @@ Event.add(defines.events.on_gui_opened, gui_opened) Event.add( defines.events.on_player_died, - function(event) + function (event) local player = game.get_player(event.player_index or 0) if not player or not player.valid then @@ -257,7 +257,7 @@ Event.add( Gui.on_custom_close( chest_gui_frame_name, - function(event) + function (event) event.element.destroy() end ) diff --git a/maps/cave_choppy/main.lua b/maps/cave_choppy/main.lua index 2b5f8f5d..94a09233 100644 --- a/maps/cave_choppy/main.lua +++ b/maps/cave_choppy/main.lua @@ -1036,7 +1036,7 @@ local function on_chunk_generated(event) end local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/cave_miner.lua b/maps/cave_miner.lua index c5c1e227..beeacfc3 100644 --- a/maps/cave_miner.lua +++ b/maps/cave_miner.lua @@ -794,7 +794,7 @@ local function on_chunk_generated(event) end local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/cave_miner_v2/functions.lua b/maps/cave_miner_v2/functions.lua index e3c15b0f..85eb7605 100644 --- a/maps/cave_miner_v2/functions.lua +++ b/maps/cave_miner_v2/functions.lua @@ -24,7 +24,7 @@ end function Public.get_colored_name(player_index) local player = game.players[player_index] - local colored_name = table.concat({'[color=', player.chat_color.r, ',', player.chat_color.g, ',', player.chat_color.b, ']', player.name, '[/color]'}) + local colored_name = table.concat({ '[color=', player.chat_color.r, ',', player.chat_color.g, ',', player.chat_color.b, ']', player.name, '[/color]' }) return colored_name end @@ -64,30 +64,30 @@ function Public.reveal(cave_miner, surface, source_surface, position, brushsize) local copied_tiles = {} local i = 0 local brushsize_square = brushsize ^ 2 - for _, tile in pairs(source_surface.find_tiles_filtered({area = {{position.x - brushsize, position.y - brushsize}, {position.x + brushsize, position.y + brushsize}}})) do + for _, tile in pairs(source_surface.find_tiles_filtered({ area = { { position.x - brushsize, position.y - brushsize }, { position.x + brushsize, position.y + brushsize } } })) do local tile_position = tile.position if tile.name ~= 'lab-dark-2' and tile.name ~= 'lab-dark-1' and (position.x - tile_position.x) ^ 2 + (position.y - tile_position.y) ^ 2 < brushsize_square then i = i + 1 - copied_tiles[i] = {name = 'lab-dark-1', position = tile.position} - tiles[i] = {name = tile.name, position = tile.position} + copied_tiles[i] = { name = 'lab-dark-1', position = tile.position } + tiles[i] = { name = tile.name, position = tile.position } end end surface.set_tiles(tiles, true, false, false, false) source_surface.set_tiles(copied_tiles, false, false, false, false) - for _, entity in pairs(source_surface.find_entities_filtered({area = {{position.x - brushsize, position.y - brushsize}, {position.x + brushsize, position.y + brushsize}}})) do + for _, entity in pairs(source_surface.find_entities_filtered({ area = { { position.x - brushsize, position.y - brushsize }, { position.x + brushsize, position.y + brushsize } } })) do local entity_position = entity.position if (position.x - entity_position.x) ^ 2 + (position.y - entity_position.y) ^ 2 < brushsize_square then - local e = entity.clone({position = entity_position, surface = surface}) + local e = entity.clone({ position = entity_position, surface = surface }) if entity.force.index == 2 then e.active = true - table.insert(cave_miner.reveal_queue, {entity.type, entity.position.x, entity.position.y}) + table.insert(cave_miner.reveal_queue, { entity.type, entity.position.x, entity.position.y }) end entity.destroy() end end - source_surface.set_tiles({{name = 'lab-dark-2', position = position}}, false) + source_surface.set_tiles({ { name = 'lab-dark-2', position = position } }, false) source_surface.request_to_generate_chunks(position, 3) end @@ -116,7 +116,7 @@ function Public.spawn_player(player) player.teleport(position, surface) for name, count in pairs(Constants.starting_items) do - player.insert({name = name, count = count}) + player.insert({ name = name, count = count }) end end @@ -126,7 +126,7 @@ function Public.set_mining_speed(cave_miner, force) end function Public.place_worm(surface, position, multiplier) - local e = surface.create_entity({name = BiterRaffle.roll('worm', Public.get_difficulty_modifier(position) * multiplier), position = position, force = 'enemy'}) + local e = surface.create_entity({ name = BiterRaffle.roll('worm', Public.get_difficulty_modifier(position) * multiplier), position = position, force = 'enemy' }) return e end @@ -135,9 +135,9 @@ function Public.spawn_random_biter(surface, position, multiplier) local non_colliding_position = surface.find_non_colliding_position(name, position, 16, 1) local unit if non_colliding_position then - unit = surface.create_entity({name = name, position = non_colliding_position, force = 'enemy'}) + unit = surface.create_entity({ name = name, position = non_colliding_position, force = 'enemy' }) else - unit = surface.create_entity({name = name, position = position, force = 'enemy'}) + unit = surface.create_entity({ name = name, position = position, force = 'enemy' }) end unit.ai_settings.allow_try_return_to_spawner = false unit.ai_settings.allow_destroy_when_commands_fail = false @@ -150,7 +150,7 @@ function Public.rock_spawns_biters(cave_miner, position) local difficulty_modifier = Public.get_difficulty_modifier(position) local tick = game.tick for c = 1, amount, 1 do - Esq.add_to_queue(tick + c * 25, surface, {name = BiterRaffle.roll('mixed', difficulty_modifier), position = position, force = 'enemy'}, 8) + Esq.add_to_queue(tick + c * 25, surface, { name = BiterRaffle.roll('mixed', difficulty_modifier), position = position, force = 'enemy' }, 8) end end @@ -158,14 +158,14 @@ function Public.loot_crate(surface, position, container_name, player_index) local amount_multiplier = Constants.treasures[container_name].amount_multiplier local base_amount = 16 * amount_multiplier local difficulty_modifier = Public.get_difficulty_modifier(position) - local slots = game.entity_prototypes[container_name].get_inventory_size(defines.inventory.chest) + local slots = prototypes.entity[container_name].get_inventory_size(defines.inventory.chest) local tech_bonus = Constants.treasures[container_name].tech_bonus local description = Constants.treasures[container_name].description local blacklist = LootRaffle.get_tech_blacklist(difficulty_modifier + tech_bonus) local item_stacks = LootRaffle.roll(base_amount + difficulty_modifier * amount_multiplier * 5000, slots, blacklist) - local container = surface.create_entity({name = container_name, position = position, force = 'neutral'}) + local container = surface.create_entity({ name = container_name, position = position, force = 'neutral' }) for _, item_stack in pairs(item_stacks) do container.insert(item_stack) end @@ -186,17 +186,17 @@ function Public.loot_crate(surface, position, container_name, player_index) end for _, player in pairs(game.forces.player.connected_players) do - player.add_custom_alert(container, {type = 'item', name = 'wooden-chest'}, text, true) + player.add_custom_alert(container, { type = 'item', name = 'wooden-chest' }, text, true) end end function Public.place_crude_oil(surface, position, multiplier) - if not surface.can_place_entity({name = 'crude-oil', position = position, amount = 1}) then + if not surface.can_place_entity({ name = 'crude-oil', position = position, amount = 1 }) then return end local d = math_sqrt(position.x ^ 2 + position.y ^ 2) local amount = math_random(50000, 100000) + d * 100 * multiplier - surface.create_entity({name = 'crude-oil', position = position, amount = amount}) + surface.create_entity({ name = 'crude-oil', position = position, amount = amount }) end function Public.create_top_gui(player) @@ -204,18 +204,18 @@ function Public.create_top_gui(player) if frame then return end - frame = player.gui.top.add({type = 'frame', name = 'cave_miner', direction = 'horizontal'}) + frame = player.gui.top.add({ type = 'frame', name = 'cave_miner', direction = 'horizontal' }) frame.style.maximal_height = 38 - local label = frame.add({type = 'label', caption = 'Loading...'}) + local label = frame.add({ type = 'label', caption = 'Loading...' }) label.style.font = 'heading-2' - label.style.font_color = {225, 225, 225} + label.style.font_color = { 225, 225, 225 } label.style.margin = 0 label.style.padding = 0 - local label = frame.add({type = 'label', caption = 'Loading...'}) + local label = frame.add({ type = 'label', caption = 'Loading...' }) label.style.font = 'heading-2' - label.style.font_color = {225, 225, 225} + label.style.font_color = { 225, 225, 225 } label.style.margin = 0 label.style.padding = 0 end @@ -246,7 +246,7 @@ local function is_entity_in_darkness(entity) return false end - for _, lamp in pairs(entity.surface.find_entities_filtered({area = {{position.x - 16, position.y - 16}, {position.x + 16, position.y + 16}}, name = 'small-lamp'})) do + for _, lamp in pairs(entity.surface.find_entities_filtered({ area = { { position.x - 16, position.y - 16 }, { position.x + 16, position.y + 16 } }, name = 'small-lamp' })) do local circuit = lamp.get_or_create_control_behavior() if circuit then if lamp.energy > 25 and circuit.disabled == false then @@ -284,7 +284,7 @@ local function darkness_event(cave_miner, entity) count = 16 end for c = 1, count, 1 do - Esq.add_to_queue(game.tick + math_random(5, 45) * c, entity.surface, {name = BiterRaffle.roll('mixed', difficulty_modifier), position = position, force = 'enemy'}, 8) + Esq.add_to_queue(game.tick + math_random(5, 45) * c, entity.surface, { name = BiterRaffle.roll('mixed', difficulty_modifier), position = position, force = 'enemy' }, 8) end entity.damage(darkness[index] * 2, 'neutral', 'poison') @@ -306,58 +306,58 @@ end Public.mining_events = { { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) if math.random(1, 8) == 1 then - entity.surface.spill_item_stack(entity.position, {name = 'raw-fish', count = 1}, true) + entity.surface.spill_item_stack(entity.position, { name = 'raw-fish', count = 1 }, true) end end, 350000, 'Nothing' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local amount = Public.roll_biter_amount() local position = entity.position local surface = entity.surface local difficulty_modifier = Public.get_difficulty_modifier(position) local tick = game.tick for c = 1, amount, 1 do - Esq.add_to_queue(tick + c * 25, surface, {name = BiterRaffle.roll('mixed', difficulty_modifier), position = position, force = 'enemy'}, 8) + Esq.add_to_queue(tick + c * 25, surface, { name = BiterRaffle.roll('mixed', difficulty_modifier), position = position, force = 'enemy' }, 8) end end, 16384, 'Mixed_Biters' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local amount = Public.roll_biter_amount() local position = entity.position local surface = entity.surface local difficulty_modifier = Public.get_difficulty_modifier(position) local tick = game.tick for c = 1, amount, 1 do - Esq.add_to_queue(tick + c * 25, surface, {name = BiterRaffle.roll('biter', difficulty_modifier), position = position, force = 'enemy'}, 8) + Esq.add_to_queue(tick + c * 25, surface, { name = BiterRaffle.roll('biter', difficulty_modifier), position = position, force = 'enemy' }, 8) end end, 2048, 'Biters' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local amount = Public.roll_biter_amount() local position = entity.position local surface = entity.surface local difficulty_modifier = Public.get_difficulty_modifier(position) local tick = game.tick for c = 1, amount, 1 do - Esq.add_to_queue(tick + c * 25, surface, {name = BiterRaffle.roll('spitter', difficulty_modifier), position = position, force = 'enemy'}, 8) + Esq.add_to_queue(tick + c * 25, surface, { name = BiterRaffle.roll('spitter', difficulty_modifier), position = position, force = 'enemy' }, 8) end end, 2048, 'Spitters' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.loot_crate(surface, position, 'wooden-chest', player_index) @@ -366,7 +366,7 @@ Public.mining_events = { 'Treasure_Tier_1' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.loot_crate(surface, position, 'iron-chest', player_index) @@ -375,7 +375,7 @@ Public.mining_events = { 'Treasure_Tier_2' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.loot_crate(surface, position, 'steel-chest', player_index) @@ -384,7 +384,7 @@ Public.mining_events = { 'Treasure_Tier_3' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.loot_crate(surface, position, 'crash-site-spaceship-wreck-medium-' .. math_random(1, 3), player_index) @@ -393,7 +393,7 @@ Public.mining_events = { 'Treasure_Tier_4' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.loot_crate(surface, position, 'crash-site-spaceship-wreck-big-' .. math_random(1, 2), player_index) @@ -402,7 +402,7 @@ Public.mining_events = { 'Treasure_Tier_5' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.loot_crate(surface, position, 'big-ship-wreck-' .. math_random(1, 3), player_index) @@ -411,7 +411,7 @@ Public.mining_events = { 'Treasure_Tier_6' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.loot_crate(surface, position, 'crash-site-chest-' .. math_random(1, 2), player_index) @@ -420,7 +420,7 @@ Public.mining_events = { 'Treasure_Tier_7' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.loot_crate(surface, position, 'crash-site-spaceship', player_index) @@ -430,7 +430,7 @@ Public.mining_events = { 'Treasure_Tier_8' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface local unit = Public.spawn_random_biter(surface, position, 2) @@ -440,17 +440,17 @@ Public.mining_events = { 'Pet' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface - surface.create_entity({name = 'biter-spawner', position = position, force = 'enemy'}) + surface.create_entity({ name = 'biter-spawner', position = position, force = 'enemy' }) Public.unstuck_player(player_index) end, 1024, 'Nest' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface Public.place_worm(surface, position, 1) @@ -460,7 +460,7 @@ Public.mining_events = { 'Worm' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position if position.x ^ 2 + position.y ^ 2 < 8000 then return @@ -476,7 +476,7 @@ Public.mining_events = { surface, { name = BiterRaffle.roll('worm', difficulty_modifier), - position = {position.x + (-4 + math_random(0, 8)), position.y + (-4 + math_random(0, 8))}, + position = { position.x + (-4 + math_random(0, 8)), position.y + (-4 + math_random(0, 8)) }, force = 'enemy' }, 16 @@ -487,28 +487,28 @@ Public.mining_events = { 'Worms' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface - surface.create_entity({name = 'compilatron', position = position, force = 'player'}) + surface.create_entity({ name = 'compilatron', position = position, force = 'player' }) end, 64, 'Friendly Compilatron' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface - surface.create_entity({name = 'compilatron', position = position, force = 'enemy'}) + surface.create_entity({ name = 'compilatron', position = position, force = 'enemy' }) end, 128, 'Enemy Compilatron' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface - local entity = surface.create_entity({name = cave_miner.buildings_raffle[math_random(1, #cave_miner.buildings_raffle)], position = position, force = 'player'}) + local entity = surface.create_entity({ name = cave_miner.buildings_raffle[math_random(1, #cave_miner.buildings_raffle)], position = position, force = 'player' }) entity.health = math_random(1, entity.prototype.max_health) local player = game.players[player_index] game.print(Public.get_colored_name(player_index) .. ' discovered an abandoned building', Constants.chat_color) @@ -517,10 +517,10 @@ Public.mining_events = { 'Abandoned Building' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface - surface.create_entity({name = 'car', position = position, force = 'player'}) + surface.create_entity({ name = 'car', position = position, force = 'player' }) Public.unstuck_player(player_index) local player = game.players[player_index] game.print(player.name .. ' has finally found their car!!', Constants.chat_color) @@ -529,22 +529,22 @@ Public.mining_events = { 'Car' }, { - function(cave_miner, entity, player_index) + function (cave_miner, entity, player_index) local position = entity.position local surface = entity.surface local tick = game.tick local trees = {} - for k, prototype in pairs(game.entity_prototypes) do + for k, prototype in pairs(prototypes.entity) do if prototype.type == 'tree' then table.insert(trees, k) end end table.shuffle_table(trees) - local tree = game.entity_prototypes[trees[1]].name + local tree = prototypes.entity[trees[1]].name for c = 1, math_random(4, 96), 1 do - Esq.add_to_queue(tick + c * 5, surface, {name = tree, position = position, force = 'neutral'}, 64) + Esq.add_to_queue(tick + c * 5, surface, { name = tree, position = position, force = 'neutral' }, 64) end local player = game.players[player_index] game.print(player.name .. ' found a whole forest!', Constants.chat_color) @@ -555,14 +555,14 @@ Public.mining_events = { } Public.on_entity_died = { - ['unit'] = function(cave_miner, entity) + ['unit'] = function (cave_miner, entity) local position = entity.position local surface = entity.surface if math.random(1, 8) == 1 then - surface.spill_item_stack(position, {name = 'raw-fish', count = 1}, true) + surface.spill_item_stack(position, { name = 'raw-fish', count = 1 }, true) end end, - ['unit-spawner'] = function(cave_miner, entity) + ['unit-spawner'] = function (cave_miner, entity) local position = entity.position local surface = entity.surface local a = 64 * 0.0001 @@ -572,14 +572,14 @@ Public.on_entity_died = { Public.spawn_random_biter(surface, position, 1) end end, - ['simple-entity'] = function(cave_miner, entity) + ['simple-entity'] = function (cave_miner, entity) local position = entity.position cave_miner.rocks_broken = cave_miner.rocks_broken + 1 if math.random(1, 6) == 1 then Public.rock_spawns_biters(cave_miner, position) end end, - ['container'] = function(cave_miner, entity) + ['container'] = function (cave_miner, entity) local position = entity.position Public.reveal(cave_miner, game.surfaces.nauvis, game.surfaces.cave_miner_source, position, 20) end diff --git a/maps/cave_miner_v2/main.lua b/maps/cave_miner_v2/main.lua index a3a4381b..896c9839 100644 --- a/maps/cave_miner_v2/main.lua +++ b/maps/cave_miner_v2/main.lua @@ -208,7 +208,7 @@ local function on_init() cave_miner.buildings_raffle = {} local types = { 'furnace', 'assembling-machine', 'reactor', 'artillery-turret', 'boiler', 'beacon', 'generator', 'storage-tank', 'roboport' } - for _, e in pairs(game.entity_prototypes) do + for _, e in pairs(prototypes.entity) do for _, t in pairs(types) do if e.type == t then table.insert(cave_miner.buildings_raffle, e.name) diff --git a/maps/choppy.lua b/maps/choppy.lua index b4d91001..14cbe2db 100644 --- a/maps/choppy.lua +++ b/maps/choppy.lua @@ -274,7 +274,7 @@ local function on_player_joined_game(event) ['rock-huge'] = { 'uranium-ore' } } - if game.item_prototypes['angels-ore1'] then + if prototypes.item['angels-ore1'] then storage.entity_yield['tree-01'] = { 'angels-ore1', 'angels-ore2' } storage.entity_yield['tree-02-red'] = { 'angels-ore5', 'angels-ore6' } storage.entity_yield['tree-04'] = { 'coal' } @@ -283,7 +283,7 @@ local function on_player_joined_game(event) game.map_settings.pollution.ageing = 0 end - if game.item_prototypes['thorium-ore'] then + if prototypes.item['thorium-ore'] then storage.entity_yield['rock-big'] = { 'uranium-ore', 'thorium-ore' } storage.entity_yield['rock-huge'] = { 'uranium-ore', 'thorium-ore' } end diff --git a/maps/choppy_dx.lua b/maps/choppy_dx.lua index 00f13fa3..a3e455c7 100644 --- a/maps/choppy_dx.lua +++ b/maps/choppy_dx.lua @@ -395,7 +395,7 @@ local function on_player_joined_game(event) ['tree-05'] = { 'copper-ore', 'stone' } } - if game.item_prototypes['angels-ore1'] then + if prototypes.item['angels-ore1'] then storage.entity_yield['tree-01'] = { 'angels-ore1', 'angels-ore2' } storage.entity_yield['tree-02-red'] = { 'angels-ore5', 'angels-ore6' } storage.entity_yield['tree-04'] = { 'coal' } @@ -404,7 +404,7 @@ local function on_player_joined_game(event) --game.map_settings.pollution.ageing = 0 end - if game.item_prototypes['thorium-ore'] then + if prototypes.item['thorium-ore'] then storage.entity_yield['rock-big'] = { 'uranium-ore', 'thorium-ore' } storage.entity_yield['rock-huge'] = { 'uranium-ore', 'thorium-ore' } end @@ -636,9 +636,9 @@ local function on_player_mined_entity(event) player.create_local_flying_text( { - position = entity.position, - text = '+' .. amount .. ' [item=' .. main_item .. '] +' .. second_item_amount .. ' [item=' .. second_item .. ']', - color = { r = 0.8, g = 0.8, b = 0.8 } + position = entity.position, + text = '+' .. amount .. ' [item=' .. main_item .. '] +' .. second_item_amount .. ' [item=' .. second_item .. ']', + color = { r = 0.8, g = 0.8, b = 0.8 } } ) diff --git a/maps/chronosphere/world_functions.lua b/maps/chronosphere/world_functions.lua index 9dbd58b0..cfdce3bc 100644 --- a/maps/chronosphere/world_functions.lua +++ b/maps/chronosphere/world_functions.lua @@ -12,53 +12,53 @@ local floor = math.floor local Public = {} local noises = { - ['no_rocks'] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, - ['no_rocks_2'] = {{modifier = 0.013, weight = 1}, {modifier = 0.1, weight = 0.1}}, - ['large_caves'] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, - ['small_caves'] = {{modifier = 0.008, weight = 1}, {modifier = 0.03, weight = 0.15}, {modifier = 0.25, weight = 0.05}}, - ['small_caves_2'] = {{modifier = 0.009, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.25, weight = 0.05}}, - ['cave_ponds'] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.06}}, - ['cave_rivers'] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.25}, {modifier = 0.05, weight = 0.01}}, - ['cave_rivers_2'] = {{modifier = 0.003, weight = 1}, {modifier = 0.01, weight = 0.21}, {modifier = 0.05, weight = 0.01}}, - ['cave_rivers_3'] = {{modifier = 0.002, weight = 1}, {modifier = 0.01, weight = 0.15}, {modifier = 0.05, weight = 0.01}}, - ['cave_rivers_4'] = {{modifier = 0.001, weight = 1}, {modifier = 0.01, weight = 0.11}, {modifier = 0.05, weight = 0.01}}, - ['scrapyard'] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.35}, {modifier = 0.05, weight = 0.23}, {modifier = 0.1, weight = 0.11}}, - ['forest_location'] = {{modifier = 0.006, weight = 1}, {modifier = 0.01, weight = 0.25}, {modifier = 0.05, weight = 0.15}, {modifier = 0.1, weight = 0.05}}, - ['forest_density'] = {{modifier = 0.01, weight = 1}, {modifier = 0.05, weight = 0.5}, {modifier = 0.1, weight = 0.025}}, - ['ores'] = {{modifier = 0.05, weight = 1}, {modifier = 0.02, weight = 0.55}, {modifier = 0.05, weight = 0.05}}, - ['hedgemaze'] = {{modifier = 0.001, weight = 1}} + ['no_rocks'] = { { modifier = 0.0033, weight = 1 }, { modifier = 0.01, weight = 0.22 }, { modifier = 0.05, weight = 0.05 }, { modifier = 0.1, weight = 0.04 } }, + ['no_rocks_2'] = { { modifier = 0.013, weight = 1 }, { modifier = 0.1, weight = 0.1 } }, + ['large_caves'] = { { modifier = 0.0033, weight = 1 }, { modifier = 0.01, weight = 0.22 }, { modifier = 0.05, weight = 0.05 }, { modifier = 0.1, weight = 0.04 } }, + ['small_caves'] = { { modifier = 0.008, weight = 1 }, { modifier = 0.03, weight = 0.15 }, { modifier = 0.25, weight = 0.05 } }, + ['small_caves_2'] = { { modifier = 0.009, weight = 1 }, { modifier = 0.05, weight = 0.25 }, { modifier = 0.25, weight = 0.05 } }, + ['cave_ponds'] = { { modifier = 0.01, weight = 1 }, { modifier = 0.1, weight = 0.06 } }, + ['cave_rivers'] = { { modifier = 0.005, weight = 1 }, { modifier = 0.01, weight = 0.25 }, { modifier = 0.05, weight = 0.01 } }, + ['cave_rivers_2'] = { { modifier = 0.003, weight = 1 }, { modifier = 0.01, weight = 0.21 }, { modifier = 0.05, weight = 0.01 } }, + ['cave_rivers_3'] = { { modifier = 0.002, weight = 1 }, { modifier = 0.01, weight = 0.15 }, { modifier = 0.05, weight = 0.01 } }, + ['cave_rivers_4'] = { { modifier = 0.001, weight = 1 }, { modifier = 0.01, weight = 0.11 }, { modifier = 0.05, weight = 0.01 } }, + ['scrapyard'] = { { modifier = 0.005, weight = 1 }, { modifier = 0.01, weight = 0.35 }, { modifier = 0.05, weight = 0.23 }, { modifier = 0.1, weight = 0.11 } }, + ['forest_location'] = { { modifier = 0.006, weight = 1 }, { modifier = 0.01, weight = 0.25 }, { modifier = 0.05, weight = 0.15 }, { modifier = 0.1, weight = 0.05 } }, + ['forest_density'] = { { modifier = 0.01, weight = 1 }, { modifier = 0.05, weight = 0.5 }, { modifier = 0.1, weight = 0.025 } }, + ['ores'] = { { modifier = 0.05, weight = 1 }, { modifier = 0.02, weight = 0.55 }, { modifier = 0.05, weight = 0.05 } }, + ['hedgemaze'] = { { modifier = 0.001, weight = 1 } } } local entity_functions = { - ['turret'] = function(surface, entity) + ['turret'] = function (surface, entity) surface.create_entity(entity) end, - ['simple-entity'] = function(surface, entity) + ['simple-entity'] = function (surface, entity) surface.create_entity(entity) end, - ['simple-entity-with-owner'] = function(surface, entity) + ['simple-entity-with-owner'] = function (surface, entity) surface.create_entity(entity) end, - ['ammo-turret'] = function(surface, entity) + ['ammo-turret'] = function (surface, entity) local e = surface.create_entity(entity) - e.insert({name = 'uranium-rounds-magazine', count = random(16, 64)}) + e.insert({ name = 'uranium-rounds-magazine', count = random(16, 64) }) end, - ['container'] = function(surface, entity) + ['container'] = function (surface, entity) Treasure(surface, entity.position, entity.name) end, - ['lab'] = function(surface, entity) + ['lab'] = function (surface, entity) local objective = Chrono_table.get_table() local e = surface.create_entity(entity) local evo = 1 + min(floor(objective.chronojumps / 5), 4) local research = { - {'automation-science-pack', 'logistic-science-pack'}, - {'automation-science-pack', 'logistic-science-pack', 'military-science-pack'}, - {'automation-science-pack', 'logistic-science-pack', 'military-science-pack', 'chemical-science-pack'}, - {'automation-science-pack', 'logistic-science-pack', 'military-science-pack', 'chemical-science-pack', 'production-science-pack'}, - {'automation-science-pack', 'logistic-science-pack', 'military-science-pack', 'chemical-science-pack', 'production-science-pack', 'utility-science-pack'} + { 'automation-science-pack', 'logistic-science-pack' }, + { 'automation-science-pack', 'logistic-science-pack', 'military-science-pack' }, + { 'automation-science-pack', 'logistic-science-pack', 'military-science-pack', 'chemical-science-pack' }, + { 'automation-science-pack', 'logistic-science-pack', 'military-science-pack', 'chemical-science-pack', 'production-science-pack' }, + { 'automation-science-pack', 'logistic-science-pack', 'military-science-pack', 'chemical-science-pack', 'production-science-pack', 'utility-science-pack' } } for _, science in pairs(research[evo]) do - e.insert({name = science, count = random(min(30 + objective.chronojumps * 5, 100), min(60 + objective.chronojumps * 5, 200))}) + e.insert({ name = science, count = random(min(30 + objective.chronojumps * 5, 100), min(60 + objective.chronojumps * 5, 200)) }) end end } @@ -66,7 +66,7 @@ local entity_functions = { local function get_replacement_tile(surface, position) local objective = Chrono_table.get_table() for i = 1, 128, 1 do - local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}} + local vectors = { { 0, i }, { 0, i * -1 }, { i, 0 }, { i * -1, 0 } } table.shuffle_table(vectors) for k, v in pairs(vectors) do local tile = surface.get_tile(position.x + v[1], position.y + v[2]) @@ -94,12 +94,12 @@ function Public.replace_water(surface, left_top) local tiles = {} for x = 0, 31, 1 do for y = 0, 31, 1 do - local p = {x = left_top.x + x, y = left_top.y + y} + local p = { x = left_top.x + x, y = left_top.y + y } local tile = surface.get_tile(p) if tile.hidden_tile then surface.set_hidden_tile(p, get_replacement_tile(surface, p).name) elseif tile.collides_with('resource-layer') then - tiles[#tiles + 1] = {name = get_replacement_tile(surface, p), position = p} + tiles[#tiles + 1] = { name = get_replacement_tile(surface, p), position = p } end end end @@ -109,8 +109,8 @@ end function Public.spawn_entities(surface, entities) local objective = Chrono_table.get_table() for _, entity in pairs(entities) do - if entity_functions[game.entity_prototypes[entity.name].type] then - entity_functions[game.entity_prototypes[entity.name].type](surface, entity) + if entity_functions[prototypes.entity[entity.name].type] then + entity_functions[prototypes.entity[entity.name].type](surface, entity) else if surface.can_place_entity(entity) then local e = surface.create_entity(entity) @@ -125,7 +125,7 @@ function Public.spawn_entities(surface, entities) end function Public.spawn_decoratives(surface, decoratives) - surface.create_decoratives {check_collision = false, decoratives = decoratives} + surface.create_decoratives { check_collision = false, decoratives = decoratives } end function Public.spawn_treasures(surface, treasures) @@ -134,7 +134,7 @@ function Public.spawn_treasures(surface, treasures) if random(1, 6) == 1 then name = 'iron-chest' end - if surface.can_place_entity({name = name, position = p}) then + if surface.can_place_entity({ name = name, position = p }) then Treasure(surface, p, name) end end @@ -160,16 +160,16 @@ end --LABYRINTH-- local modifiers = { - {x = 0, y = -1}, - {x = -1, y = 0}, - {x = 1, y = 0}, - {x = 0, y = 1} + { x = 0, y = -1 }, + { x = -1, y = 0 }, + { x = 1, y = 0 }, + { x = 0, y = 1 } } local modifiers_diagonal = { - {diagonal = {x = -1, y = 1}, connection_1 = {x = -1, y = 0}, connection_2 = {x = 0, y = 1}}, - {diagonal = {x = 1, y = -1}, connection_1 = {x = 1, y = 0}, connection_2 = {x = 0, y = -1}}, - {diagonal = {x = 1, y = 1}, connection_1 = {x = 1, y = 0}, connection_2 = {x = 0, y = 1}}, - {diagonal = {x = -1, y = -1}, connection_1 = {x = -1, y = 0}, connection_2 = {x = 0, y = -1}} + { diagonal = { x = -1, y = 1 }, connection_1 = { x = -1, y = 0 }, connection_2 = { x = 0, y = 1 } }, + { diagonal = { x = 1, y = -1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = -1 } }, + { diagonal = { x = 1, y = 1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = 1 } }, + { diagonal = { x = -1, y = -1 }, connection_1 = { x = -1, y = 0 }, connection_2 = { x = 0, y = -1 } } } local function get_path_connections_count(cell_pos) @@ -186,7 +186,7 @@ end function Public.process_labyrinth_cell(pos, seed) local scheduletable = Chrono_table.get_schedule_table() local lake_noise_value = -0.85 - local cell_position = {x = pos.x / 32, y = pos.y / 32} + local cell_position = { x = pos.x / 32, y = pos.y / 32 } local mazenoise = Public.get_noise('hedgemaze', cell_position, seed) if mazenoise < lake_noise_value and Public.distance(pos.x / 32, pos.y / 32) > 65 then @@ -206,7 +206,7 @@ function Public.process_labyrinth_cell(pos, seed) end for _, m in pairs(modifiers) do - if get_path_connections_count({x = cell_position.x + m.x, y = cell_position.y + m.y}) >= random(2, 3) then + if get_path_connections_count({ x = cell_position.x + m.x, y = cell_position.y + m.y }) >= random(2, 3) then return false end end @@ -220,15 +220,15 @@ function Public.process_labyrinth_cell(pos, seed) end function Public.build_blueprint(surface, position, id, force) - local item = surface.create_entity{name = "item-on-ground", position = position, stack = {name = "blueprint", count = 1}} - local success = item.stack.import_stack(Blueprints[id]) - if success <= 0 then - local ghosts = item.stack.build_blueprint{surface = surface, force = force, position = position, force_build = true} - for _, ghost in pairs(ghosts) do - ghost.silent_revive({raise_revive = true}) - end - end - if item.valid then item.destroy() end + local item = surface.create_entity { name = "item-on-ground", position = position, stack = { name = "blueprint", count = 1 } } + local success = item.stack.import_stack(Blueprints[id]) + if success <= 0 then + local ghosts = item.stack.build_blueprint { surface = surface, force = force, position = position, force_build = true } + for _, ghost in pairs(ghosts) do + ghost.silent_revive({ raise_revive = true }) + end + end + if item.valid then item.destroy() end end return Public diff --git a/maps/crab_defender/terrain.lua b/maps/crab_defender/terrain.lua index 03f81992..d519c4ae 100644 --- a/maps/crab_defender/terrain.lua +++ b/maps/crab_defender/terrain.lua @@ -17,7 +17,7 @@ end local function get_replacement_tile(surface, position) for i = 1, 128, 1 do - local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}} + local vectors = { { 0, i }, { 0, i * -1 }, { i, 0 }, { i * -1, 0 } } shuffle(vectors) for k, v in pairs(vectors) do local tile = surface.get_tile(position.x + v[1], position.y + v[2]) @@ -39,7 +39,7 @@ local function is_enemy_territory(surface, p) end local function place_crab_market(surface, position) - local market = surface.create_entity({name = 'market', position = position, force = 'player'}) + local market = surface.create_entity({ name = 'market', position = position, force = 'player' }) market.minable = false return market end @@ -58,23 +58,23 @@ local function enemy_territory(surface, left_top) return end - local area = {{left_top.x, left_top.y}, {left_top.x + 32, left_top.y + 32}} + local area = { { left_top.x, left_top.y }, { left_top.x + 32, left_top.y + 32 } } local find_entities_filtered = surface.find_entities_filtered for x = 0, 31, 1 do for y = 0, 31, 1 do - local pos = {x = left_top.x + x, y = left_top.y + y} + local pos = { x = left_top.x + x, y = left_top.y + y } local get_tile = surface.get_tile(pos) if is_enemy_territory(surface, pos) then if get_tile.valid and get_tile.name == 'tutorial-grid' then if math_random(1, 1024) == 1 then - if surface.can_place_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) then + if surface.can_place_entity({ name = 'biter-spawner', force = 'decoratives', position = pos }) then local entity if math_random(1, 4) == 1 then - entity = surface.create_entity({name = 'spitter-spawner', force = 'decoratives', position = pos}) + entity = surface.create_entity({ name = 'spitter-spawner', force = 'decoratives', position = pos }) else - entity = surface.create_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) + entity = surface.create_entity({ name = 'biter-spawner', force = 'decoratives', position = pos }) end entity.active = false entity.destructible = false @@ -85,9 +85,9 @@ local function enemy_territory(surface, left_top) end end - for _, entity in pairs(find_entities_filtered({area = area, type = 'resource'})) do + for _, entity in pairs(find_entities_filtered({ area = area, type = 'resource' })) do if is_enemy_territory(surface, entity.position) then - surface.create_entity({name = 'uranium-ore', position = entity.position, amount = math_random(200, 8000)}) + surface.create_entity({ name = 'uranium-ore', position = entity.position, amount = math_random(200, 8000) }) entity.destroy() end end @@ -102,16 +102,16 @@ local function render_market_hp() this.caption = rendering.draw_text { - text = 'Crab Market', - surface = surface, - target = this.market, - target_offset = {0, -3.4}, - color = {0, 255, 0}, - scale = 1.80, - font = 'default-game', - alignment = 'center', - scale_with_zoom = false - } + text = 'Crab Market', + surface = surface, + target = this.market, + target_offset = { 0, -3.4 }, + color = { 0, 255, 0 }, + scale = 1.80, + font = 'default-game', + alignment = 'center', + scale_with_zoom = false + } end local function generate_spawn_area(this, surface) @@ -120,36 +120,36 @@ local function generate_spawn_area(this, surface) end local find_entities_filtered = surface.find_entities_filtered - surface.request_to_generate_chunks({x = 0, y = 0}, 1) - surface.request_to_generate_chunks({x = 32, y = 118}, 1) + surface.request_to_generate_chunks({ x = 0, y = 0 }, 1) + surface.request_to_generate_chunks({ x = 32, y = 118 }, 1) - if not surface.is_chunk_generated({-7, 0}) then + if not surface.is_chunk_generated({ -7, 0 }) then return end - if not surface.is_chunk_generated({5, 0}) then + if not surface.is_chunk_generated({ 5, 0 }) then return end local spawn_position_x = 32 local spawn_position_y = 120 - surface.create_entity({name = 'electric-beam', position = {-532, -10}, source = {-532, -10}, target = {-471, -124}}) - surface.create_entity({name = 'electric-beam', position = {665, -10}, source = {665, -10}, target = {601, -127}}) + surface.create_entity({ name = 'electric-beam', position = { -532, -10 }, source = { -532, -10 }, target = { -471, -124 } }) + surface.create_entity({ name = 'electric-beam', position = { 665, -10 }, source = { 665, -10 }, target = { 601, -127 } }) - for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = {{-145, -133}, {32, 59}}})) do + for _, tile in pairs(surface.find_tiles_filtered({ name = { 'water', 'deepwater' }, area = { { -145, -133 }, { 32, 59 } } })) do local noise = math_abs(simplex_noise(tile.position.x * 0.02, tile.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 16) if tile.position.x > -160 + noise then - surface.set_tiles({{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true) + surface.set_tiles({ { name = get_replacement_tile(surface, tile.position), position = { tile.position.x, tile.position.y } } }, true) end end for _, entity in pairs( find_entities_filtered( { - type = {'resource', 'cliff'}, + type = { 'resource', 'cliff' }, area = { - {spawn_position_x - 128, spawn_position_y - 132}, - {spawn_position_x + 64, spawn_position_y + 32} + { spawn_position_x - 128, spawn_position_y - 132 }, + { spawn_position_x + 64, spawn_position_y + 32 } } } ) @@ -158,33 +158,33 @@ local function generate_spawn_area(this, surface) end local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end end for x = -4, 4, 1 do for y = -3, 3, 1 do - surface.regenerate_decorative(decorative_names, {{x, y}}) + surface.regenerate_decorative(decorative_names, { { x, y } }) end end local ore_positions = { - {x = spawn_position_x - 80, y = spawn_position_y + 50}, - {x = spawn_position_x - 40, y = spawn_position_y + 50}, - {x = spawn_position_x, y = spawn_position_y + 50}, - {x = spawn_position_x + 40, y = spawn_position_y + 50}, - {x = spawn_position_x + 80, y = spawn_position_y + 50} + { x = spawn_position_x - 80, y = spawn_position_y + 50 }, + { x = spawn_position_x - 40, y = spawn_position_y + 50 }, + { x = spawn_position_x, y = spawn_position_y + 50 }, + { x = spawn_position_x + 40, y = spawn_position_y + 50 }, + { x = spawn_position_x + 80, y = spawn_position_y + 50 } } shuffle(ore_positions) map_functions.draw_smoothed_out_ore_circle(ore_positions[1], 'copper-ore', surface, 15, 2500) map_functions.draw_smoothed_out_ore_circle(ore_positions[2], 'iron-ore', surface, 15, 2500) map_functions.draw_smoothed_out_ore_circle(ore_positions[3], 'coal', surface, 15, 1500) map_functions.draw_smoothed_out_ore_circle(ore_positions[4], 'stone', surface, 15, 1500) - map_functions.draw_noise_tile_circle({x = spawn_position_x, y = spawn_position_y + 25}, 'water', surface, 16) + map_functions.draw_noise_tile_circle({ x = spawn_position_x, y = spawn_position_y + 25 }, 'water', surface, 16) map_functions.draw_oil_circle(ore_positions[5], 'crude-oil', surface, 8, 200000) - local pos = surface.find_non_colliding_position('market', {spawn_position_x, spawn_position_y}, 50, 1) + local pos = surface.find_non_colliding_position('market', { spawn_position_x, spawn_position_y }, 50, 1) this.market = place_crab_market(surface, pos) render_market_hp() @@ -194,8 +194,8 @@ local function generate_spawn_area(this, surface) find_entities_filtered( { area = { - {this.market.position.x - r, this.market.position.y - r}, - {this.market.position.x + r, this.market.position.y + r} + { this.market.position.x - r, this.market.position.y - r }, + { this.market.position.x + r, this.market.position.y + r } }, type = 'tree' } @@ -204,33 +204,33 @@ local function generate_spawn_area(this, surface) entity.destroy() end - local turret_pos = surface.find_non_colliding_position('gun-turret', {spawn_position_x, spawn_position_y - 5}, 50, 1) - local turret = surface.create_entity({name = 'gun-turret', position = turret_pos, force = 'player'}) - turret.insert({name = 'firearm-magazine', count = 32}) + local turret_pos = surface.find_non_colliding_position('gun-turret', { spawn_position_x, spawn_position_y - 5 }, 50, 1) + local turret = surface.create_entity({ name = 'gun-turret', position = turret_pos, force = 'player' }) + turret.insert({ name = 'firearm-magazine', count = 32 }) for x = -20, 20, 1 do for y = -20, 20, 1 do - local market_pos = {x = this.market.position.x + x, y = this.market.position.y + y} + local market_pos = { x = this.market.position.x + x, y = this.market.position.y + y } local distance_to_center = x ^ 2 + y ^ 2 if distance_to_center > 64 and distance_to_center < 225 then - if math_random(1, 3) == 1 and surface.can_place_entity({name = 'wooden-chest', position = market_pos, force = 'player'}) then - surface.create_entity({name = 'wooden-chest', position = market_pos, force = 'player'}) + if math_random(1, 3) == 1 and surface.can_place_entity({ name = 'wooden-chest', position = market_pos, force = 'player' }) then + surface.create_entity({ name = 'wooden-chest', position = market_pos, force = 'player' }) end end end end - local area = {{x = -160, y = -96}, {x = 160, y = 96}} - for _, tile in pairs(surface.find_tiles_filtered({name = 'water', area = area})) do + local area = { { x = -160, y = -96 }, { x = 160, y = 96 } } + for _, tile in pairs(surface.find_tiles_filtered({ name = 'water', area = area })) do if math_random(1, 32) == 1 then - surface.create_entity({name = 'fish', position = tile.position}) + surface.create_entity({ name = 'fish', position = tile.position }) end end - local character_pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, spawn_position_y}, 50, 1) + local character_pos = surface.find_non_colliding_position('character', { spawn_position_x + 1, spawn_position_y }, 50, 1) game.forces['player'].set_spawn_position(character_pos, surface) for _, player in pairs(game.connected_players) do - local spawn_pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, spawn_position_y}, 50, 1) + local spawn_pos = surface.find_non_colliding_position('character', { spawn_position_x + 1, spawn_position_y }, 50, 1) player.teleport(spawn_pos, surface) end this.spawn_area_generated = true @@ -250,8 +250,8 @@ local function process_chunk(left_top) for _, entity in pairs( find_entities_filtered( { - area = {{left_top.x - 32, left_top.y - 32}, {left_top.x + 32, left_top.y + 32}}, - type = {'tree', 'simple-entity', 'cliff'} + area = { { left_top.x - 32, left_top.y - 32 }, { left_top.x + 32, left_top.y + 32 } }, + type = { 'tree', 'simple-entity', 'cliff' } } ) ) do @@ -260,7 +260,7 @@ local function process_chunk(left_top) end end - game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}}) + game.forces.player.chart(surface, { { left_top.x, left_top.y }, { left_top.x + 31, left_top.y + 31 } }) if this.market and this.market.valid then this.game_reset = false end diff --git a/maps/deep_jungle/main.lua b/maps/deep_jungle/main.lua index 65b4270e..eb1f1a30 100644 --- a/maps/deep_jungle/main.lua +++ b/maps/deep_jungle/main.lua @@ -14,7 +14,7 @@ local random = math.random local function on_chunk_charted(event) local settings = DPT.get('settings') local surface = game.get_surface(event.surface_index) - local deco = game.decorative_prototypes + local deco = prototypes.decorative local position = event.position if settings.chunks_charted[tostring(position.x) .. tostring(position.y)] then return @@ -27,27 +27,27 @@ local function on_chunk_charted(event) decorative_names[#decorative_names + 1] = k end end - surface.regenerate_decorative(decorative_names, {position}) + surface.regenerate_decorative(decorative_names, { position }) if random(1, 14) ~= 1 then return end - map_functions.draw_rainbow_patch({x = position.x * 32 + random(1, 32), y = position.y * 32 + random(1, 32)}, surface, random(14, 26), 2000) + map_functions.draw_rainbow_patch({ x = position.x * 32 + random(1, 32), y = position.y * 32 + random(1, 32) }, surface, random(14, 26), 2000) end local function on_player_joined_game(event) local player = game.get_player(event.player_index) local surface = game.get_surface('deep_jungle') - if player.online_time < 5 and surface.is_chunk_generated({0, 0}) then - player.teleport(surface.find_non_colliding_position('character', {0, 0}, 2, 1), 'deep_jungle') + if player.online_time < 5 and surface.is_chunk_generated({ 0, 0 }) then + player.teleport(surface.find_non_colliding_position('character', { 0, 0 }, 2, 1), 'deep_jungle') else if player.online_time < 5 then - player.teleport({0, 0}, 'deep_jungle') + player.teleport({ 0, 0 }, 'deep_jungle') end end if player.online_time < 2 then - player.insert {name = 'iron-plate', count = 32} + player.insert { name = 'iron-plate', count = 32 } end end @@ -61,43 +61,43 @@ local function on_entity_died(event) if random(1, 8) == 1 then local p = surface.find_non_colliding_position('small-biter', entity.position, 2, 0.5) if p then - surface.create_entity {name = 'small-biter', position = entity.position} + surface.create_entity { name = 'small-biter', position = entity.position } end return end if random(1, 16) == 1 then local p = surface.find_non_colliding_position('medium-biter', entity.position, 2, 0.5) if p then - surface.create_entity {name = 'medium-biter', position = entity.position} + surface.create_entity { name = 'medium-biter', position = entity.position } end return end if random(1, 32) == 1 then local p = surface.find_non_colliding_position('big-biter', entity.position, 2, 0.5) if p then - surface.create_entity {name = 'big-biter', position = entity.position} + surface.create_entity { name = 'big-biter', position = entity.position } end return end if random(1, 512) == 1 then local p = surface.find_non_colliding_position('behemoth-biter', entity.position, 2, 0.5) if p then - surface.create_entity {name = 'behemoth-biter', position = entity.position} + surface.create_entity { name = 'behemoth-biter', position = entity.position } end return end end if entity.type == 'simple-entity' then if random(1, 8) == 1 then - surface.create_entity {name = 'small-worm-turret', position = entity.position} + surface.create_entity { name = 'small-worm-turret', position = entity.position } return end if random(1, 16) == 1 then - surface.create_entity {name = 'medium-worm-turret', position = entity.position} + surface.create_entity { name = 'medium-worm-turret', position = entity.position } return end if random(1, 32) == 1 then - surface.create_entity {name = 'big-worm-turret', position = entity.position} + surface.create_entity { name = 'big-worm-turret', position = entity.position } return end end @@ -115,7 +115,7 @@ local function chunk_load() end end -local on_tick = function() +local on_tick = function () local tick = game.tick if tick % 40 == 0 then chunk_load() @@ -129,18 +129,18 @@ local function on_init() map_gen_settings.moisture = 0.99 map_gen_settings.water = 'none' map_gen_settings.starting_area = 'normal' - map_gen_settings.cliff_settings = {cliff_elevation_interval = 4, cliff_elevation_0 = 0.1} + map_gen_settings.cliff_settings = { cliff_elevation_interval = 4, cliff_elevation_0 = 0.1 } map_gen_settings.autoplace_controls = { - ['coal'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['stone'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['copper-ore'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['iron-ore'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['crude-oil'] = {frequency = 'very-high', size = 'big', richness = 'normal'}, - ['trees'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['enemy-base'] = {frequency = 'high', size = 'big', richness = 'good'} + ['coal'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['stone'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['copper-ore'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['iron-ore'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['crude-oil'] = { frequency = 'very-high', size = 'big', richness = 'normal' }, + ['trees'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['enemy-base'] = { frequency = 'high', size = 'big', richness = 'good' } } game.create_surface('deep_jungle', map_gen_settings) - game.forces.player.set_spawn_position({0, 0}, game.surfaces['deep_jungle']) + game.forces.player.set_spawn_position({ 0, 0 }, game.surfaces['deep_jungle']) settings.force_chunk = true settings.chunk_load_tick = game.tick + 200 end diff --git a/maps/desert_oasis.lua b/maps/desert_oasis.lua index f232a796..9e441738 100644 --- a/maps/desert_oasis.lua +++ b/maps/desert_oasis.lua @@ -132,7 +132,7 @@ local function on_chunk_generated(event) if get_noise('oasis', entity.position, seed) <= oasis_start then entity.destroy() else - if game.item_prototypes[entity.name] then + if prototypes.item[entity.name] then surface.create_entity( { name = entity.name, position = entity.position, amount = math_random(200, 300) + math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.65 } ) @@ -278,7 +278,7 @@ local function deny_tile_building(surface, inventory, tiles, tile) for _, t in pairs(tiles) do if not save_tiles[t.old_tile.name] then surface.set_tiles({ { name = t.old_tile.name, position = t.position } }, true) - if game.item_prototypes[tile.name] then + if prototypes.item[tile.name] then inventory.insert({ name = tile.name, count = 1 }) else if tile_to_item[tile.name] then diff --git a/maps/expanse/functions.lua b/maps/expanse/functions.lua index 54a44774..522d373b 100644 --- a/maps/expanse/functions.lua +++ b/maps/expanse/functions.lua @@ -193,7 +193,7 @@ function Public.spawn_units(spawner) end function Public.get_item_tooltip(name) - return { 'expanse.stats_item_tooltip', game.item_prototypes[name].localised_name, Price_raffle.get_item_worth(name) } + return { 'expanse.stats_item_tooltip', prototypes.item[name].localised_name, Price_raffle.get_item_worth(name) } end function Public.invasion_numbers() diff --git a/maps/expanse/price_raffle.lua b/maps/expanse/price_raffle.lua index eb3665db..f0ce7409 100644 --- a/maps/expanse/price_raffle.lua +++ b/maps/expanse/price_raffle.lua @@ -236,7 +236,7 @@ function Public.roll_item_stack(remaining_budget, blacklist, value_blacklist) end end - local stack_size = game.item_prototypes[item_name].stack_size * 32 + local stack_size = prototypes.item[item_name].stack_size * 32 local item_count = 1 diff --git a/maps/fish_defender/terrain.lua b/maps/fish_defender/terrain.lua index 61bc22a2..35426e0d 100644 --- a/maps/fish_defender/terrain.lua +++ b/maps/fish_defender/terrain.lua @@ -24,7 +24,7 @@ local rock_raffle = { local function get_replacement_tile(surface, position) for i = 1, 128, 1 do - local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}} + local vectors = { { 0, i }, { 0, i * -1 }, { i, 0 }, { i * -1, 0 } } table.shuffle_table(vectors) for k, v in pairs(vectors) do local tile = surface.get_tile(position.x + v[1], position.y + v[2]) @@ -63,15 +63,15 @@ end local body_radius = 3072 local body_square_radius = body_radius ^ 2 -local body_center_position = {x = -1500, y = 0} +local body_center_position = { x = -1500, y = 0 } local body_spacing = math_floor(body_radius * 0.82) -local body_circle_center_1 = {x = body_center_position.x, y = body_center_position.y - body_spacing} -local body_circle_center_2 = {x = body_center_position.x, y = body_center_position.y + body_spacing} +local body_circle_center_1 = { x = body_center_position.x, y = body_center_position.y - body_spacing } +local body_circle_center_2 = { x = body_center_position.x, y = body_center_position.y + body_spacing } local fin_radius = 800 local square_fin_radius = fin_radius ^ 2 -local fin_circle_center_1 = {x = -480, y = 0} -local fin_circle_center_2 = {x = -480 - 360, y = 0} +local fin_circle_center_1 = { x = -480, y = 0 } +local fin_circle_center_2 = { x = -480 - 360, y = 0 } local function is_body(p) local this = FDT.get() @@ -124,39 +124,39 @@ local function is_out_of_map_tile(p) end local function place_fish_market(surface, position) - local market = surface.create_entity({name = 'market', position = position, force = 'player'}) + local market = surface.create_entity({ name = 'market', position = position, force = 'player' }) market.minable = false return market end local function generate_spawn_area(surface) - surface.request_to_generate_chunks({x = 0, y = 0}, 7) - surface.request_to_generate_chunks({x = 160, y = 0}, 4) + surface.request_to_generate_chunks({ x = 0, y = 0 }, 7) + surface.request_to_generate_chunks({ x = 160, y = 0 }, 4) --surface.force_generate_chunk_requests() local spawn_area_generated = FDT.get('spawn_area_generated') if spawn_area_generated then return end - if not surface.is_chunk_generated({-7, 0}) then + if not surface.is_chunk_generated({ -7, 0 }) then return end - if not surface.is_chunk_generated({5, 0}) then + if not surface.is_chunk_generated({ 5, 0 }) then return end FDT.get().spawn_area_generated = true local spawn_position_x = -128 - surface.create_entity({name = 'electric-beam', position = {160, -96}, source = {160, -96}, target = {160, 96}}) + surface.create_entity({ name = 'electric-beam', position = { 160, -96 }, source = { 160, -96 }, target = { 160, 96 } }) - for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = {{-160, -160}, {160, 160}}})) do + for _, tile in pairs(surface.find_tiles_filtered({ name = { 'water', 'deepwater' }, area = { { -160, -160 }, { 160, 160 } } })) do local noise = math_abs(simplex_noise(tile.position.x * 0.02, tile.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 16) if tile.position.x > -160 + noise then - surface.set_tiles({{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true) + surface.set_tiles({ { name = get_replacement_tile(surface, tile.position), position = { tile.position.x, tile.position.y } } }, true) end end - for _, entity in pairs(surface.find_entities_filtered({type = {'resource', 'cliff'}, area = {{spawn_position_x - 32, -256}, {160, 256}}})) do + for _, entity in pairs(surface.find_entities_filtered({ type = { 'resource', 'cliff' }, area = { { spawn_position_x - 32, -256 }, { 160, 256 } } })) do if is_body(entity.position) then if entity.position.x > spawn_position_x - 32 + math_abs(simplex_noise(entity.position.x * 0.02, entity.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 16) then entity.destroy() @@ -165,34 +165,34 @@ local function generate_spawn_area(surface) end local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end end for x = -4, 4, 1 do for y = -3, 3, 1 do - surface.regenerate_decorative(decorative_names, {{x, y}}) + surface.regenerate_decorative(decorative_names, { { x, y } }) end end local y = 80 local ore_positions = { - {x = spawn_position_x - 52, y = y}, - {x = spawn_position_x - 52, y = y * 0.5}, - {x = spawn_position_x - 52, y = 0}, - {x = spawn_position_x - 52, y = y * -0.5}, - {x = spawn_position_x - 52, y = y * -1} + { x = spawn_position_x - 52, y = y }, + { x = spawn_position_x - 52, y = y * 0.5 }, + { x = spawn_position_x - 52, y = 0 }, + { x = spawn_position_x - 52, y = y * -0.5 }, + { x = spawn_position_x - 52, y = y * -1 } } table.shuffle_table(ore_positions) map_functions.draw_smoothed_out_ore_circle(ore_positions[1], 'copper-ore', surface, 15, 2500) map_functions.draw_smoothed_out_ore_circle(ore_positions[2], 'iron-ore', surface, 15, 2500) map_functions.draw_smoothed_out_ore_circle(ore_positions[3], 'coal', surface, 15, 1500) map_functions.draw_smoothed_out_ore_circle(ore_positions[4], 'stone', surface, 15, 1500) - map_functions.draw_noise_tile_circle({x = spawn_position_x - 20, y = 0}, 'water', surface, 16) + map_functions.draw_noise_tile_circle({ x = spawn_position_x - 20, y = 0 }, 'water', surface, 16) map_functions.draw_oil_circle(ore_positions[5], 'crude-oil', surface, 8, 200000) - local pos = surface.find_non_colliding_position('market', {spawn_position_x, 0}, 50, 1) + local pos = surface.find_non_colliding_position('market', { spawn_position_x, 0 }, 50, 1) FDT.get().market = place_fish_market(surface, pos) local market = FDT.get('market') @@ -201,8 +201,8 @@ local function generate_spawn_area(surface) surface.find_entities_filtered( { area = { - {market.position.x - r, market.position.y - r}, - {market.position.x + r, market.position.y + r} + { market.position.x - r, market.position.y - r }, + { market.position.x + r, market.position.y + r } }, type = 'tree' } @@ -216,35 +216,35 @@ local function generate_spawn_area(surface) end end - local pos = surface.find_non_colliding_position('gun-turret', {spawn_position_x + 5, 1}, 50, 1) - local turret = surface.create_entity({name = 'gun-turret', position = pos, force = 'player'}) - turret.insert({name = 'firearm-magazine', count = 32}) + local pos = surface.find_non_colliding_position('gun-turret', { spawn_position_x + 5, 1 }, 50, 1) + local turret = surface.create_entity({ name = 'gun-turret', position = pos, force = 'player' }) + turret.insert({ name = 'firearm-magazine', count = 32 }) for x = -20, 20, 1 do for y = -20, 20, 1 do - local pos = {x = market.position.x + x, y = market.position.y + y} + local pos = { x = market.position.x + x, y = market.position.y + y } --local distance_to_center = math_sqrt(x^2 + y^2) --if distance_to_center > 8 and distance_to_center < 15 then local distance_to_center = x ^ 2 + y ^ 2 if distance_to_center > 64 and distance_to_center < 225 then - if math_random(1, 3) == 1 and surface.can_place_entity({name = 'wooden-chest', position = pos, force = 'player'}) then - local chest = surface.create_entity({name = 'wooden-chest', position = pos, force = 'player'}) + if math_random(1, 3) == 1 and surface.can_place_entity({ name = 'wooden-chest', position = pos, force = 'player' }) then + local chest = surface.create_entity({ name = 'wooden-chest', position = pos, force = 'player' }) end end end end - local area = {{x = -160, y = -96}, {x = 160, y = 96}} - for _, tile in pairs(surface.find_tiles_filtered({name = 'water', area = area})) do + local area = { { x = -160, y = -96 }, { x = 160, y = 96 } } + for _, tile in pairs(surface.find_tiles_filtered({ name = 'water', area = area })) do if math_random(1, 32) == 1 then - surface.create_entity({name = 'fish', position = tile.position}) + surface.create_entity({ name = 'fish', position = tile.position }) end end - local pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1) + local pos = surface.find_non_colliding_position('character', { spawn_position_x + 1, 4 }, 50, 1) game.forces['player'].set_spawn_position(pos, surface) for _, player in pairs(game.connected_players) do - local pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1) + local pos = surface.find_non_colliding_position('character', { spawn_position_x + 1, 4 }, 50, 1) player.teleport(pos, surface) end end @@ -266,7 +266,7 @@ local function enemy_territory(surface, left_top) return end - local area = {{left_top.x, left_top.y}, {left_top.x + 32, left_top.y + 32}} + local area = { { left_top.x, left_top.y }, { left_top.x + 32, left_top.y + 32 } } --local area = {{160, -512},{750, 512}} --for _, tile in pairs(surface.find_tiles_filtered({area = area})) do @@ -277,47 +277,47 @@ local function enemy_territory(surface, left_top) if left_top.x > 256 then for x = 0, 31, 1 do for y = 0, 31, 1 do - local pos = {x = left_top.x + x, y = left_top.y + y} + local pos = { x = left_top.x + x, y = left_top.y + y } if is_enemy_territory(pos) then if math_random(1, 512) == 1 then - if surface.can_place_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) then + if surface.can_place_entity({ name = 'biter-spawner', force = 'decoratives', position = pos }) then local entity if math_random(1, 4) == 1 then - entity = surface.create_entity({name = 'spitter-spawner', force = 'decoratives', position = pos}) + entity = surface.create_entity({ name = 'spitter-spawner', force = 'decoratives', position = pos }) else - entity = surface.create_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) + entity = surface.create_entity({ name = 'biter-spawner', force = 'decoratives', position = pos }) end entity.active = false entity.destructible = false end end - --if pos.x % 32 == 0 and pos.y % 32 == 0 then - -- local decorative_names = {} - -- for k,v in pairs(game.decorative_prototypes) do - -- if v.autoplace_specification then - -- decorative_names[#decorative_names+1] = k - -- end - -- end - -- surface.regenerate_decorative(decorative_names, {{x=math_floor(pos.x/32),y=math_floor(pos.y/32)}}) - --end + --if pos.x % 32 == 0 and pos.y % 32 == 0 then + -- local decorative_names = {} + -- for k,v in pairs(prototypes.decorative) do + -- if v.autoplace_specification then + -- decorative_names[#decorative_names+1] = k + -- end + -- end + -- surface.regenerate_decorative(decorative_names, {{x=math_floor(pos.x/32),y=math_floor(pos.y/32)}}) + --end end end end end - for _, entity in pairs(surface.find_entities_filtered({area = area, type = {'tree', 'cliff'}})) do + for _, entity in pairs(surface.find_entities_filtered({ area = area, type = { 'tree', 'cliff' } })) do if is_enemy_territory(entity.position) then entity.destroy() end end - for _, entity in pairs(surface.find_entities_filtered({area = area, type = 'resource'})) do + for _, entity in pairs(surface.find_entities_filtered({ area = area, type = 'resource' })) do if is_enemy_territory(entity.position) then - surface.create_entity({name = 'uranium-ore', position = entity.position, amount = math_random(200, 8000)}) + surface.create_entity({ name = 'uranium-ore', position = entity.position, amount = math_random(200, 8000) }) entity.destroy() end end - for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = area})) do + for _, tile in pairs(surface.find_tiles_filtered({ name = { 'water', 'deepwater' }, area = area })) do if is_enemy_territory(tile.position) then - surface.set_tiles({{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true) + surface.set_tiles({ { name = get_replacement_tile(surface, tile.position), position = { tile.position.x, tile.position.y } } }, true) end end end @@ -338,10 +338,10 @@ local function fish_mouth(surface, left_top) for x = 0, 31, 1 do for y = 0, 31, 1 do - local pos = {x = left_top.x + x, y = left_top.y + y} + local pos = { x = left_top.x + x, y = left_top.y + y } local noise = simplex_noise(pos.x * 0.006, 0, game.surfaces[1].map_gen_settings.seed) * 20 if pos.y <= 12 + noise and pos.y >= -12 + noise then - surface.set_tiles({{name = 'water', position = pos}}) + surface.set_tiles({ { name = 'water', position = pos } }) end end end @@ -352,7 +352,7 @@ function Public.fish_eye(surface, position) surface.force_generate_chunk_requests() for x = -48, 48, 1 do for y = -48, 48, 1 do - local p = {x = position.x + x, y = position.y + y} + local p = { x = position.x + x, y = position.y + y } --local distance = math_sqrt(((position.x - p.x) ^ 2) + ((position.y - p.y) ^ 2)) --if distance < 44 then -- surface.set_tiles({{name = "water-green", position = p}}, true) @@ -364,16 +364,16 @@ function Public.fish_eye(surface, position) local distance = ((position.x - p.x) ^ 2) + ((position.y - p.y) ^ 2) if distance < 1936 then if distance < 484 then - surface.set_tiles({{name = 'out-of-map', position = p}}, true) + surface.set_tiles({ { name = 'out-of-map', position = p } }, true) else - surface.set_tiles({{name = 'water-green', position = p}}, true) + surface.set_tiles({ { name = 'water-green', position = p } }, true) end end end end end -local ores = {'coal', 'iron-ore', 'copper-ore', 'stone'} +local ores = { 'coal', 'iron-ore', 'copper-ore', 'stone' } local function plankton_territory(surface, position, seed) local snoise = simplex_noise @@ -391,18 +391,18 @@ local function plankton_territory(surface, position, seed) if noise_2 > 0.75 then local i = math_floor(noise * 6) % 4 + 1 --surface.set_tiles({{name = "grass-" .. i, position = position}}, true) - surface.create_entity({name = ores[i], position = position, amount = 1 + 2500 * math_abs(noise_2 * 3)}) + surface.create_entity({ name = ores[i], position = position, amount = 1 + 2500 * math_abs(noise_2 * 3) }) return ('grass-' .. i) end if noise_2 < -0.76 then local i = math_floor(noise * 6) % 4 + 1 --surface.set_tiles({{name = "grass-" .. i, position = position}}, true) if noise_2 < -0.86 then - surface.create_entity({name = 'uranium-ore', position = position, amount = 1 + 1000 * math_abs(noise_2 * 2)}) + surface.create_entity({ name = 'uranium-ore', position = position, amount = 1 + 1000 * math_abs(noise_2 * 2) }) return ('grass-' .. i) end if math_random(1, 3) ~= 1 then - surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position}) + surface.create_entity({ name = rock_raffle[math_random(1, #rock_raffle)], position = position }) end return ('grass-' .. i) end @@ -411,14 +411,14 @@ local function plankton_territory(surface, position, seed) local i = math_floor(noise * 32) % 4 + 1 --surface.set_tiles({{name = "grass-" .. i, position = position}}, true) if math_random(1, 5) == 1 then - surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position}) + surface.create_entity({ name = rock_raffle[math_random(1, #rock_raffle)], position = position }) end return ('grass-' .. i) end --surface.set_tiles({{name = "water", position = position}}, true) if math_random(1, 128) == 1 then - surface.create_entity({name = 'fish', position = position}) + surface.create_entity({ name = 'fish', position = position }) end return 'water' @@ -443,12 +443,12 @@ local function process_chunk(left_top) for x = 0, 31, 1 do for y = 0, 31, 1 do - local pos = {x = left_top.x + x, y = left_top.y + y} + local pos = { x = left_top.x + x, y = left_top.y + y } if is_out_of_map_tile(pos) then --if not plankton_territory(surface, pos, seed) then surface.set_tiles({{name = "out-of-map", position = pos}}, true) end local tile_to_set = plankton_territory(surface, pos, seed) --local tile_to_set = "out-of-map" - tiles[#tiles + 1] = {name = tile_to_set, position = pos} + tiles[#tiles + 1] = { name = tile_to_set, position = pos } end end end @@ -457,7 +457,7 @@ local function process_chunk(left_top) --if game.tick == 0 then return end --if game.forces.player.is_chunk_charted(surface, {left_top.x / 32, left_top.y / 32}) then - game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}}) + game.forces.player.chart(surface, { { left_top.x, left_top.y }, { left_top.x + 31, left_top.y + 31 } }) --end if market and market.valid then FDT.get().game_reset = false @@ -490,7 +490,7 @@ local function on_chunk_generated(event) if game_has_ended then return end - this.chunk_queue[#this.chunk_queue + 1] = {x = left_top.x, y = left_top.y} + this.chunk_queue[#this.chunk_queue + 1] = { x = left_top.x, y = left_top.y } end end diff --git a/maps/fish_defender_v1/fish_defender.lua b/maps/fish_defender_v1/fish_defender.lua index 4d05d7bb..b64cbe47 100644 --- a/maps/fish_defender_v1/fish_defender.lua +++ b/maps/fish_defender_v1/fish_defender.lua @@ -1377,7 +1377,7 @@ local function on_chunk_generated(event) end local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end @@ -1552,7 +1552,7 @@ local function on_chunk_generated(event) surface.set_tiles(tiles, true) local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/fish_defender_v2/terrain.lua b/maps/fish_defender_v2/terrain.lua index 08a472f5..178322bb 100644 --- a/maps/fish_defender_v2/terrain.lua +++ b/maps/fish_defender_v2/terrain.lua @@ -24,7 +24,7 @@ local size_of_rock_raffle = #rock_raffle local function place_rock(surface, position) local a = (random(-250, 250)) * 0.05 local b = (random(-250, 250)) * 0.05 - surface.create_entity({name = rock_raffle[random(1, size_of_rock_raffle)], position = {position.x + a, position.y + b}}) + surface.create_entity({ name = rock_raffle[random(1, size_of_rock_raffle)], position = { position.x + a, position.y + b } }) end local function shuffle(tbl) @@ -40,7 +40,7 @@ local function resource_placement(surface, position, name, amount, tiles) local w_max = 256 local h_max = 256 - local biases = {[0] = {[0] = 1}} + local biases = { [0] = { [0] = 1 } } local ti = 1 local function grow(grid, t) @@ -48,7 +48,7 @@ local function resource_placement(surface, position, name, amount, tiles) local new_count = 0 for x, _ in pairs(grid) do for y, _ in pairs(_) do - table.insert(old, {x, y}) + table.insert(old, { x, y }) end end for _, pos in pairs(old) do @@ -89,7 +89,7 @@ local function resource_placement(surface, position, name, amount, tiles) name = name, amount = amount * (bias / total_bias), force = 'neutral', - position = {position.x + x, position.y + y} + position = { position.x + x, position.y + y } } end end @@ -97,7 +97,7 @@ end function Public.get_replacement_tile(surface, position) for i = 1, 128, 1 do - local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}} + local vectors = { { 0, i }, { 0, i * -1 }, { i, 0 }, { i * -1, 0 } } shuffle(vectors) for k, v in pairs(vectors) do local tile = surface.get_tile(position.x + v[1], position.y + v[2]) @@ -130,7 +130,7 @@ local function is_enemy_territory(p) end local function place_fish_market(surface, position) - local market = surface.create_entity({name = 'market', position = position, force = 'player'}) + local market = surface.create_entity({ name = 'market', position = position, force = 'player' }) market.minable = false return market @@ -138,303 +138,303 @@ end local enemy_territory_token = Token.register( - function(data) - local surface_index = data.surface_index - local left_top = data.left_top - local surface = game.get_surface(surface_index) - if left_top.x < 256 then - return - end - if left_top.x > 750 then - return - end - if left_top.y > 766 then - return - end - if left_top.y < -256 then - return - end + function (data) + local surface_index = data.surface_index + local left_top = data.left_top + local surface = game.get_surface(surface_index) + if left_top.x < 256 then + return + end + if left_top.x > 750 then + return + end + if left_top.y > 766 then + return + end + if left_top.y < -256 then + return + end - local area = {{left_top.x, left_top.y}, {left_top.x + 32, left_top.y + 32}} + local area = { { left_top.x, left_top.y }, { left_top.x + 32, left_top.y + 32 } } - if left_top.x > 300 then - for x = 0, 31, 1 do - for y = 0, 31, 1 do - local pos = {x = left_top.x + x, y = left_top.y + y} - if is_enemy_territory(pos) then - if random(1, 512) == 1 then - if surface.can_place_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) then - local entity - if random(1, 4) == 1 then - entity = surface.create_entity({name = 'spitter-spawner', force = 'decoratives', position = pos}) - else - entity = surface.create_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) + if left_top.x > 300 then + for x = 0, 31, 1 do + for y = 0, 31, 1 do + local pos = { x = left_top.x + x, y = left_top.y + y } + if is_enemy_territory(pos) then + if random(1, 512) == 1 then + if surface.can_place_entity({ name = 'biter-spawner', force = 'decoratives', position = pos }) then + local entity + if random(1, 4) == 1 then + entity = surface.create_entity({ name = 'spitter-spawner', force = 'decoratives', position = pos }) + else + entity = surface.create_entity({ name = 'biter-spawner', force = 'decoratives', position = pos }) + end + entity.active = false + entity.destructible = false end - entity.active = false - entity.destructible = false end end end end end - end - for _, entity in pairs(surface.find_entities_filtered({area = area, type = {'tree', 'cliff'}})) do - if is_enemy_territory(entity.position) then - entity.destroy() + for _, entity in pairs(surface.find_entities_filtered({ area = area, type = { 'tree', 'cliff' } })) do + if is_enemy_territory(entity.position) then + entity.destroy() + end end - end - for _, entity in pairs(surface.find_entities_filtered({area = area, type = 'resource'})) do - if is_enemy_territory(entity.position) then - surface.create_entity({name = 'uranium-ore', position = entity.position, amount = random(200, 8000)}) - entity.destroy() + for _, entity in pairs(surface.find_entities_filtered({ area = area, type = 'resource' })) do + if is_enemy_territory(entity.position) then + surface.create_entity({ name = 'uranium-ore', position = entity.position, amount = random(200, 8000) }) + entity.destroy() + end end - end - for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = area})) do - if is_enemy_territory(tile.position) then - surface.set_tiles({{name = Public.get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true) - end - end - end -) - -local fish_mouth_token = - Token.register( - function(data) - local surface_index = data.surface_index - local left_top = data.left_top - local surface = game.get_surface(surface_index) - if left_top.x > -1800 then - return - end - if left_top.y > 64 then - return - end - if left_top.y < -64 then - return - end - if left_top.x < -2200 then - return - end - - for x = 0, 31, 1 do - for y = 0, 31, 1 do - local pos = {x = left_top.x + x, y = left_top.y + y} - local noise = simplex_noise(pos.x * 0.006, 0, game.surfaces[1].map_gen_settings.seed) * 20 - if pos.y <= 12 + noise and pos.y >= -12 + noise then - surface.set_tiles({{name = 'water', position = pos}}) + for _, tile in pairs(surface.find_tiles_filtered({ name = { 'water', 'deepwater' }, area = area })) do + if is_enemy_territory(tile.position) then + surface.set_tiles({ { name = Public.get_replacement_tile(surface, tile.position), position = { tile.position.x, tile.position.y } } }, true) end end end - end -) + ) + +local fish_mouth_token = + Token.register( + function (data) + local surface_index = data.surface_index + local left_top = data.left_top + local surface = game.get_surface(surface_index) + if left_top.x > -1800 then + return + end + if left_top.y > 64 then + return + end + if left_top.y < -64 then + return + end + if left_top.x < -2200 then + return + end + + for x = 0, 31, 1 do + for y = 0, 31, 1 do + local pos = { x = left_top.x + x, y = left_top.y + y } + local noise = simplex_noise(pos.x * 0.006, 0, game.surfaces[1].map_gen_settings.seed) * 20 + if pos.y <= 12 + noise and pos.y >= -12 + noise then + surface.set_tiles({ { name = 'water', position = pos } }) + end + end + end + end + ) local request_to_generate_chunks_token = Token.register( - function(data) - local surface_index = data.surface_index - local surface = game.get_surface(surface_index) - local spawn_area_generated = Public.get('spawn_area_generated') - if spawn_area_generated then - return + function (data) + local surface_index = data.surface_index + local surface = game.get_surface(surface_index) + local spawn_area_generated = Public.get('spawn_area_generated') + if spawn_area_generated then + return + end + + surface.request_to_generate_chunks({ 0, 0 }, 8) + + local fish_eye_location = Public.get('fish_eye_location') + + surface.request_to_generate_chunks(fish_eye_location, 2) end - - surface.request_to_generate_chunks({0, 0}, 8) - - local fish_eye_location = Public.get('fish_eye_location') - - surface.request_to_generate_chunks(fish_eye_location, 2) - end -) + ) local function initial_cargo_boxes() return { - {name = 'coal', count = random(32, 64)}, - {name = 'coal', count = random(32, 64)}, - {name = 'coal', count = random(32, 64)}, - {name = 'iron-ore', count = random(32, 128)}, - {name = 'iron-ore', count = random(32, 128)}, - {name = 'iron-ore', count = random(32, 128)}, - {name = 'copper-ore', count = random(32, 128)}, - {name = 'copper-ore', count = random(32, 128)}, - {name = 'copper-ore', count = random(32, 128)}, - {name = 'submachine-gun', count = 1}, - {name = 'submachine-gun', count = 1}, - {name = 'submachine-gun', count = 1}, - {name = 'shotgun', count = 1}, - {name = 'shotgun', count = 1}, - {name = 'shotgun', count = 1}, - {name = 'burner-mining-drill', count = 1}, - {name = 'burner-mining-drill', count = 2}, - {name = 'burner-mining-drill', count = 1}, - {name = 'burner-mining-drill', count = 4}, - {name = 'gun-turret', count = 1}, - {name = 'gun-turret', count = 1}, - {name = 'gun-turret', count = 1}, - {name = 'shotgun-shell', count = random(4, 5)}, - {name = 'shotgun-shell', count = random(4, 5)}, - {name = 'shotgun-shell', count = random(4, 5)}, - {name = 'grenade', count = random(2, 7)}, - {name = 'grenade', count = random(2, 8)}, - {name = 'grenade', count = random(2, 7)}, - {name = 'light-armor', count = random(2, 4)}, - {name = 'iron-gear-wheel', count = random(7, 15)}, - {name = 'iron-gear-wheel', count = random(7, 15)}, - {name = 'iron-gear-wheel', count = random(7, 15)}, - {name = 'iron-gear-wheel', count = random(7, 15)}, - {name = 'iron-plate', count = random(15, 23)}, - {name = 'iron-plate', count = random(15, 23)}, - {name = 'iron-plate', count = random(15, 23)}, - {name = 'iron-plate', count = random(15, 23)}, - {name = 'copper-plate', count = random(15, 23)}, - {name = 'copper-plate', count = random(15, 23)}, - {name = 'copper-plate', count = random(15, 23)}, - {name = 'copper-plate', count = random(15, 23)}, - {name = 'firearm-magazine', count = random(10, 15)}, - {name = 'firearm-magazine', count = random(10, 15)}, - {name = 'firearm-magazine', count = random(10, 15)}, - {name = 'firearm-magazine', count = random(10, 15)} + { name = 'coal', count = random(32, 64) }, + { name = 'coal', count = random(32, 64) }, + { name = 'coal', count = random(32, 64) }, + { name = 'iron-ore', count = random(32, 128) }, + { name = 'iron-ore', count = random(32, 128) }, + { name = 'iron-ore', count = random(32, 128) }, + { name = 'copper-ore', count = random(32, 128) }, + { name = 'copper-ore', count = random(32, 128) }, + { name = 'copper-ore', count = random(32, 128) }, + { name = 'submachine-gun', count = 1 }, + { name = 'submachine-gun', count = 1 }, + { name = 'submachine-gun', count = 1 }, + { name = 'shotgun', count = 1 }, + { name = 'shotgun', count = 1 }, + { name = 'shotgun', count = 1 }, + { name = 'burner-mining-drill', count = 1 }, + { name = 'burner-mining-drill', count = 2 }, + { name = 'burner-mining-drill', count = 1 }, + { name = 'burner-mining-drill', count = 4 }, + { name = 'gun-turret', count = 1 }, + { name = 'gun-turret', count = 1 }, + { name = 'gun-turret', count = 1 }, + { name = 'shotgun-shell', count = random(4, 5) }, + { name = 'shotgun-shell', count = random(4, 5) }, + { name = 'shotgun-shell', count = random(4, 5) }, + { name = 'grenade', count = random(2, 7) }, + { name = 'grenade', count = random(2, 8) }, + { name = 'grenade', count = random(2, 7) }, + { name = 'light-armor', count = random(2, 4) }, + { name = 'iron-gear-wheel', count = random(7, 15) }, + { name = 'iron-gear-wheel', count = random(7, 15) }, + { name = 'iron-gear-wheel', count = random(7, 15) }, + { name = 'iron-gear-wheel', count = random(7, 15) }, + { name = 'iron-plate', count = random(15, 23) }, + { name = 'iron-plate', count = random(15, 23) }, + { name = 'iron-plate', count = random(15, 23) }, + { name = 'iron-plate', count = random(15, 23) }, + { name = 'copper-plate', count = random(15, 23) }, + { name = 'copper-plate', count = random(15, 23) }, + { name = 'copper-plate', count = random(15, 23) }, + { name = 'copper-plate', count = random(15, 23) }, + { name = 'firearm-magazine', count = random(10, 15) }, + { name = 'firearm-magazine', count = random(10, 15) }, + { name = 'firearm-magazine', count = random(10, 15) }, + { name = 'firearm-magazine', count = random(10, 15) } } end local generate_spawn_area_token = Token.register( - function(data) - local surface_index = data.surface_index - local surface = game.get_surface(surface_index) - local spawn_area_generated = Public.get('spawn_area_generated') - if spawn_area_generated then - return - end - - local chunk_load_tick = Public.get('chunk_load_tick') - if chunk_load_tick > game.tick then - if game.tick % 100 == 1 then - game.print('[color=blue][Map Generator][/color] Generating map in progress...') + function (data) + local surface_index = data.surface_index + local surface = game.get_surface(surface_index) + local spawn_area_generated = Public.get('spawn_area_generated') + if spawn_area_generated then + return end - return - end - local spawn_position_x = -128 - - surface.create_entity({name = 'electric-beam', position = {254, -143}, source = {254, -143}, target = {254, 193}}) -- fish - --surface.create_entity({name = 'electric-beam', position = {160, -101}, source = {160, -101}, target = {160, 248}}) -- fish - --surface.create_entity({name = 'electric-beam', position = {160, -88}, source = {160, -88}, target = {160, 185}}) - - for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = {{-300, -256}, {300, 300}}})) do - surface.set_tiles({{name = Public.get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true) - end - - for _, entity in pairs(surface.find_entities_filtered({type = {'resource', 'cliff'}, area = {{-300, -256}, {300, 300}}})) do - entity.destroy() - end - - local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do - if v.autoplace_specification then - decorative_names[#decorative_names + 1] = k + local chunk_load_tick = Public.get('chunk_load_tick') + if chunk_load_tick > game.tick then + if game.tick % 100 == 1 then + game.print('[color=blue][Map Generator][/color] Generating map in progress...') + end + return end - end - for x = -4, 4, 1 do - for y = -3, 3, 1 do - surface.regenerate_decorative(decorative_names, {{x, y}}) + + local spawn_position_x = -128 + + surface.create_entity({ name = 'electric-beam', position = { 254, -143 }, source = { 254, -143 }, target = { 254, 193 } }) -- fish + --surface.create_entity({name = 'electric-beam', position = {160, -101}, source = {160, -101}, target = {160, 248}}) -- fish + --surface.create_entity({name = 'electric-beam', position = {160, -88}, source = {160, -88}, target = {160, 185}}) + + for _, tile in pairs(surface.find_tiles_filtered({ name = { 'water', 'deepwater' }, area = { { -300, -256 }, { 300, 300 } } })) do + surface.set_tiles({ { name = Public.get_replacement_tile(surface, tile.position), position = { tile.position.x, tile.position.y } } }, true) end - end - local _y = 80 - local ore_positions = { - {x = spawn_position_x - 52, y = _y}, - {x = spawn_position_x - 52, y = _y * 0.5}, - {x = spawn_position_x - 52, y = 0}, - {x = spawn_position_x - 52, y = _y * -0.5}, - {x = spawn_position_x - 52, y = _y * -1} - } - shuffle(ore_positions) + for _, entity in pairs(surface.find_entities_filtered({ type = { 'resource', 'cliff' }, area = { { -300, -256 }, { 300, 300 } } })) do + entity.destroy() + end - resource_placement(surface, ore_positions[1], 'copper-ore', 1500000, 650) - resource_placement(surface, ore_positions[2], 'iron-ore', 1500000, 650) - resource_placement(surface, ore_positions[3], 'coal', 1300000, 650) - resource_placement(surface, ore_positions[4], 'stone', 1300000, 650) - - for _ = 0, 10, 1 do - place_rock(surface, ore_positions[4]) --add rocks to stone area - end - - map_functions.draw_noise_tile_circle({x = spawn_position_x - 20, y = 0}, 'water', surface, 16) - map_functions.draw_oil_circle(ore_positions[5], 'crude-oil', surface, 8, 200000) - - local pos = surface.find_non_colliding_position('market', {spawn_position_x, 0}, 50, 1) - local market = Public.set('market', place_fish_market(surface, pos)) - - local r = 16 - for _, entity in pairs( - surface.find_entities_filtered( - { - area = { - {market.position.x - r, market.position.y - r}, - {market.position.x + r, market.position.y + r} - }, - type = 'tree' - } - ) - ) do - local distance_to_center = sqrt((entity.position.x - market.position.x) ^ 2 + (entity.position.y - market.position.y) ^ 2) - if distance_to_center < r then - if random(1, r) > distance_to_center then - entity.destroy() + local decorative_names = {} + for k, v in pairs(prototypes.decorative) do + if v.autoplace_specification then + decorative_names[#decorative_names + 1] = k + end + end + for x = -4, 4, 1 do + for y = -3, 3, 1 do + surface.regenerate_decorative(decorative_names, { { x, y } }) end end - end - local turret_pos = surface.find_non_colliding_position('gun-turret', {spawn_position_x + 5, 1}, 50, 1) - local turret = surface.create_entity({name = 'gun-turret', position = turret_pos, force = 'player'}) - turret.insert({name = 'firearm-magazine', count = 32}) + local _y = 80 + local ore_positions = { + { x = spawn_position_x - 52, y = _y }, + { x = spawn_position_x - 52, y = _y * 0.5 }, + { x = spawn_position_x - 52, y = 0 }, + { x = spawn_position_x - 52, y = _y * -0.5 }, + { x = spawn_position_x - 52, y = _y * -1 } + } + shuffle(ore_positions) - local cargo_boxes = initial_cargo_boxes() + resource_placement(surface, ore_positions[1], 'copper-ore', 1500000, 650) + resource_placement(surface, ore_positions[2], 'iron-ore', 1500000, 650) + resource_placement(surface, ore_positions[3], 'coal', 1300000, 650) + resource_placement(surface, ore_positions[4], 'stone', 1300000, 650) - for x = -20, 20, 1 do - for y = -20, 20, 1 do - local market_pos = {x = market.position.x + x, y = market.position.y + y} - local distance_to_center = x ^ 2 + y ^ 2 - if distance_to_center > 64 and distance_to_center < 225 then - if random(1, 3) == 1 and surface.can_place_entity({name = 'wooden-chest', position = market_pos, force = 'player'}) then - local e = surface.create_entity({name = 'wooden-chest', position = market_pos, force = 'player', create_build_effect_smoke = false}) - if random(1, 8) == 1 then - local inventory = e.get_inventory(defines.inventory.chest) - inventory.insert(cargo_boxes[random(1, #cargo_boxes)]) + for _ = 0, 10, 1 do + place_rock(surface, ore_positions[4]) --add rocks to stone area + end + + map_functions.draw_noise_tile_circle({ x = spawn_position_x - 20, y = 0 }, 'water', surface, 16) + map_functions.draw_oil_circle(ore_positions[5], 'crude-oil', surface, 8, 200000) + + local pos = surface.find_non_colliding_position('market', { spawn_position_x, 0 }, 50, 1) + local market = Public.set('market', place_fish_market(surface, pos)) + + local r = 16 + for _, entity in pairs( + surface.find_entities_filtered( + { + area = { + { market.position.x - r, market.position.y - r }, + { market.position.x + r, market.position.y + r } + }, + type = 'tree' + } + ) + ) do + local distance_to_center = sqrt((entity.position.x - market.position.x) ^ 2 + (entity.position.y - market.position.y) ^ 2) + if distance_to_center < r then + if random(1, r) > distance_to_center then + entity.destroy() + end + end + end + + local turret_pos = surface.find_non_colliding_position('gun-turret', { spawn_position_x + 5, 1 }, 50, 1) + local turret = surface.create_entity({ name = 'gun-turret', position = turret_pos, force = 'player' }) + turret.insert({ name = 'firearm-magazine', count = 32 }) + + local cargo_boxes = initial_cargo_boxes() + + for x = -20, 20, 1 do + for y = -20, 20, 1 do + local market_pos = { x = market.position.x + x, y = market.position.y + y } + local distance_to_center = x ^ 2 + y ^ 2 + if distance_to_center > 64 and distance_to_center < 225 then + if random(1, 3) == 1 and surface.can_place_entity({ name = 'wooden-chest', position = market_pos, force = 'player' }) then + local e = surface.create_entity({ name = 'wooden-chest', position = market_pos, force = 'player', create_build_effect_smoke = false }) + if random(1, 8) == 1 then + local inventory = e.get_inventory(defines.inventory.chest) + inventory.insert(cargo_boxes[random(1, #cargo_boxes)]) + end end end end end - end - local area = {{x = -160, y = -96}, {x = 160, y = 96}} - for _, tile in pairs(surface.find_tiles_filtered({name = 'water', area = area})) do - if random(1, 32) == 1 then - surface.create_entity({name = 'fish', position = tile.position}) + local area = { { x = -160, y = -96 }, { x = 160, y = 96 } } + for _, tile in pairs(surface.find_tiles_filtered({ name = 'water', area = area })) do + if random(1, 32) == 1 then + surface.create_entity({ name = 'fish', position = tile.position }) + end end + + local character_pos = surface.find_non_colliding_position('character', { spawn_position_x + 1, 4 }, 50, 1) + game.forces['player'].set_spawn_position(character_pos, surface) + + for _, player in pairs(game.connected_players) do + local spawn_pos = surface.find_non_colliding_position('character', { spawn_position_x + 1, 4 }, 50, 1) + player.teleport(spawn_pos, surface) + end + + local rr = 200 + local p = { x = -131, y = 5 } + game.forces.player.chart( + surface, + { + { p.x - rr - 100, p.y - rr }, + { p.x + rr + 400, p.y + rr } + } + ) + + Public.set('spawn_area_generated', true) end - - local character_pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1) - game.forces['player'].set_spawn_position(character_pos, surface) - - for _, player in pairs(game.connected_players) do - local spawn_pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1) - player.teleport(spawn_pos, surface) - end - - local rr = 200 - local p = {x = -131, y = 5} - game.forces.player.chart( - surface, - { - {p.x - rr - 100, p.y - rr}, - {p.x + rr + 400, p.y + rr} - } - ) - - Public.set('spawn_area_generated', true) - end -) + ) local function process_chunk(left_top) local active_surface_index = Public.get('active_surface_index') @@ -443,14 +443,14 @@ local function process_chunk(left_top) return end - Task.set_timeout_in_ticks(1, request_to_generate_chunks_token, {surface_index = surface.index}) - Task.set_timeout_in_ticks(15, generate_spawn_area_token, {surface_index = surface.index}) - Task.set_timeout_in_ticks(60, enemy_territory_token, {surface_index = surface.index, left_top = left_top}) - Task.set_timeout_in_ticks(90, fish_mouth_token, {surface_index = surface.index, left_top = left_top}) + Task.set_timeout_in_ticks(1, request_to_generate_chunks_token, { surface_index = surface.index }) + Task.set_timeout_in_ticks(15, generate_spawn_area_token, { surface_index = surface.index }) + Task.set_timeout_in_ticks(60, enemy_territory_token, { surface_index = surface.index, left_top = left_top }) + Task.set_timeout_in_ticks(90, fish_mouth_token, { surface_index = surface.index, left_top = left_top }) local market = Public.get('market') - game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}}) + game.forces.player.chart(surface, { { left_top.x, left_top.y }, { left_top.x + 31, left_top.y + 31 } }) if market and market.valid then Public.set('game_reset', false) end diff --git a/maps/hedge_maze.lua b/maps/hedge_maze.lua index dad57d94..1c089e44 100644 --- a/maps/hedge_maze.lua +++ b/maps/hedge_maze.lua @@ -22,9 +22,9 @@ local modifiers = { } local modifiers_diagonal = { - { diagonal = { x = -1, y = 1 }, connection_1 = { x = -1, y = 0 }, connection_2 = { x = 0, y = 1 } }, - { diagonal = { x = 1, y = -1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = -1 } }, - { diagonal = { x = 1, y = 1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = 1 } }, + { diagonal = { x = -1, y = 1 }, connection_1 = { x = -1, y = 0 }, connection_2 = { x = 0, y = 1 } }, + { diagonal = { x = 1, y = -1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = -1 } }, + { diagonal = { x = 1, y = 1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = 1 } }, { diagonal = { x = -1, y = -1 }, connection_1 = { x = -1, y = 0 }, connection_2 = { x = 0, y = -1 } } } @@ -43,66 +43,66 @@ local wrecks = { 'big-ship-wreck-1', 'big-ship-wreck-2', 'big-ship-wreck-3' } local function create_shipwreck(surface, position) local raffle = {} local loot = { - { { name = 'iron-gear-wheel', count = math_random(80, 100) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'copper-cable', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.1, evolution_max = 0.5 }, - { { name = 'electric-engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.4, evolution_max = 0.8 }, - { { name = 'battery', count = math_random(40, 80) }, weight = 2, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'advanced-circuit', count = math_random(40, 80) }, weight = 3, evolution_min = 0.4, evolution_max = 1 }, - { { name = 'electronic-circuit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, - { { name = 'processing-unit', count = math_random(30, 60) }, weight = 3, evolution_min = 0.7, evolution_max = 1 }, - { { name = 'explosives', count = math_random(25, 50) }, weight = 1, evolution_min = 0.2, evolution_max = 0.6 }, - { { name = 'lubricant-barrel', count = math_random(4, 10) }, weight = 1, evolution_min = 0.3, evolution_max = 0.5 }, - { { name = 'rocket-fuel', count = math_random(4, 10) }, weight = 2, evolution_min = 0.3, evolution_max = 0.7 }, - { { name = 'steel-plate', count = math_random(50, 100) }, weight = 2, evolution_min = 0.1, evolution_max = 0.3 }, - { { name = 'nuclear-fuel', count = 1 }, weight = 2, evolution_min = 0.7, evolution_max = 1 }, - { { name = 'burner-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 }, - { { name = 'inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, - { { name = 'long-handed-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, - { { name = 'fast-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'filter-inserter', count = math_random(4, 8) }, weight = 1, evolution_min = 0.2, evolution_max = 1 }, - { { name = 'stack-filter-inserter', count = math_random(2, 4) }, weight = 1, evolution_min = 0.4, evolution_max = 1 }, - { { name = 'stack-inserter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'small-electric-pole', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'medium-electric-pole', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 1 }, - { { name = 'wooden-chest', count = math_random(16, 24) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 }, - { { name = 'iron-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.1, evolution_max = 0.4 }, - { { name = 'steel-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'small-lamp', count = math_random(8, 16) }, weight = 3, evolution_min = 0.1, evolution_max = 0.3 }, - { { name = 'rail', count = math_random(50, 75) }, weight = 3, evolution_min = 0.1, evolution_max = 0.6 }, - { { name = 'assembling-machine-1', count = math_random(1, 2) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'assembling-machine-2', count = math_random(1, 2) }, weight = 3, evolution_min = 0.2, evolution_max = 0.8 }, - { { name = 'offshore-pump', count = 1 }, weight = 2, evolution_min = 0.0, evolution_max = 0.1 }, - { { name = 'heat-pipe', count = math_random(8, 12) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'arithmetic-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'constant-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'decider-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'power-switch', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'programmable-speaker', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'green-wire', count = math_random(50, 100) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'red-wire', count = math_random(50, 100) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'burner-mining-drill', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 }, - { { name = 'electric-mining-drill', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.6 }, + { { name = 'iron-gear-wheel', count = math_random(80, 100) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'copper-cable', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.1, evolution_max = 0.5 }, + { { name = 'electric-engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.4, evolution_max = 0.8 }, + { { name = 'battery', count = math_random(40, 80) }, weight = 2, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'advanced-circuit', count = math_random(40, 80) }, weight = 3, evolution_min = 0.4, evolution_max = 1 }, + { { name = 'electronic-circuit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, + { { name = 'processing-unit', count = math_random(30, 60) }, weight = 3, evolution_min = 0.7, evolution_max = 1 }, + { { name = 'explosives', count = math_random(25, 50) }, weight = 1, evolution_min = 0.2, evolution_max = 0.6 }, + { { name = 'lubricant-barrel', count = math_random(4, 10) }, weight = 1, evolution_min = 0.3, evolution_max = 0.5 }, + { { name = 'rocket-fuel', count = math_random(4, 10) }, weight = 2, evolution_min = 0.3, evolution_max = 0.7 }, + { { name = 'steel-plate', count = math_random(50, 100) }, weight = 2, evolution_min = 0.1, evolution_max = 0.3 }, + { { name = 'nuclear-fuel', count = 1 }, weight = 2, evolution_min = 0.7, evolution_max = 1 }, + { { name = 'burner-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 }, + { { name = 'inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, + { { name = 'long-handed-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, + { { name = 'fast-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'filter-inserter', count = math_random(4, 8) }, weight = 1, evolution_min = 0.2, evolution_max = 1 }, + { { name = 'stack-filter-inserter', count = math_random(2, 4) }, weight = 1, evolution_min = 0.4, evolution_max = 1 }, + { { name = 'stack-inserter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'small-electric-pole', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'medium-electric-pole', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 1 }, + { { name = 'wooden-chest', count = math_random(16, 24) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 }, + { { name = 'iron-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.1, evolution_max = 0.4 }, + { { name = 'steel-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'small-lamp', count = math_random(8, 16) }, weight = 3, evolution_min = 0.1, evolution_max = 0.3 }, + { { name = 'rail', count = math_random(50, 75) }, weight = 3, evolution_min = 0.1, evolution_max = 0.6 }, + { { name = 'assembling-machine-1', count = math_random(1, 2) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'assembling-machine-2', count = math_random(1, 2) }, weight = 3, evolution_min = 0.2, evolution_max = 0.8 }, + { { name = 'offshore-pump', count = 1 }, weight = 2, evolution_min = 0.0, evolution_max = 0.1 }, + { { name = 'heat-pipe', count = math_random(8, 12) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'arithmetic-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'constant-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'decider-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'power-switch', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'programmable-speaker', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'green-wire', count = math_random(50, 100) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'red-wire', count = math_random(50, 100) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'burner-mining-drill', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 }, + { { name = 'electric-mining-drill', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.6 }, { { name = 'express-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, { { name = 'express-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'express-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'fast-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'fast-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'fast-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.3 }, - { { name = 'transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, - { { name = 'underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, - { { name = 'splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, - { { name = 'pipe', count = math_random(40, 50) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'pipe-to-ground', count = math_random(8, 16) }, weight = 1, evolution_min = 0.2, evolution_max = 0.5 }, - { { name = 'pump', count = math_random(1, 4) }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'rail-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 }, - { { name = 'rail-chain-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 }, - { { name = 'stone-wall', count = math_random(25, 75) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 }, - { { name = 'gate', count = math_random(4, 8) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 }, - { { name = 'train-stop', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'express-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'fast-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.0, evolution_max = 0.5 } + { { name = 'express-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'fast-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'fast-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'fast-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.3 }, + { { name = 'transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, + { { name = 'underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, + { { name = 'splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, + { { name = 'pipe', count = math_random(40, 50) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'pipe-to-ground', count = math_random(8, 16) }, weight = 1, evolution_min = 0.2, evolution_max = 0.5 }, + { { name = 'pump', count = math_random(1, 4) }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'rail-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 }, + { { name = 'rail-chain-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 }, + { { name = 'stone-wall', count = math_random(25, 75) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 }, + { { name = 'gate', count = math_random(4, 8) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 }, + { { name = 'train-stop', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'express-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'fast-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.0, evolution_max = 0.5 } } local distance_to_center = math.sqrt(position.x ^ 2 + position.y ^ 2) @@ -296,7 +296,7 @@ local function on_chunk_generated(event) labyrinth(event) local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/island_troopers/main.lua b/maps/island_troopers/main.lua index 86f97ba1..b66bebfd 100644 --- a/maps/island_troopers/main.lua +++ b/maps/island_troopers/main.lua @@ -223,7 +223,7 @@ local function on_init() surface.force_generate_chunk_requests() --storage.tree_raffle = {} - --for _, e in pairs(game.entity_prototypes) do + --for _, e in pairs(prototypes.entity) do -- if e.type == "tree" then -- table.insert(storage.tree_raffle, e.name) -- end @@ -238,7 +238,7 @@ local function on_init() ['red-desert-decal'] = true } storage.decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if not blacklist[k] then if v.autoplace_specification then storage.decorative_names[#storage.decorative_names + 1] = k diff --git a/maps/journey/functions.lua b/maps/journey/functions.lua index 1373ea4f..031fa39e 100644 --- a/maps/journey/functions.lua +++ b/maps/journey/functions.lua @@ -14,7 +14,7 @@ local math_floor = math.floor local math_abs = math.abs local Public = {} -local mixed_ores = {'copper-ore', 'iron-ore', 'stone', 'coal'} +local mixed_ores = { 'copper-ore', 'iron-ore', 'stone', 'coal' } local function clear_selectors(journey) for k, world_selector in pairs(journey.world_selectors) do @@ -46,35 +46,35 @@ function Public.place_mixed_ore(event, journey) local y = event.area.left_top.y + math_random(0, 31) local base_amount = 1000 + math_sqrt(x ^ 2 + y ^ 2) * 5 local richness = journey.mixed_ore_richness - Map_functions.draw_rainbow_patch({x = x, y = y}, surface, math_random(17, 22), base_amount * richness + 100) + Map_functions.draw_rainbow_patch({ x = x, y = y }, surface, math_random(17, 22), base_amount * richness + 100) end local function place_teleporter(journey, surface, position, build_beacon) local tiles = {} for x = -2, 2, 1 do for y = -2, 2, 1 do - local pos = {x = position.x + x, y = position.y + y} - table.insert(tiles, {name = Constants.teleporter_tile, position = pos}) + local pos = { x = position.x + x, y = position.y + y } + table.insert(tiles, { name = Constants.teleporter_tile, position = pos }) end end surface.set_tiles(tiles, false) - surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x - 1.5, y = position.y - 1.5}, target = {x = position.x + 2.5, y = position.y - 1.0}}) - surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x + 2.5, y = position.y - 1.5}, target = {x = position.x + 2.5, y = position.y + 3.0}}) - surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x + 2.5, y = position.y + 2.5}, target = {x = position.x - 1.5, y = position.y + 3.0}}) - surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x - 1.5, y = position.y + 2.5}, target = {x = position.x - 1.5, y = position.y - 1.0}}) - surface.destroy_decoratives({area = {{position.x - 3, position.y - 3}, {position.x + 3, position.y + 3}}}) + surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x - 1.5, y = position.y - 1.5 }, target = { x = position.x + 2.5, y = position.y - 1.0 } }) + surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x + 2.5, y = position.y - 1.5 }, target = { x = position.x + 2.5, y = position.y + 3.0 } }) + surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x + 2.5, y = position.y + 2.5 }, target = { x = position.x - 1.5, y = position.y + 3.0 } }) + surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x - 1.5, y = position.y + 2.5 }, target = { x = position.x - 1.5, y = position.y - 1.0 } }) + surface.destroy_decoratives({ area = { { position.x - 3, position.y - 3 }, { position.x + 3, position.y + 3 } } }) if build_beacon then - local beacon = surface.create_entity({name = 'beacon', position = {x = position.x, y = position.y}, force = 'player'}) + local beacon = surface.create_entity({ name = 'beacon', position = { x = position.x, y = position.y }, force = 'player' }) journey.beacon_objective_health = 10000 beacon.operable = false beacon.minable = false beacon.active = false rendering.draw_text { - text = {'journey.teleporter'}, + text = { 'journey.teleporter' }, surface = surface, target = beacon, - target_offset = {0, -1.5}, - color = {0, 1, 0}, + target_offset = { 0, -1.5 }, + color = { 0, 1, 0 }, scale = 0.90, font = 'default-game', alignment = 'center', @@ -82,16 +82,16 @@ local function place_teleporter(journey, surface, position, build_beacon) } local hp = rendering.draw_text { - text = {'journey.beacon_hp', journey.beacon_objective_health}, - surface = surface, - target = beacon, - target_offset = {0, -1.0}, - color = {0, 1, 0}, - scale = 0.90, - font = 'default-game', - alignment = 'center', - scale_with_zoom = false - } + text = { 'journey.beacon_hp', journey.beacon_objective_health }, + surface = surface, + target = beacon, + target_offset = { 0, -1.0 }, + color = { 0, 1, 0 }, + scale = 0.90, + font = 'default-game', + alignment = 'center', + scale_with_zoom = false + } journey.beacon_objective = beacon journey.beacon_objective_hp_label = hp end @@ -101,12 +101,12 @@ local function destroy_teleporter(journey, surface, position) local tiles = {} for x = -2, 2, 1 do for y = -2, 2, 1 do - local pos = {x = position.x + x, y = position.y + y} - table.insert(tiles, {name = 'lab-dark-1', position = pos}) + local pos = { x = position.x + x, y = position.y + y } + table.insert(tiles, { name = 'lab-dark-1', position = pos }) end end surface.set_tiles(tiles, true) - for _, e in pairs(surface.find_entities_filtered({name = 'electric-beam-no-sound', area = {{position.x - 3, position.y - 3}, {position.x + 3, position.y + 3}}})) do + for _, e in pairs(surface.find_entities_filtered({ name = 'electric-beam-no-sound', area = { { position.x - 3, position.y - 3 }, { position.x + 3, position.y + 3 } } })) do e.destroy() end end @@ -124,14 +124,14 @@ local function drop_player_items(journey, player) for i = 1, player.crafting_queue_size, 1 do if player.crafting_queue_size > 0 then - player.cancel_crafting {index = 1, count = 99999999} + player.cancel_crafting { index = 1, count = 99999999 } end end local surface = player.surface - local spill_blockage = surface.create_entity {name = 'oil-refinery', position = journey.beacon_objective.position or player.position} + local spill_blockage = surface.create_entity { name = 'oil-refinery', position = journey.beacon_objective.position or player.position } - for _, define in pairs({defines.inventory.character_main, defines.inventory.character_guns, defines.inventory.character_ammo, defines.inventory.character_armor, defines.inventory.character_vehicle, defines.inventory.character_trash}) do + for _, define in pairs({ defines.inventory.character_main, defines.inventory.character_guns, defines.inventory.character_ammo, defines.inventory.character_armor, defines.inventory.character_vehicle, defines.inventory.character_trash }) do local inventory = character.get_inventory(define) if inventory and inventory.valid then for i = 1, #inventory, 1 do @@ -156,7 +156,7 @@ function Public.clear_player(player) return end player.character.destroy() - player.set_controller({type = defines.controllers.god}) + player.set_controller({ type = defines.controllers.god }) player.create_character() player.clear_items_inside() end @@ -182,7 +182,7 @@ end local function set_map_modifiers(journey) local mgs = game.surfaces.nauvis.map_gen_settings - for _, name in pairs({'iron-ore', 'copper-ore', 'uranium-ore', 'coal', 'stone', 'crude-oil'}) do + for _, name in pairs({ 'iron-ore', 'copper-ore', 'uranium-ore', 'coal', 'stone', 'crude-oil' }) do mgs.autoplace_controls[name].richness = calc_modifier(journey, name) mgs.autoplace_controls[name].size = calc_modifier(journey, 'ore_size') mgs.autoplace_controls[name].frequency = calc_modifier(journey, 'ore_frequency') @@ -230,16 +230,16 @@ local function delete_nauvis_chunks(journey) if not journey.nauvis_chunk_positions then journey.nauvis_chunk_positions = {} for chunk in surface.get_chunks() do - table.insert(journey.nauvis_chunk_positions, {chunk.x, chunk.y}) + table.insert(journey.nauvis_chunk_positions, { chunk.x, chunk.y }) end journey.size_of_nauvis_chunk_positions = #journey.nauvis_chunk_positions - for _, e in pairs(surface.find_entities_filtered {type = 'radar'}) do + for _, e in pairs(surface.find_entities_filtered { type = 'radar' }) do e.destroy() end for _, player in pairs(game.players) do - local button = player.gui.top.add({type = 'sprite-button', name = 'chunk_progress', caption = ''}) + local button = player.gui.top.add({ type = 'sprite-button', name = 'chunk_progress', caption = '' }) button.style.font = 'heading-1' - button.style.font_color = {222, 222, 222} + button.style.font_color = { 222, 222, 222 } button.style.minimal_height = 38 button.style.maximal_height = 38 button.style.minimal_width = 240 @@ -261,7 +261,7 @@ local function delete_nauvis_chunks(journey) end end - local caption = {'journey.chunks_delete', journey.size_of_nauvis_chunk_positions} + local caption = { 'journey.chunks_delete', journey.size_of_nauvis_chunk_positions } for _, player in pairs(game.connected_players) do if player.gui.top.chunk_progress then player.gui.top.chunk_progress.caption = caption @@ -276,7 +276,7 @@ function Public.mothership_message_queue(journey) return end if text ~= '' then - game.print({'journey.mothership_format', text}) + game.print({ 'journey.mothership_format', text }) end table.remove(journey.mothership_messages, 1) end @@ -314,17 +314,17 @@ end local function cargo_gui(name, itemname, tooltip, value, hidden) for _, player in pairs(game.connected_players) do if not player.gui.top[name] then - local frame = player.gui.top.add({type = 'frame', name = name}) + local frame = player.gui.top.add({ type = 'frame', name = name }) frame.style.left_margin = 0 frame.style.padding = 0 - local sprite = frame.add({type = 'sprite', sprite = 'item/' .. itemname, name = name .. '_sprite', resize_to_sprite = false}) + local sprite = frame.add({ type = 'sprite', sprite = 'item/' .. itemname, name = name .. '_sprite', resize_to_sprite = false }) sprite.style.minimal_width = 28 sprite.style.minimal_height = 28 sprite.style.maximal_width = 28 sprite.style.maximal_height = 28 sprite.style.margin = 0 sprite.style.padding = 0 - local progressbar = frame.add({type = 'progressbar', name = name .. '_progressbar', value = 0}) + local progressbar = frame.add({ type = 'progressbar', name = name .. '_progressbar', value = 0 }) progressbar.style = 'achievement_progressbar' progressbar.style.minimal_width = 100 progressbar.style.maximal_width = 100 @@ -348,13 +348,13 @@ local function cargo_gui(name, itemname, tooltip, value, hidden) end function Public.update_tooltips(journey) - local modiftt = {''} + local modiftt = { '' } for k, v in pairs(Constants.modifiers) do - modiftt = {'', modiftt, {'journey.tooltip_modifier', v.name, math.round(get_modifier(k, journey) * 100)}} + modiftt = { '', modiftt, { 'journey.tooltip_modifier', v.name, math.round(get_modifier(k, journey) * 100) } } end journey.tooltip_modifiers = modiftt - local capsulett = {''} + local capsulett = { '' } local c = 0 for k, v in pairs(journey.bonus_goods) do local str = ' ' @@ -362,9 +362,9 @@ function Public.update_tooltips(journey) v = string.sub(str, 1, -string.len(v2)) .. v2 c = c + 1 if c % 3 == 0 then - capsulett = {'', capsulett, {'journey.tooltip_capsule2', v, k}} + capsulett = { '', capsulett, { 'journey.tooltip_capsule2', v, k } } else - capsulett = {'', capsulett, {'journey.tooltip_capsule', v, k}} + capsulett = { '', capsulett, { 'journey.tooltip_capsule', v, k } } end end journey.tooltip_capsules = capsulett @@ -373,14 +373,14 @@ end function Public.draw_gui(journey) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings - local caption = {'journey.world', journey.world_number, Constants.unique_world_traits[journey.world_trait].name} - local tooltip = {'journey.world_tooltip', Constants.unique_world_traits[journey.world_trait].desc, journey.tooltip_modifiers, journey.tooltip_capsules} + local caption = { 'journey.world', journey.world_number, Constants.unique_world_traits[journey.world_trait].name } + local tooltip = { 'journey.world_tooltip', Constants.unique_world_traits[journey.world_trait].desc, journey.tooltip_modifiers, journey.tooltip_capsules } for _, player in pairs(game.connected_players) do if not player.gui.top.journey_button then - local element = player.gui.top.add({type = 'sprite-button', name = 'journey_button', caption = ''}) + local element = player.gui.top.add({ type = 'sprite-button', name = 'journey_button', caption = '' }) element.style.font = 'heading-1' - element.style.font_color = {222, 222, 222} + element.style.font_color = { 222, 222, 222 } element.style.minimal_height = 38 element.style.maximal_height = 38 element.style.minimal_width = 250 @@ -398,24 +398,24 @@ function Public.draw_gui(journey) else value = journey.mothership_cargo['uranium-fuel-cell'] / fuel_requirement end - cargo_gui('journey_fuel', 'uranium-fuel-cell', {'journey.tooltip_fuel', fuel_requirement, journey.mothership_cargo['uranium-fuel-cell']}, value) + cargo_gui('journey_fuel', 'uranium-fuel-cell', { 'journey.tooltip_fuel', fuel_requirement, journey.mothership_cargo['uranium-fuel-cell'] }, value) local max_satellites = journey.mothership_cargo_space['satellite'] local value2 = journey.mothership_cargo['satellite'] / max_satellites - cargo_gui('journey_satellites', 'satellite', {'journey.tooltip_satellite', journey.mothership_cargo['satellite'], max_satellites}, value2) + cargo_gui('journey_satellites', 'satellite', { 'journey.tooltip_satellite', journey.mothership_cargo['satellite'], max_satellites }, value2) local max_emergency_fuel = journey.mothership_cargo_space['nuclear-reactor'] local value3 = journey.mothership_cargo['nuclear-reactor'] / max_emergency_fuel - cargo_gui('journey_emergency', 'nuclear-reactor', {'journey.tooltip_nuclear_fuel', journey.mothership_cargo['nuclear-reactor'], max_emergency_fuel}, value3) + cargo_gui('journey_emergency', 'nuclear-reactor', { 'journey.tooltip_nuclear_fuel', journey.mothership_cargo['nuclear-reactor'], max_emergency_fuel }, value3) local item = journey.speedrun.item local time = math.round(journey.speedrun.time / 6) / 10 local speedgoal = journey.mothership_cargo_space[item] or 1 local value4 = (journey.mothership_cargo[item] or 0) / speedgoal if journey.speedrun.enabled then - cargo_gui('journey_delivery', item, {'journey.tooltip_delivery', journey.mothership_cargo[item] or 0, speedgoal, time}, value4) + cargo_gui('journey_delivery', item, { 'journey.tooltip_delivery', journey.mothership_cargo[item] or 0, speedgoal, time }, value4) else - cargo_gui('journey_delivery', item, {'journey.tooltip_delivery', journey.mothership_cargo[item] or 0, speedgoal, time}, value4, true) + cargo_gui('journey_delivery', item, { 'journey.tooltip_delivery', journey.mothership_cargo[item] or 0, speedgoal, time }, value4, true) end end @@ -426,7 +426,7 @@ local function is_mothership(position) if math.abs(position.y) > Constants.mothership_radius then return false end - local p = {x = position.x, y = position.y} + local p = { x = position.x, y = position.y } if p.x > 0 then p.x = p.x + 1 end @@ -446,11 +446,11 @@ function Public.on_mothership_chunk_generated(event) local tiles = {} for x = 0, 31, 1 do for y = 0, 31, 1 do - local position = {x = left_top.x + x, y = left_top.y + y} + local position = { x = left_top.x + x, y = left_top.y + y } if is_mothership(position) then - table.insert(tiles, {name = 'black-refined-concrete', position = position}) + table.insert(tiles, { name = 'black-refined-concrete', position = position }) else - table.insert(tiles, {name = 'out-of-map', position = position}) + table.insert(tiles, { name = 'out-of-map', position = position }) end end end @@ -506,7 +506,7 @@ function Public.restart_server(journey) log('Can force restart only during world selection stages') return end - game.print({'journey.cmd_server_restarting'}, {r = 255, g = 255, b = 0}) + game.print({ 'journey.cmd_server_restarting' }, { r = 255, g = 255, b = 0 }) Public.export_journey(journey, true) Server.start_scenario('Journey') return @@ -514,7 +514,7 @@ end function Public.hard_reset(journey) if journey.restart_from_scenario then - game.print({'journey.cmd_server_restarting'}, {r = 255, g = 255, b = 0}) + game.print({ 'journey.cmd_server_restarting' }, { r = 255, g = 255, b = 0 }) Public.export_journey(journey, false) Server.start_scenario('Journey') return @@ -540,11 +540,11 @@ function Public.hard_reset(journey) game.map_settings.pollution.min_to_diffuse = 75 game.map_settings.pollution.expected_max_per_chunk = 300 - game.map_settings.enemy_expansion.max_expansion_distance = 5 --default 7 - game.map_settings.enemy_expansion.friendly_base_influence_radius = 1 --default 2 - game.map_settings.enemy_expansion.enemy_building_influence_radius = 5 --default 2 - game.map_settings.enemy_expansion.building_coefficient = 0.02 --default 0.1 - game.map_settings.enemy_expansion.neighbouring_chunk_coefficient = 0.25 --defualt 0.5 + game.map_settings.enemy_expansion.max_expansion_distance = 5 --default 7 + game.map_settings.enemy_expansion.friendly_base_influence_radius = 1 --default 2 + game.map_settings.enemy_expansion.enemy_building_influence_radius = 5 --default 2 + game.map_settings.enemy_expansion.building_coefficient = 0.02 --default 0.1 + game.map_settings.enemy_expansion.neighbouring_chunk_coefficient = 0.25 --defualt 0.5 game.map_settings.enemy_expansion.neighbouring_base_chunk_coefficient = 0.25 --default 0.4 local surface = game.surfaces[1] @@ -562,9 +562,9 @@ function Public.hard_reset(journey) end journey.world_selectors = {} - journey.reroll_selector = {activation_level = 0} + journey.reroll_selector = { activation_level = 0 } for i = 1, 3, 1 do - journey.world_selectors[i] = {activation_level = 0, texts = {}} + journey.world_selectors[i] = { activation_level = 0, texts = {} } end journey.mothership_speed = 0.5 journey.characters_in_mothership = 0 @@ -594,7 +594,7 @@ function Public.hard_reset(journey) journey.emergency_triggered = false journey.emergency_selected = false journey.game_state = 'create_mothership' - journey.speedrun = {enabled = false, time = 0, item = 'iron-stick'} + journey.speedrun = { enabled = false, time = 0, item = 'iron-stick' } journey.vote_minimum = 1 journey.mothership_messages_last_damage = game.tick for k, modifier in pairs(Constants.modifiers) do @@ -605,7 +605,7 @@ end function Public.create_mothership(journey) local surface = game.create_surface('mothership', Constants.mothership_gen_settings) - surface.request_to_generate_chunks({x = 0, y = 0}, 6) + surface.request_to_generate_chunks({ x = 0, y = 0 }, 6) surface.force_generate_chunk_requests() surface.freeze_daytime = true journey.game_state = 'draw_mothership' @@ -617,7 +617,7 @@ function Public.draw_mothership(journey) local positions = {} for x = Constants.mothership_radius * -1, Constants.mothership_radius, 1 do for y = Constants.mothership_radius * -1, Constants.mothership_radius, 1 do - local position = {x = x, y = y} + local position = { x = x, y = y } if is_mothership(position) then table.insert(positions, position) end @@ -627,19 +627,19 @@ function Public.draw_mothership(journey) table.shuffle_table(positions) for _, position in pairs(positions) do - if surface.count_tiles_filtered({area = {{position.x - 1, position.y - 1}, {position.x + 2, position.y + 2}}, name = 'out-of-map'}) > 0 then - local e = surface.create_entity({name = 'stone-wall', position = position, force = 'player'}) + if surface.count_tiles_filtered({ area = { { position.x - 1, position.y - 1 }, { position.x + 2, position.y + 2 } }, name = 'out-of-map' }) > 0 then + local e = surface.create_entity({ name = 'stone-wall', position = position, force = 'player' }) protect(e, true) end - if surface.count_tiles_filtered({area = {{position.x - 1, position.y - 1}, {position.x + 2, position.y + 2}}, name = 'lab-dark-1'}) < 4 then - surface.set_tiles({{name = 'lab-dark-1', position = position}}, true) + if surface.count_tiles_filtered({ area = { { position.x - 1, position.y - 1 }, { position.x + 2, position.y + 2 } }, name = 'lab-dark-1' }) < 4 then + surface.set_tiles({ { name = 'lab-dark-1', position = position } }, true) end end for _, tile in pairs( - surface.find_tiles_filtered({area = {{Constants.mothership_teleporter_position.x - 2, Constants.mothership_teleporter_position.y - 2}, {Constants.mothership_teleporter_position.x + 2, Constants.mothership_teleporter_position.y + 2}}}) + surface.find_tiles_filtered({ area = { { Constants.mothership_teleporter_position.x - 2, Constants.mothership_teleporter_position.y - 2 }, { Constants.mothership_teleporter_position.x + 2, Constants.mothership_teleporter_position.y + 2 } } }) ) do - surface.set_tiles({{name = 'lab-dark-1', position = tile.position}}, true) + surface.set_tiles({ { name = 'lab-dark-1', position = tile.position } }, true) end for k, area in pairs(Constants.world_selector_areas) do @@ -647,65 +647,65 @@ function Public.draw_mothership(journey) local position = area.left_top local rectangle = rendering.draw_rectangle { - width = 1, - filled = true, - surface = surface, - left_top = position, - right_bottom = {position.x + Constants.world_selector_width, position.y + Constants.world_selector_height}, - color = Constants.world_selector_colors[k], - draw_on_ground = true, - only_in_alt_mode = false - } + width = 1, + filled = true, + surface = surface, + left_top = position, + right_bottom = { position.x + Constants.world_selector_width, position.y + Constants.world_selector_height }, + color = Constants.world_selector_colors[k], + draw_on_ground = true, + only_in_alt_mode = false + } table.insert(journey.world_selectors[k].rectangles, rectangle) journey.world_selectors[k].border = rendering.draw_rectangle { - width = 8, - filled = false, - surface = surface, - left_top = position, - right_bottom = {position.x + Constants.world_selector_width, position.y + Constants.world_selector_height}, - color = {r = 100, g = 100, b = 100, a = 255}, - draw_on_ground = true, - only_in_alt_mode = false - } + width = 8, + filled = false, + surface = surface, + left_top = position, + right_bottom = { position.x + Constants.world_selector_width, position.y + Constants.world_selector_height }, + color = { r = 100, g = 100, b = 100, a = 255 }, + draw_on_ground = true, + only_in_alt_mode = false + } end journey.reroll_selector.rectangle = rendering.draw_rectangle { - width = 8, - filled = true, - surface = surface, - left_top = Constants.reroll_selector_area.left_top, - right_bottom = Constants.reroll_selector_area.right_bottom, - color = Constants.reroll_selector_area_color, - draw_on_ground = true, - only_in_alt_mode = false - } + width = 8, + filled = true, + surface = surface, + left_top = Constants.reroll_selector_area.left_top, + right_bottom = Constants.reroll_selector_area.right_bottom, + color = Constants.reroll_selector_area_color, + draw_on_ground = true, + only_in_alt_mode = false + } journey.reroll_selector.border = rendering.draw_rectangle { - width = 8, - filled = false, - surface = surface, - left_top = Constants.reroll_selector_area.left_top, - right_bottom = Constants.reroll_selector_area.right_bottom, - color = {r = 100, g = 100, b = 100, a = 255}, - draw_on_ground = true, - only_in_alt_mode = false - } + width = 8, + filled = false, + surface = surface, + left_top = Constants.reroll_selector_area.left_top, + right_bottom = Constants.reroll_selector_area.right_bottom, + color = { r = 100, g = 100, b = 100, a = 255 }, + draw_on_ground = true, + only_in_alt_mode = false + } - for k, item_name in pairs({'arithmetic-combinator', 'constant-combinator', 'decider-combinator', 'programmable-speaker', 'red-wire', 'green-wire', 'small-lamp', 'substation', 'pipe', 'gate', 'stone-wall', 'transport-belt'}) do - local chest = surface.create_entity({name = 'infinity-chest', position = {-7 + k, Constants.mothership_radius - 3}, force = 'player'}) - chest.set_infinity_container_filter(1, {name = item_name, count = game.item_prototypes[item_name].stack_size}) + for k, item_name in pairs({ 'arithmetic-combinator', 'constant-combinator', 'decider-combinator', 'programmable-speaker', 'red-wire', 'green-wire', 'small-lamp', 'substation', 'pipe', 'gate', 'stone-wall', 'transport-belt' }) do + local chest = surface.create_entity({ name = 'infinity-chest', position = { -7 + k, Constants.mothership_radius - 3 }, force = 'player' }) + chest.set_infinity_container_filter(1, { name = item_name, count = prototypes.item[item_name].stack_size }) protect(chest, false) - local loader = surface.create_entity({name = 'express-loader', position = {-7 + k, Constants.mothership_radius - 4}, force = 'player'}) + local loader = surface.create_entity({ name = 'express-loader', position = { -7 + k, Constants.mothership_radius - 4 }, force = 'player' }) protect(loader, true) loader.direction = 4 end for m = -1, 1, 2 do - local inter = surface.create_entity({name = 'electric-energy-interface', position = {11 * m, Constants.mothership_radius - 4}, force = 'player'}) + local inter = surface.create_entity({ name = 'electric-energy-interface', position = { 11 * m, Constants.mothership_radius - 4 }, force = 'player' }) protect(inter, true) - local sub = surface.create_entity({name = 'substation', position = {9 * m, Constants.mothership_radius - 4}, force = 'player'}) + local sub = surface.create_entity({ name = 'substation', position = { 9 * m, Constants.mothership_radius - 4 }, force = 'player' }) protect(sub, true) end @@ -715,21 +715,21 @@ function Public.draw_mothership(journey) x = x - 1 end local y = Constants.mothership_radius * 0.5 - 7 - local turret = surface.create_entity({name = 'artillery-turret', position = {x * m, y}, force = 'player'}) + local turret = surface.create_entity({ name = 'artillery-turret', position = { x * m, y }, force = 'player' }) turret.direction = 4 protect(turret, false) - local ins = surface.create_entity({name = 'burner-inserter', position = {(x - 1) * m, y}, force = 'player'}) + local ins = surface.create_entity({ name = 'burner-inserter', position = { (x - 1) * m, y }, force = 'player' }) ins.direction = 4 + m * 2 ins.rotatable = false protect(ins, false) - local chest = surface.create_entity({name = 'infinity-chest', position = {(x - 2) * m, y}, force = 'player'}) - chest.set_infinity_container_filter(1, {name = 'solid-fuel', count = 50}) - chest.set_infinity_container_filter(2, {name = 'artillery-shell', count = 1}) + local chest = surface.create_entity({ name = 'infinity-chest', position = { (x - 2) * m, y }, force = 'player' }) + chest.set_infinity_container_filter(1, { name = 'solid-fuel', count = 50 }) + chest.set_infinity_container_filter(2, { name = 'artillery-shell', count = 1 }) protect(chest, false) end for _ = 1, 3, 1 do - local comp = surface.create_entity({name = 'compilatron', position = Constants.mothership_teleporter_position, force = 'player'}) + local comp = surface.create_entity({ name = 'compilatron', position = Constants.mothership_teleporter_position, force = 'player' }) comp.destructible = false end Public.draw_gui(journey) @@ -743,7 +743,7 @@ function Public.teleport_players_to_mothership(journey) for _, player in pairs(game.connected_players) do if player.surface.name ~= 'mothership' then Public.clear_player(player) - player.teleport(surface.find_non_colliding_position('character', {0, 0}, 32, 0.5), surface) + player.teleport(surface.find_non_colliding_position('character', { 0, 0 }, 32, 0.5), surface) journey.characters_in_mothership = journey.characters_in_mothership + 1 table.insert(journey.mothership_messages, 'Welcome home ' .. player.name .. '!') return @@ -767,12 +767,12 @@ function Public.set_minimum_to_vote(journey) end local surface = game.surfaces.mothership if #game.connected_players <= journey.vote_minimum and surface and surface.daytime <= 0.5 then - table.insert(journey.mothership_messages, {'journey.message_min_players', journey.vote_minimum}) + table.insert(journey.mothership_messages, { 'journey.message_min_players', journey.vote_minimum }) end end local function get_activation_level(journey, surface, area) - local player_count_in_area = surface.count_entities_filtered({area = area, name = 'character'}) + local player_count_in_area = surface.count_entities_filtered({ area = area, name = 'character' }) local player_count_for_max_activation = math.max(#game.connected_players, journey.vote_minimum) * (2 / 3) local level = player_count_in_area / player_count_for_max_activation level = math.round(level, 2) @@ -790,7 +790,7 @@ local function animate_selectors(journey) end for _, rectangle in pairs(world_selector.rectangles) do local color = Constants.world_selector_colors[k] - rendering.set_color(rectangle, {r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255}) + rendering.set_color(rectangle, { r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255 }) end end local activation_level = journey.reroll_selector.activation_level @@ -801,7 +801,7 @@ local function animate_selectors(journey) activation_level = 1 end local color = Constants.reroll_selector_area_color - rendering.set_color(journey.reroll_selector.rectangle, {r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255}) + rendering.set_color(journey.reroll_selector.rectangle, { r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255 }) end local function draw_background(journey, surface) @@ -811,23 +811,23 @@ local function draw_background(journey, surface) local speed = journey.mothership_speed for c = 1, 16 * speed, 1 do local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)] - surface.create_entity({name = 'shotgun-pellet', position = position, target = {position[1], position[2] + Constants.mothership_radius * 2}, speed = speed}) + surface.create_entity({ name = 'shotgun-pellet', position = position, target = { position[1], position[2] + Constants.mothership_radius * 2 }, speed = speed }) end for c = 1, 16 * speed, 1 do local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)] - surface.create_entity({name = 'piercing-shotgun-pellet', position = position, target = {position[1], position[2] + Constants.mothership_radius * 2}, speed = speed}) + surface.create_entity({ name = 'piercing-shotgun-pellet', position = position, target = { position[1], position[2] + Constants.mothership_radius * 2 }, speed = speed }) end for c = 1, 2 * speed, 1 do local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)] - surface.create_entity({name = 'cannon-projectile', position = position, target = {position[1], position[2] + Constants.mothership_radius * 2}, speed = speed}) + surface.create_entity({ name = 'cannon-projectile', position = position, target = { position[1], position[2] + Constants.mothership_radius * 2 }, speed = speed }) end for c = 1, 1 * speed, 1 do local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)] - surface.create_entity({name = 'uranium-cannon-projectile', position = position, target = {position[1], position[2] + Constants.mothership_radius * 2}, speed = speed}) + surface.create_entity({ name = 'uranium-cannon-projectile', position = position, target = { position[1], position[2] + Constants.mothership_radius * 2 }, speed = speed }) end if math.random(1, 32) == 1 then local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)] - surface.create_entity({name = 'explosive-uranium-cannon-projectile', position = position, target = {position[1], position[2] + Constants.mothership_radius * 3}, speed = speed}) + surface.create_entity({ name = 'explosive-uranium-cannon-projectile', position = position, target = { position[1], position[2] + Constants.mothership_radius * 3 }, speed = speed }) end if math.random(1, 90) == 1 then local position_x = math.random(64, 160) @@ -838,7 +838,7 @@ local function draw_background(journey, surface) if math.random(1, 2) == 1 then position_y = position_y * -1 end - surface.create_entity({name = 'big-worm-turret', position = {position_x, position_y}, force = 'enemy'}) + surface.create_entity({ name = 'big-worm-turret', position = { position_x, position_y }, force = 'enemy' }) end end @@ -850,7 +850,7 @@ local function roll_bonus_goods(journey, trait, amount) local loot_table = Constants.starter_goods_pool[key] if #bonus_goods < (amount or 3) and math.random(numbers[1], numbers[2]) >= 1 then local item = loot_table[math.random(1, #loot_table)] - bonus_goods[#bonus_goods + 1] = {item[1], math.random(item[2], item[3])} + bonus_goods[#bonus_goods + 1] = { item[1], math.random(item[2], item[3]) } end end end @@ -864,8 +864,8 @@ function Public.set_world_selectors(journey) rendering.draw_text { text = journey.mothership_cargo.satellite .. ' x ', surface = surface, - target = {x, Constants.reroll_selector_area.left_top.y - 1.5}, - color = {255, 255, 255, 255}, + target = { x, Constants.reroll_selector_area.left_top.y - 1.5 }, + color = { 255, 255, 255, 255 }, scale = 1.5, font = 'default-large-bold', alignment = 'center', @@ -876,7 +876,7 @@ function Public.set_world_selectors(journey) surface = surface, y_scale = 1.5, x_scale = 1.5, - target = {x + 1.6, Constants.reroll_selector_area.left_top.y - 1} + target = { x + 1.6, Constants.reroll_selector_area.left_top.y - 1 } } } @@ -905,8 +905,8 @@ function Public.set_world_selectors(journey) local texts = world_selector.texts local modifiers = world_selector.modifiers local y_modifier = -11.3 - local limits = {6, Constants.unique_world_traits[world_selector.world_trait].mods} - local counts = {0, 0} + local limits = { 6, Constants.unique_world_traits[world_selector.world_trait].mods } + local counts = { 0, 0 } local i = 1 if journey.importing then goto skip_reroll @@ -920,35 +920,35 @@ function Public.set_world_selectors(journey) --at max, so we lower it as a positive modifier v = math.floor(math.random(data.dmin, data.dmax) * -0.5) counts[2] = counts[2] + 1 - modifiers[i] = {name = modifier, value = v, neg = false} + modifiers[i] = { name = modifier, value = v, neg = false } elseif data.dmin < 0 and counts[1] < limits[1] then --at max, but it is good modifier, so lower it as negative modifier v = math.floor(math.random(data.dmin, data.dmax)) counts[1] = counts[1] + 1 - modifiers[i] = {name = modifier, value = v, neg = true} + modifiers[i] = { name = modifier, value = v, neg = true } end elseif journey.world_modifiers[modifier] <= data.min then if data.dmin < 0 and counts[1] < limits[1] then --at min, but good to have it min, so we grow it as negative modifier v = math.floor(math.random(data.dmin, data.dmax)) counts[1] = counts[1] + 1 - modifiers[i] = {name = modifier, value = v, neg = true} + modifiers[i] = { name = modifier, value = v, neg = true } elseif data.dmin > 0 and counts[2] < limits[2] then --at min, but min is bad, so we grow it as positive modifier v = math.floor(math.random(data.dmin, data.dmax) * -0.5) counts[2] = counts[2] + 1 - modifiers[i] = {name = modifier, value = v, neg = false} + modifiers[i] = { name = modifier, value = v, neg = false } end else --somewhere in middle, we first try to fill the positives then negatives. table is shuffled so it should be fine if counts[2] < limits[2] then v = math.floor(math.random(data.dmin, data.dmax) * -0.5) counts[2] = counts[2] + 1 - modifiers[i] = {name = modifier, value = v, neg = false} + modifiers[i] = { name = modifier, value = v, neg = false } elseif counts[1] < limits[1] then v = math.floor(math.random(data.dmin, data.dmax)) counts[1] = counts[1] + 1 - modifiers[i] = {name = modifier, value = v, neg = true} + modifiers[i] = { name = modifier, value = v, neg = true } end end i = i + 1 @@ -961,8 +961,8 @@ function Public.set_world_selectors(journey) rendering.draw_text { text = Constants.unique_world_traits[world_selector.world_trait].name, surface = surface, - target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier}, - color = {100, 0, 255, 255}, + target = { position.x + Constants.world_selector_width * 0.5, position.y + y_modifier }, + color = { 100, 0, 255, 255 }, scale = 1.25, font = 'default-large-bold', alignment = 'center', @@ -981,9 +981,9 @@ function Public.set_world_selectors(journey) local color if modifier.neg then - color = {200, 0, 0, 255} + color = { 200, 0, 0, 255 } else - color = {0, 200, 0, 255} + color = { 0, 200, 0, 255 } end table.insert( @@ -991,7 +991,7 @@ function Public.set_world_selectors(journey) rendering.draw_text { text = text, surface = surface, - target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier}, + target = { position.x + Constants.world_selector_width * 0.5, position.y + y_modifier }, color = color, scale = 1.25, font = 'default-large', @@ -1007,8 +1007,8 @@ function Public.set_world_selectors(journey) rendering.draw_text { text = 'Fuel requirement +' .. world_selector.fuel_requirement, surface = surface, - target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier}, - color = {155, 155, 0, 255}, + target = { position.x + Constants.world_selector_width * 0.5, position.y + y_modifier }, + color = { 155, 155, 0, 255 }, scale = 1.25, font = 'default-large', alignment = 'center', @@ -1020,7 +1020,7 @@ function Public.set_world_selectors(journey) rendering.draw_sprite { sprite = 'item/uranium-fuel-cell', surface = surface, - target = {position.x + Constants.world_selector_width * 0.5 + 3.7, position.y + y_modifier + 0.5} + target = { position.x + Constants.world_selector_width * 0.5 + 3.7, position.y + y_modifier + 0.5 } } ) @@ -1030,15 +1030,15 @@ function Public.set_world_selectors(journey) for k2, good in pairs(world_selector.bonus_goods) do local render_id = rendering.draw_text { - text = '+' .. good[2], - surface = surface, - target = {position.x + x_modifier, position.y + y_modifier}, - color = {200, 200, 0, 255}, - scale = 1.25, - font = 'default-large', - alignment = 'center', - scale_with_zoom = false - } + text = '+' .. good[2], + surface = surface, + target = { position.x + x_modifier, position.y + y_modifier }, + color = { 200, 200, 0, 255 }, + scale = 1.25, + font = 'default-large', + alignment = 'center', + scale_with_zoom = false + } table.insert(texts, render_id) x_modifier = x_modifier + 0.95 @@ -1051,10 +1051,10 @@ function Public.set_world_selectors(journey) local render_id = rendering.draw_sprite { - sprite = 'item/' .. good[1], - surface = surface, - target = {position.x + x_modifier, position.y + 0.5 + y_modifier} - } + sprite = 'item/' .. good[1], + surface = surface, + target = { position.x + x_modifier, position.y + 0.5 + y_modifier } + } table.insert(texts, render_id) x_modifier = x_modifier + 1.70 @@ -1271,7 +1271,7 @@ function Public.create_the_world(journey) for _, modifier in pairs(modifiers) do local m = (100 + modifier.value) * 0.01 local name = modifier.name - local extremes = {Constants.modifiers[name].min, Constants.modifiers[name].max} + local extremes = { Constants.modifiers[name].min, Constants.modifiers[name].max } journey.world_modifiers[name] = math.round(math.min(extremes[2], math.max(extremes[1], journey.world_modifiers[name] * m)) * 100000, 5) / 100000 end surface.map_gen_settings = mgs @@ -1307,7 +1307,7 @@ function Public.create_the_world(journey) end journey.goods_to_dispatch = {} for k, v in pairs(journey.bonus_goods) do - table.insert(journey.goods_to_dispatch, {k, v}) + table.insert(journey.goods_to_dispatch, { k, v }) end table.shuffle_table(journey.goods_to_dispatch) Public.update_tooltips(journey) @@ -1388,7 +1388,7 @@ end function Public.place_teleporter_into_world(journey) local surface = game.surfaces.nauvis - surface.request_to_generate_chunks({x = 0, y = 0}, 3) + surface.request_to_generate_chunks({ x = 0, y = 0 }, 3) surface.force_generate_chunk_requests() place_teleporter(journey, surface, Constants.mothership_teleporter_position, true) journey.game_state = 'make_it_night' @@ -1439,7 +1439,7 @@ function Public.dispatch_goods(journey) if journey.dispatch_beacon_position then local good = goods_to_dispatch[journey.dispatch_key] - surface.spill_item_stack(journey.dispatch_beacon_position, {name = good[1], count = good[2]}, true, nil, false) + surface.spill_item_stack(journey.dispatch_beacon_position, { name = good[1], count = good[2] }, true, nil, false) table.remove(journey.goods_to_dispatch, journey.dispatch_key) journey.dispatch_beacon = nil journey.dispatch_beacon_position = nil @@ -1452,15 +1452,15 @@ function Public.dispatch_goods(journey) return end - local position = {x = chunk.x * 32 + math.random(0, 31), y = chunk.y * 32 + math.random(0, 31)} + local position = { x = chunk.x * 32 + math.random(0, 31), y = chunk.y * 32 + math.random(0, 31) } position = surface.find_non_colliding_position('rocket-silo', position, 32, 1) if not position then return end - journey.dispatch_beacon = surface.create_entity({name = 'stone-wall', position = position, force = 'neutral'}) + journey.dispatch_beacon = surface.create_entity({ name = 'stone-wall', position = position, force = 'neutral' }) journey.dispatch_beacon.minable = false - journey.dispatch_beacon_position = {x = position.x, y = position.y} + journey.dispatch_beacon_position = { x = position.x, y = position.y } journey.dispatch_key = math.random(1, size_of_goods_to_dispatch) local good = goods_to_dispatch[journey.dispatch_key] @@ -1469,7 +1469,7 @@ function Public.dispatch_goods(journey) Server.to_discord_embed('A capsule containing ' .. good[2] .. 'x ' .. good[1] .. ' was spotted at: x=' .. position.x .. ', y=' .. position.y .. '!') end - surface.create_entity({name = 'artillery-projectile', position = {x = position.x - 256 + math.random(0, 512), y = position.y - 256}, target = position, speed = 0.2}) + surface.create_entity({ name = 'artillery-projectile', position = { x = position.x - 256 + math.random(0, 512), y = position.y - 256 }, target = position, speed = 0.2 }) end function Public.world(journey) @@ -1486,7 +1486,7 @@ function Public.world(journey) local time = math.round(journey.speedrun.time / 6) / 10 if journey.mothership_cargo[item] and journey.mothership_cargo[item] >= journey.mothership_cargo_space[item] then local amount = 6 - local brackets = {120, 120, 240, 480, 960, 1920} + local brackets = { 120, 120, 240, 480, 960, 1920 } local timer = time for i = 1, 6, 1 do if timer >= brackets[i] then @@ -1496,8 +1496,8 @@ function Public.world(journey) break end end - table.insert(journey.mothership_messages, {'journey.message_delivery_done', item, time, amount}) - Server.to_discord_embed({'journey.message_delivery_done', item, time, amount}, true) + table.insert(journey.mothership_messages, { 'journey.message_delivery_done', item, time, amount }) + Server.to_discord_embed({ 'journey.message_delivery_done', item, time, amount }, true) local bonus_goods = roll_bonus_goods(journey, 'resupply_station', amount) for _, good in pairs(bonus_goods) do if journey.bonus_goods[good[1]] then @@ -1505,7 +1505,7 @@ function Public.world(journey) else journey.bonus_goods[good[1]] = good[2] end - table.insert(journey.mothership_messages, {'journey.message_delivered', good[1], good[2]}) + table.insert(journey.mothership_messages, { 'journey.message_delivered', good[1], good[2] }) end Public.update_tooltips(journey) journey.speedrun.enabled = false @@ -1515,7 +1515,7 @@ function Public.world(journey) time = math.round(journey.speedrun.time / 6) / 10 local speedgoal = journey.mothership_cargo_space[item] or 1 local value = (journey.mothership_cargo[item] or 0) / speedgoal - cargo_gui('journey_delivery', item, {'journey.tooltip_delivery', journey.mothership_cargo[item] or 0, speedgoal, time}, value) + cargo_gui('journey_delivery', item, { 'journey.tooltip_delivery', journey.mothership_cargo[item] or 0, speedgoal, time }, value) end end @@ -1533,9 +1533,9 @@ function Public.world(journey) local name = slot.name local count = slot.count local needs = (journey.mothership_cargo_space[name] or 0) - (journey.mothership_cargo[name] or 0) - if needs > 0 and count >= math.min(game.item_prototypes[name].stack_size, needs) then + if needs > 0 and count >= math.min(prototypes.item[name].stack_size, needs) then if silo.launch_rocket() then - table.insert(journey.mothership_messages, {'journey.message_rocket_launched', count, name, silo.position.x, silo.position.y}) + table.insert(journey.mothership_messages, { 'journey.message_rocket_launched', count, name, silo.position.x, silo.position.y }) end end end @@ -1571,7 +1571,7 @@ function Public.teleporters(journey, player) if tile.name ~= Constants.teleporter_tile and tile.hidden_tile ~= Constants.teleporter_tile then return end - local base_position = {0, 0} + local base_position = { 0, 0 } if surface.index == 1 then drop_player_items(journey, player) local position = game.surfaces.mothership.find_non_colliding_position('character', base_position, 32, 0.5) @@ -1603,7 +1603,7 @@ function Public.deal_damage_to_beacon(journey, incoming_damage) end local resistance = journey.beacon_objective_resistance journey.beacon_objective_health = math.floor(journey.beacon_objective_health - (incoming_damage * (1 - resistance))) - rendering.set_text(journey.beacon_objective_hp_label, {'journey.beacon_hp', journey.beacon_objective_health}) + rendering.set_text(journey.beacon_objective_hp_label, { 'journey.beacon_hp', journey.beacon_objective_health }) if journey.beacon_objective_health < 5000 and game.tick > journey.mothership_messages_last_damage + 900 then --under 50%, once every 15 seconds max table.insert(journey.mothership_messages, 'The personal teleporter is being damaged, preparing for emergency departure.') journey.mothership_messages_last_damage = game.tick @@ -1633,10 +1633,10 @@ function Public.lure_biters(journey, position) end local beacon = journey.beacon_objective local surface = beacon.surface - local biters = surface.find_entities_filtered {position = position or beacon.position, radius = 80, force = 'enemy', type = 'unit'} + local biters = surface.find_entities_filtered { position = position or beacon.position, radius = 80, force = 'enemy', type = 'unit' } if #biters > 0 then for _, biter in pairs(biters) do - biter.set_command({type = defines.command.attack_area, destination = beacon.position, radius = 10, distraction = defines.distraction.by_anything}) + biter.set_command({ type = defines.command.attack_area, destination = beacon.position, radius = 10, distraction = defines.distraction.by_anything }) end end --return (#biters or 0) diff --git a/maps/journey/unique_modifiers.lua b/maps/journey/unique_modifiers.lua index d9ebb4c4..6aaef5ee 100644 --- a/maps/journey/unique_modifiers.lua +++ b/maps/journey/unique_modifiers.lua @@ -6,7 +6,7 @@ local math_random = math.random local math_abs = math.abs local math_floor = math.floor local math_sqrt = math.sqrt -local rock_raffle = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'} +local rock_raffle = { 'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge' } local size_of_rock_raffle = #rock_raffle local ore_raffle = {} for i = 1, 25, 1 do @@ -73,24 +73,24 @@ local Public = {} Public.lush = {} Public.eternal_day = { - on_world_start = function(journey) + on_world_start = function (journey) game.surfaces.nauvis.daytime = 0 game.surfaces.nauvis.freeze_daytime = true end, - clear = function(journey) + clear = function (journey) local surface = game.surfaces.nauvis surface.freeze_daytime = false end } Public.eternal_night = { - on_world_start = function(journey) + on_world_start = function (journey) local surface = game.surfaces.nauvis surface.daytime = 0.44 surface.freeze_daytime = true surface.solar_power_multiplier = 5 end, - clear = function(journey) + clear = function (journey) local surface = game.surfaces.nauvis surface.freeze_daytime = false surface.solar_power_multiplier = 1 @@ -98,25 +98,25 @@ Public.eternal_night = { } Public.pitch_black = { - on_world_start = function(journey) + on_world_start = function (journey) local surface = game.surfaces.nauvis surface.daytime = 0.44 surface.freeze_daytime = true surface.solar_power_multiplier = 3 surface.min_brightness = 0 - surface.brightness_visual_weights = {0.8, 0.8, 0.8, 1} + surface.brightness_visual_weights = { 0.8, 0.8, 0.8, 1 } end, - clear = function(journey) + clear = function (journey) local surface = game.surfaces.nauvis surface.freeze_daytime = false surface.solar_power_multiplier = 1 surface.min_brightness = 0.15 - surface.brightness_visual_weights = {0, 0, 0, 1} + surface.brightness_visual_weights = { 0, 0, 0, 1 } end } Public.matter_anomaly = { - on_world_start = function(journey) + on_world_start = function (journey) local force = game.forces.player for i = 1, 4, 1 do force.technologies['mining-productivity-' .. i].researched = true @@ -125,7 +125,7 @@ Public.matter_anomaly = { force.technologies['mining-productivity-4'].researched = true end end, - on_robot_built_entity = function(event) + on_robot_built_entity = function (event) local entity = event.created_entity if not entity.valid then return @@ -137,7 +137,7 @@ Public.matter_anomaly = { entity.die() end end, - on_built_entity = function(event) + on_built_entity = function (event) local entity = event.created_entity if not entity.valid then return @@ -152,7 +152,7 @@ Public.matter_anomaly = { } Public.quantum_anomaly = { - on_world_start = function(journey) + on_world_start = function (journey) local force = game.forces.player for i = 1, 6, 1 do force.technologies['research-speed-' .. i].researched = true @@ -162,11 +162,11 @@ Public.quantum_anomaly = { } Public.mountainous = { - on_world_start = function(journey) + on_world_start = function (journey) local force = game.forces.player force.character_loot_pickup_distance_bonus = 2 end, - on_player_mined_entity = function(event) + on_player_mined_entity = function (event) local entity = event.entity if not entity.valid then return @@ -180,10 +180,10 @@ Public.mountainous = { local count = math_floor(math_sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.05) + math_random(25, 75) local ore_amount = math_floor(count * 0.85) local stone_amount = math_floor(count * 0.15) - surface.spill_item_stack(entity.position, {name = ore, count = ore_amount}, true) - surface.spill_item_stack(entity.position, {name = 'stone', count = stone_amount}, true) + surface.spill_item_stack(entity.position, { name = ore, count = ore_amount }, true) + surface.spill_item_stack(entity.position, { name = 'stone', count = stone_amount }, true) end, - on_chunk_generated = function(event, journey) + on_chunk_generated = function (event, journey) local surface = event.surface local seed = surface.map_gen_settings.seed local left_top_x = event.area.left_top.x @@ -193,11 +193,11 @@ Public.mountainous = { for x = 0, 31, 1 do for y = 0, 31, 1 do if math_random(1, 3) ~= 1 then - position = {x = left_top_x + x, y = left_top_y + y} - if surface.can_place_entity({name = 'coal', position = position}) then + position = { x = left_top_x + x, y = left_top_y + y } + if surface.can_place_entity({ name = 'coal', position = position }) then noise = math_abs(Get_noise('scrapyard', position, seed)) if noise < 0.025 or noise > 0.50 then - surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = position}) + surface.create_entity({ name = rock_raffle[math_random(1, size_of_rock_raffle)], position = position }) end end end @@ -207,7 +207,7 @@ Public.mountainous = { } Public.replicant_fauna = { - on_entity_died = function(event) + on_entity_died = function (event) local entity = event.entity if not entity.valid then return @@ -220,13 +220,13 @@ Public.replicant_fauna = { return end if cause.force.index == 2 then - cause.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor), position = entity.position, force = 'enemy'}) + cause.surface.create_entity({ name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor), position = entity.position, force = 'enemy' }) end end } Public.tarball = { - on_robot_built_entity = function(event) + on_robot_built_entity = function (event) local entity = event.created_entity if not entity.valid then return @@ -239,7 +239,7 @@ Public.tarball = { end entity.minable = false end, - on_built_entity = function(event) + on_built_entity = function (event) local entity = event.created_entity if not entity.valid then return @@ -252,7 +252,7 @@ Public.tarball = { end entity.minable = false end, - on_chunk_generated = function(event, journey) + on_chunk_generated = function (event, journey) table.insert( journey.world_color_filters, rendering.draw_sprite( @@ -262,13 +262,13 @@ Public.tarball = { y_scale = 32, target = event.area.left_top, surface = event.surface, - tint = {r = 0.0, g = 0.0, b = 0.0, a = 0.45}, + tint = { r = 0.0, g = 0.0, b = 0.0, a = 0.45 }, render_layer = 'ground' } ) ) end, - clear = function(journey) + clear = function (journey) for _, id in pairs(journey.world_color_filters) do rendering.destroy(id) end @@ -277,26 +277,26 @@ Public.tarball = { } Public.swamps = { - set_specials = function(journey) + set_specials = function (journey) journey.world_specials['water'] = 2 end, - on_chunk_generated = function(event, journey) + on_chunk_generated = function (event, journey) local surface = event.surface local seed = surface.map_gen_settings.seed local left_top_x = event.area.left_top.x local left_top_y = event.area.left_top.y local tiles = {} - for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = event.area})) do - table.insert(tiles, {name = 'water-shallow', position = tile.position}) + for _, tile in pairs(surface.find_tiles_filtered({ name = { 'water', 'deepwater' }, area = event.area })) do + table.insert(tiles, { name = 'water-shallow', position = tile.position }) end for x = 0, 31, 1 do for y = 0, 31, 1 do - local position = {x = left_top_x + x, y = left_top_y + y} + local position = { x = left_top_x + x, y = left_top_y + y } local noise = Get_noise('journey_swamps', position, seed) if noise > 0.45 or noise < -0.65 then - table.insert(tiles, {name = 'water-shallow', position = {x = position.x, y = position.y}}) + table.insert(tiles, { name = 'water-shallow', position = { x = position.x, y = position.y } }) end end end @@ -304,23 +304,23 @@ Public.swamps = { for _, tile in pairs(tiles) do if math_random(1, 32) == 1 then - surface.create_entity({name = 'fish', position = tile.position}) + surface.create_entity({ name = 'fish', position = tile.position }) end end end } Public.wasteland = { - on_chunk_generated = function(event, journey) + on_chunk_generated = function (event, journey) local surface = event.surface local left_top_x = event.area.left_top.x local left_top_y = event.area.left_top.y local tiles = {} - for _, tile in pairs(surface.find_tiles_filtered({name = {'water'}, area = event.area})) do - table.insert(tiles, {name = 'water-green', position = tile.position}) + for _, tile in pairs(surface.find_tiles_filtered({ name = { 'water' }, area = event.area })) do + table.insert(tiles, { name = 'water-green', position = tile.position }) end - for _, tile in pairs(surface.find_tiles_filtered({name = {'deepwater'}, area = event.area})) do - table.insert(tiles, {name = 'deepwater-green', position = tile.position}) + for _, tile in pairs(surface.find_tiles_filtered({ name = { 'deepwater' }, area = event.area })) do + table.insert(tiles, { name = 'deepwater-green', position = tile.position }) end surface.set_tiles(tiles, true, false, false, false) if math_random(1, 3) ~= 1 then @@ -328,11 +328,11 @@ Public.wasteland = { end for _ = 1, math_random(0, 5), 1 do local name = wrecks[math_random(1, size_of_wrecks)] - local position = surface.find_non_colliding_position(name, {left_top_x + math_random(0, 31), left_top_y + math_random(0, 31)}, 16, 1) + local position = surface.find_non_colliding_position(name, { left_top_x + math_random(0, 31), left_top_y + math_random(0, 31) }, 16, 1) if position then - local e = surface.create_entity({name = name, position = position, force = 'neutral'}) + local e = surface.create_entity({ name = name, position = position, force = 'neutral' }) if math_random(1, 4) == 1 then - local slots = game.entity_prototypes[e.name].get_inventory_size(defines.inventory.chest) + local slots = prototypes.entity[e.name].get_inventory_size(defines.inventory.chest) local blacklist = LootRaffle.get_tech_blacklist(0.2) local item_stacks = LootRaffle.roll(math_random(16, 64), slots, blacklist) for _, item_stack in pairs(item_stacks) do @@ -342,7 +342,7 @@ Public.wasteland = { end end end, - on_world_start = function(journey) + on_world_start = function (journey) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings mgs.terrain_segmentation = 2.7 @@ -350,7 +350,7 @@ Public.wasteland = { surface.map_gen_settings = mgs surface.clear(true) end, - clear = function(journey) + clear = function (journey) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings mgs.water = mgs.water - 1 @@ -359,7 +359,7 @@ Public.wasteland = { } Public.oceanic = { - on_world_start = function(journey) + on_world_start = function (journey) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings mgs.terrain_segmentation = 0.5 @@ -367,7 +367,7 @@ Public.oceanic = { surface.map_gen_settings = mgs surface.clear(true) end, - on_robot_built_entity = function(event) + on_robot_built_entity = function (event) local entity = event.created_entity if not entity.valid then return @@ -379,7 +379,7 @@ Public.oceanic = { entity.die() end end, - on_built_entity = function(event) + on_built_entity = function (event) local entity = event.created_entity if not entity.valid then return @@ -391,7 +391,7 @@ Public.oceanic = { entity.die() end end, - clear = function(journey) + clear = function (journey) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings mgs.water = mgs.water - 6 @@ -400,7 +400,7 @@ Public.oceanic = { } Public.volcanic = { - on_chunk_generated = function(event, journey) + on_chunk_generated = function (event, journey) table.insert( journey.world_color_filters, rendering.draw_sprite( @@ -410,13 +410,13 @@ Public.volcanic = { y_scale = 32, target = event.area.left_top, surface = event.surface, - tint = {r = 0.55, g = 0.0, b = 0.0, a = 0.25}, + tint = { r = 0.55, g = 0.0, b = 0.0, a = 0.25 }, render_layer = 'ground' } ) ) end, - on_player_changed_position = function(event) + on_player_changed_position = function (event) local player = game.players[event.player_index] if player.driving then return @@ -428,22 +428,22 @@ Public.volcanic = { if solid_tiles[surface.get_tile(player.position).name] then return end - surface.create_entity({name = 'fire-flame', position = player.position}) + surface.create_entity({ name = 'fire-flame', position = player.position }) end, - on_world_start = function(journey) + on_world_start = function (journey) local surface = game.surfaces.nauvis - surface.request_to_generate_chunks({x = 0, y = 0}, 3) + surface.request_to_generate_chunks({ x = 0, y = 0 }, 3) surface.force_generate_chunk_requests() - surface.spill_item_stack({0, 0}, {name = 'stone-brick', count = 4096}, true) + surface.spill_item_stack({ 0, 0 }, { name = 'stone-brick', count = 4096 }, true) for x = -24, 24, 1 do for y = -24, 24, 1 do if math.sqrt(x ^ 2 + y ^ 2) < 24 then - surface.set_tiles({{name = 'stone-path', position = {x, y}}}, true) + surface.set_tiles({ { name = 'stone-path', position = { x, y } } }, true) end end end end, - clear = function(journey) + clear = function (journey) for _, id in pairs(journey.world_color_filters) do rendering.destroy(id) end @@ -452,17 +452,17 @@ Public.volcanic = { } Public.chaotic_resources = { - on_chunk_generated = function(event, journey) + on_chunk_generated = function (event, journey) local surface = event.surface - for _, ore in pairs(surface.find_entities_filtered({area = event.area, name = {'iron-ore', 'copper-ore', 'coal', 'stone'}})) do - surface.create_entity({name = ore_raffle_2[math_random(1, size_of_ore_raffle_2)], position = ore.position, amount = ore.amount}) + for _, ore in pairs(surface.find_entities_filtered({ area = event.area, name = { 'iron-ore', 'copper-ore', 'coal', 'stone' } })) do + surface.create_entity({ name = ore_raffle_2[math_random(1, size_of_ore_raffle_2)], position = ore.position, amount = ore.amount }) ore.destroy() end end } Public.infested = { - on_chunk_generated = function(event, journey) + on_chunk_generated = function (event, journey) table.insert( journey.world_color_filters, rendering.draw_sprite( @@ -472,24 +472,24 @@ Public.infested = { y_scale = 32, target = event.area.left_top, surface = event.surface, - tint = {r = 0.8, g = 0.0, b = 0.8, a = 0.25}, + tint = { r = 0.8, g = 0.0, b = 0.8, a = 0.25 }, render_layer = 'ground' } ) ) end, - set_specials = function(journey) + set_specials = function (journey) journey.world_specials['trees_size'] = 4 journey.world_specials['trees_richness'] = 2 journey.world_specials['trees_frequency'] = 2 end, - clear = function(journey) + clear = function (journey) for _, id in pairs(journey.world_color_filters) do rendering.destroy(id) end journey.world_color_filters = {} end, - on_entity_died = function(event) + on_entity_died = function (event) local entity = event.entity if not entity.valid then return @@ -500,9 +500,9 @@ Public.infested = { if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end - entity.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy'}) + entity.surface.create_entity({ name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy' }) end, - on_player_mined_entity = function(event) + on_player_mined_entity = function (event) if math_random(1, 2) == 1 then return end @@ -516,9 +516,9 @@ Public.infested = { if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end - entity.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy'}) + entity.surface.create_entity({ name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy' }) end, - on_robot_mined_entity = function(event) + on_robot_mined_entity = function (event) local entity = event.entity if not entity.valid then return @@ -529,12 +529,12 @@ Public.infested = { if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end - entity.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy'}) + entity.surface.create_entity({ name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy' }) end } Public.undead_plague = { - on_entity_died = function(event) + on_entity_died = function (event) local entity = event.entity if not entity.valid then return @@ -548,12 +548,12 @@ Public.undead_plague = { if entity.type ~= 'unit' then return end - entity.surface.create_entity({name = entity.name, position = entity.position, force = 'enemy'}) + entity.surface.create_entity({ name = entity.name, position = entity.position, force = 'enemy' }) end } Public.low_mass = { - on_world_start = function(journey) + on_world_start = function (journey) local force = game.forces.player force.character_running_speed_modifier = 0.5 for i = 1, 6, 1 do @@ -563,7 +563,7 @@ Public.low_mass = { } Public.dense_atmosphere = { - on_robot_built_entity = function(event) + on_robot_built_entity = function (event) local entity = event.created_entity if not entity.valid then return @@ -575,7 +575,7 @@ Public.dense_atmosphere = { entity.die() end end, - on_built_entity = function(event) + on_built_entity = function (event) local entity = event.created_entity if not entity.valid then return @@ -599,7 +599,7 @@ local function update_lazy_bastard(journey, count) end Public.lazy_bastard = { - on_robot_built_entity = function(event, journey) + on_robot_built_entity = function (event, journey) local entity = event.created_entity if not entity.valid then return @@ -611,7 +611,7 @@ Public.lazy_bastard = { update_lazy_bastard(journey, 1) end end, - on_built_entity = function(event, journey) + on_built_entity = function (event, journey) local entity = event.created_entity if not entity.valid then return @@ -623,7 +623,7 @@ Public.lazy_bastard = { update_lazy_bastard(journey, 1) end end, - on_entity_died = function(event, journey) + on_entity_died = function (event, journey) local entity = event.entity if not entity.valid then return @@ -635,7 +635,7 @@ Public.lazy_bastard = { update_lazy_bastard(journey, -1) end end, - on_player_mined_entity = function(event, journey) + on_player_mined_entity = function (event, journey) local entity = event.entity if not entity.valid then return @@ -647,7 +647,7 @@ Public.lazy_bastard = { update_lazy_bastard(journey, -1) end end, - on_robot_mined_entity = function(event, journey) + on_robot_mined_entity = function (event, journey) local entity = event.entity if not entity.valid then return @@ -659,37 +659,37 @@ Public.lazy_bastard = { update_lazy_bastard(journey, -1) end end, - on_world_start = function(journey) + on_world_start = function (journey) journey.lazy_bastard_machines = 0 end, - clear = function(journey) + clear = function (journey) game.forces.player.manual_crafting_speed_modifier = 0 end } Public.ribbon = { - on_chunk_generated = function(event, journey) + on_chunk_generated = function (event, journey) local surface = event.surface local left_top_x = event.area.left_top.x local left_top_y = event.area.left_top.y if (left_top_x + left_top_y) ^ 2 <= 256 then - local oils = surface.count_entities_filtered {name = 'crude-oil', position = {x = 0, y = 0}, radius = 256} + local oils = surface.count_entities_filtered { name = 'crude-oil', position = { x = 0, y = 0 }, radius = 256 } if math.random(1, 10 + oils * 10) == 1 then local pos = surface.find_non_colliding_position_in_box('oil-refinery', event.area, 0.1, true) if pos then - surface.create_entity({name = 'crude-oil', position = pos, amount = 60000}) + surface.create_entity({ name = 'crude-oil', position = pos, amount = 60000 }) end end end end, - on_world_start = function(journey) + on_world_start = function (journey) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings mgs.height = 256 surface.map_gen_settings = mgs surface.clear(true) end, - clear = function(journey) + clear = function (journey) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings mgs.height = nil @@ -698,18 +698,18 @@ Public.ribbon = { } Public.abandoned_library = { - on_world_start = function(journey) + on_world_start = function (journey) game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, false) game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, false) end, - clear = function(journey) + clear = function (journey) game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, true) game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, true) end } Public.railworld = { - set_specials = function(journey) + set_specials = function (journey) journey.world_specials['ore_size'] = 4 journey.world_specials['ore_frequency'] = 0.25 journey.world_specials['coal'] = 4 @@ -738,12 +738,12 @@ local delivery_options = { } Public.resupply_station = { - on_world_start = function(journey) + on_world_start = function (journey) local pick = delivery_options[math.random(1, #delivery_options)] - journey.speedrun = {enabled = true, time = 0, item = pick} - journey.mothership_cargo_space[pick] = game.item_prototypes[pick].stack_size + journey.speedrun = { enabled = true, time = 0, item = pick } + journey.mothership_cargo_space[pick] = prototypes.item[pick].stack_size end, - clear = function(journey) + clear = function (journey) journey.mothership_cargo_space[journey.speedrun.item] = nil journey.mothership_cargo[journey.speedrun.item] = 0 journey.speedrun.enabled = false @@ -751,17 +751,17 @@ Public.resupply_station = { } Public.crazy_science = { - set_specials = function(journey) + set_specials = function (journey) journey.world_specials['technology_price_multiplier'] = 50 journey.world_specials['starting_area'] = 3 journey.world_specials['copper-ore'] = 2 journey.world_specials['iron-ore'] = 4 end, - on_world_start = function(journey) + on_world_start = function (journey) game.forces.player.laboratory_productivity_bonus = 5 game.forces.player.laboratory_speed_modifier = 10 end, - on_research_finished = function(event, journey) + on_research_finished = function (event, journey) local name = 'technology_price_multiplier' local force = event.research.force journey.world_specials[name] = math.max(0.1, journey.world_specials[name] * 0.95) diff --git a/maps/junkyard.lua b/maps/junkyard.lua index 1f33e4cc..7a150cee 100644 --- a/maps/junkyard.lua +++ b/maps/junkyard.lua @@ -451,7 +451,7 @@ local function on_chunk_charted(event) storage.chunks_charted[tostring(position.x) .. tostring(position.y)] = true local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/junkyard_pvp/terrain.lua b/maps/junkyard_pvp/terrain.lua index 1502ea5c..1b44aac8 100644 --- a/maps/junkyard_pvp/terrain.lua +++ b/maps/junkyard_pvp/terrain.lua @@ -337,8 +337,8 @@ local function process_mirror_surface(event) end for _, entity in pairs(entities) do - if entity_functions[game.entity_prototypes[entity.name].type] then - entity_functions[game.entity_prototypes[entity.name].type](surface, entity) + if entity_functions[prototypes.entity[entity.name].type] then + entity_functions[prototypes.entity[entity.name].type](surface, entity) else if surface.can_place_entity(entity) then surface.create_entity(entity) diff --git a/maps/labyrinth.lua b/maps/labyrinth.lua index cf8700a4..3a587e0c 100644 --- a/maps/labyrinth.lua +++ b/maps/labyrinth.lua @@ -270,7 +270,7 @@ local function grow_cell(chunk_position, surface) -- luacheck: ignore end local tree_raffle = {} - for _, e in pairs(game.entity_prototypes) do + for _, e in pairs(prototypes.entity) do if e.type == 'tree' then table.insert(tree_raffle, e.name) end @@ -293,7 +293,7 @@ local function grow_cell(chunk_position, surface) -- luacheck: ignore 'splitter', 'straight-rail' } - for _, e in pairs(game.entity_prototypes) do + for _, e in pairs(prototypes.entity) do for _, t in pairs(types) do if e.type == t then table.insert(allied_entity_raffle, e.name) @@ -586,7 +586,7 @@ local function grow_cell(chunk_position, surface) -- luacheck: ignore surface.set_tiles(tiles, true) local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end @@ -706,135 +706,135 @@ local function treasure_chest(position, surface) local math_random = math.random local chest_raffle = {} local chest_loot = { - { { name = 'submachine-gun', count = math_random(1, 3) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 }, - { { name = 'slowdown-capsule', count = math_random(16, 32) }, weight = 1, evolution_min = 0.0, evolution_max = 1 }, - { { name = 'poison-capsule', count = math_random(16, 32) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'uranium-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.6, evolution_max = 1 }, - { { name = 'cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 0.7 }, - { { name = 'explosive-uranium-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.6, evolution_max = 1 }, - { { name = 'explosive-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 0.8 }, - { { name = 'shotgun', count = 1 }, weight = 2, evolution_min = 0.0, evolution_max = 0.2 }, - { { name = 'shotgun-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.0, evolution_max = 0.2 }, - { { name = 'combat-shotgun', count = 1 }, weight = 10, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'piercing-shotgun-shell', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 1 }, - { { name = 'flamethrower', count = 1 }, weight = 3, evolution_min = 0.3, evolution_max = 0.6 }, - { { name = 'flamethrower-ammo', count = math_random(16, 32) }, weight = 5, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'rocket-launcher', count = 1 }, weight = 5, evolution_min = 0.2, evolution_max = 0.6 }, - { { name = 'rocket', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'explosive-rocket', count = math_random(16, 32) }, weight = 10, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'land-mine', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'grenade', count = math_random(16, 32) }, weight = 10, evolution_min = 0.0, evolution_max = 0.5 }, - { { name = 'cluster-grenade', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 1 }, - { { name = 'firearm-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0, evolution_max = 0.3 }, - { { name = 'piercing-rounds-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0.1, evolution_max = 0.8 }, - { { name = 'uranium-rounds-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'defender-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.0, evolution_max = 0.7 }, - { { name = 'distractor-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.2, evolution_max = 1 }, - { { name = 'destroyer-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'atomic-bomb', count = math_random(8, 16) }, weight = 1, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'light-armor', count = 1 }, weight = 3, evolution_min = 0, evolution_max = 0.1 }, - { { name = 'heavy-armor', count = 1 }, weight = 3, evolution_min = 0.1, evolution_max = 0.3 }, - { { name = 'modular-armor', count = 1 }, weight = 2, evolution_min = 0.2, evolution_max = 0.6 }, - { { name = 'power-armor', count = 1 }, weight = 2, evolution_min = 0.4, evolution_max = 1 }, - { { name = 'power-armor-mk2', count = 1 }, weight = 1, evolution_min = 0.8, evolution_max = 1 }, - { { name = 'battery-equipment', count = 1 }, weight = 2, evolution_min = 0.3, evolution_max = 0.7 }, - { { name = 'battery-mk2-equipment', count = 1 }, weight = 2, evolution_min = 0.6, evolution_max = 1 }, - { { name = 'belt-immunity-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'solar-panel-equipment', count = math_random(1, 4) }, weight = 5, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'discharge-defense-equipment', count = 1 }, weight = 1, evolution_min = 0.5, evolution_max = 0.8 }, - { { name = 'energy-shield-equipment', count = math_random(1, 2) }, weight = 2, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'energy-shield-mk2-equipment', count = 1 }, weight = 2, evolution_min = 0.7, evolution_max = 1 }, - { { name = 'exoskeleton-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'fusion-reactor-equipment', count = 1 }, weight = 1, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'night-vision-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'personal-laser-defense-equipment', count = 1 }, weight = 2, evolution_min = 0.4, evolution_max = 1 }, - { { name = 'exoskeleton-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'iron-gear-wheel', count = math_random(80, 100) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'copper-cable', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.1, evolution_max = 0.5 }, - { { name = 'electric-engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.4, evolution_max = 0.8 }, - { { name = 'battery', count = math_random(100, 200) }, weight = 2, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'advanced-circuit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.4, evolution_max = 1 }, - { { name = 'electronic-circuit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, - { { name = 'processing-unit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.7, evolution_max = 1 }, - { { name = 'explosives', count = math_random(25, 50) }, weight = 1, evolution_min = 0.2, evolution_max = 0.6 }, - { { name = 'lubricant-barrel', count = math_random(4, 10) }, weight = 1, evolution_min = 0.3, evolution_max = 0.5 }, - { { name = 'rocket-fuel', count = math_random(4, 10) }, weight = 2, evolution_min = 0.3, evolution_max = 0.7 }, - { { name = 'player-port', count = 1 }, weight = 1, evolution_min = 0.2, evolution_max = 1 }, - { { name = 'steel-plate', count = math_random(50, 100) }, weight = 2, evolution_min = 0.1, evolution_max = 0.3 }, - { { name = 'nuclear-fuel', count = 1 }, weight = 2, evolution_min = 0.7, evolution_max = 1 }, - { { name = 'burner-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 }, - { { name = 'inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, - { { name = 'long-handed-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, - { { name = 'fast-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'filter-inserter', count = math_random(8, 16) }, weight = 1, evolution_min = 0.2, evolution_max = 1 }, - { { name = 'stack-filter-inserter', count = math_random(4, 8) }, weight = 1, evolution_min = 0.4, evolution_max = 1 }, - { { name = 'stack-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'small-electric-pole', count = math_random(16, 32) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'medium-electric-pole', count = math_random(8, 16) }, weight = 3, evolution_min = 0.2, evolution_max = 1 }, - { { name = 'big-electric-pole', count = math_random(8, 16) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'substation', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'wooden-chest', count = math_random(25, 50) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 }, - { { name = 'iron-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.1, evolution_max = 0.4 }, - { { name = 'steel-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'small-lamp', count = math_random(8, 16) }, weight = 3, evolution_min = 0.1, evolution_max = 0.3 }, - { { name = 'rail', count = math_random(50, 75) }, weight = 3, evolution_min = 0.1, evolution_max = 0.6 }, - { { name = 'assembling-machine-1', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'assembling-machine-2', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.8 }, - { { name = 'assembling-machine-3', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'accumulator', count = math_random(4, 8) }, weight = 3, evolution_min = 0.4, evolution_max = 1 }, - { { name = 'offshore-pump', count = math_random(1, 2) }, weight = 2, evolution_min = 0.0, evolution_max = 0.1 }, - { { name = 'beacon', count = math_random(1, 2) }, weight = 3, evolution_min = 0.7, evolution_max = 1 }, - { { name = 'boiler', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'steam-engine', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.5 }, - { { name = 'steam-turbine', count = math_random(1, 2) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'submachine-gun', count = math_random(1, 3) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 }, + { { name = 'slowdown-capsule', count = math_random(16, 32) }, weight = 1, evolution_min = 0.0, evolution_max = 1 }, + { { name = 'poison-capsule', count = math_random(16, 32) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'uranium-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.6, evolution_max = 1 }, + { { name = 'cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 0.7 }, + { { name = 'explosive-uranium-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.6, evolution_max = 1 }, + { { name = 'explosive-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 0.8 }, + { { name = 'shotgun', count = 1 }, weight = 2, evolution_min = 0.0, evolution_max = 0.2 }, + { { name = 'shotgun-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.0, evolution_max = 0.2 }, + { { name = 'combat-shotgun', count = 1 }, weight = 10, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'piercing-shotgun-shell', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 1 }, + { { name = 'flamethrower', count = 1 }, weight = 3, evolution_min = 0.3, evolution_max = 0.6 }, + { { name = 'flamethrower-ammo', count = math_random(16, 32) }, weight = 5, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'rocket-launcher', count = 1 }, weight = 5, evolution_min = 0.2, evolution_max = 0.6 }, + { { name = 'rocket', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'explosive-rocket', count = math_random(16, 32) }, weight = 10, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'land-mine', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'grenade', count = math_random(16, 32) }, weight = 10, evolution_min = 0.0, evolution_max = 0.5 }, + { { name = 'cluster-grenade', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 1 }, + { { name = 'firearm-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0, evolution_max = 0.3 }, + { { name = 'piercing-rounds-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0.1, evolution_max = 0.8 }, + { { name = 'uranium-rounds-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'defender-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.0, evolution_max = 0.7 }, + { { name = 'distractor-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.2, evolution_max = 1 }, + { { name = 'destroyer-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'atomic-bomb', count = math_random(8, 16) }, weight = 1, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'light-armor', count = 1 }, weight = 3, evolution_min = 0, evolution_max = 0.1 }, + { { name = 'heavy-armor', count = 1 }, weight = 3, evolution_min = 0.1, evolution_max = 0.3 }, + { { name = 'modular-armor', count = 1 }, weight = 2, evolution_min = 0.2, evolution_max = 0.6 }, + { { name = 'power-armor', count = 1 }, weight = 2, evolution_min = 0.4, evolution_max = 1 }, + { { name = 'power-armor-mk2', count = 1 }, weight = 1, evolution_min = 0.8, evolution_max = 1 }, + { { name = 'battery-equipment', count = 1 }, weight = 2, evolution_min = 0.3, evolution_max = 0.7 }, + { { name = 'battery-mk2-equipment', count = 1 }, weight = 2, evolution_min = 0.6, evolution_max = 1 }, + { { name = 'belt-immunity-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'solar-panel-equipment', count = math_random(1, 4) }, weight = 5, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'discharge-defense-equipment', count = 1 }, weight = 1, evolution_min = 0.5, evolution_max = 0.8 }, + { { name = 'energy-shield-equipment', count = math_random(1, 2) }, weight = 2, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'energy-shield-mk2-equipment', count = 1 }, weight = 2, evolution_min = 0.7, evolution_max = 1 }, + { { name = 'exoskeleton-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'fusion-reactor-equipment', count = 1 }, weight = 1, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'night-vision-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'personal-laser-defense-equipment', count = 1 }, weight = 2, evolution_min = 0.4, evolution_max = 1 }, + { { name = 'exoskeleton-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'iron-gear-wheel', count = math_random(80, 100) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'copper-cable', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.1, evolution_max = 0.5 }, + { { name = 'electric-engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.4, evolution_max = 0.8 }, + { { name = 'battery', count = math_random(100, 200) }, weight = 2, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'advanced-circuit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.4, evolution_max = 1 }, + { { name = 'electronic-circuit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, + { { name = 'processing-unit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.7, evolution_max = 1 }, + { { name = 'explosives', count = math_random(25, 50) }, weight = 1, evolution_min = 0.2, evolution_max = 0.6 }, + { { name = 'lubricant-barrel', count = math_random(4, 10) }, weight = 1, evolution_min = 0.3, evolution_max = 0.5 }, + { { name = 'rocket-fuel', count = math_random(4, 10) }, weight = 2, evolution_min = 0.3, evolution_max = 0.7 }, + { { name = 'player-port', count = 1 }, weight = 1, evolution_min = 0.2, evolution_max = 1 }, + { { name = 'steel-plate', count = math_random(50, 100) }, weight = 2, evolution_min = 0.1, evolution_max = 0.3 }, + { { name = 'nuclear-fuel', count = 1 }, weight = 2, evolution_min = 0.7, evolution_max = 1 }, + { { name = 'burner-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 }, + { { name = 'inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, + { { name = 'long-handed-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 }, + { { name = 'fast-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'filter-inserter', count = math_random(8, 16) }, weight = 1, evolution_min = 0.2, evolution_max = 1 }, + { { name = 'stack-filter-inserter', count = math_random(4, 8) }, weight = 1, evolution_min = 0.4, evolution_max = 1 }, + { { name = 'stack-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'small-electric-pole', count = math_random(16, 32) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'medium-electric-pole', count = math_random(8, 16) }, weight = 3, evolution_min = 0.2, evolution_max = 1 }, + { { name = 'big-electric-pole', count = math_random(8, 16) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'substation', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'wooden-chest', count = math_random(25, 50) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 }, + { { name = 'iron-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.1, evolution_max = 0.4 }, + { { name = 'steel-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'small-lamp', count = math_random(8, 16) }, weight = 3, evolution_min = 0.1, evolution_max = 0.3 }, + { { name = 'rail', count = math_random(50, 75) }, weight = 3, evolution_min = 0.1, evolution_max = 0.6 }, + { { name = 'assembling-machine-1', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'assembling-machine-2', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.8 }, + { { name = 'assembling-machine-3', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'accumulator', count = math_random(4, 8) }, weight = 3, evolution_min = 0.4, evolution_max = 1 }, + { { name = 'offshore-pump', count = math_random(1, 2) }, weight = 2, evolution_min = 0.0, evolution_max = 0.1 }, + { { name = 'beacon', count = math_random(1, 2) }, weight = 3, evolution_min = 0.7, evolution_max = 1 }, + { { name = 'boiler', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'steam-engine', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.5 }, + { { name = 'steam-turbine', count = math_random(1, 2) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, --{{name = "nuclear-reactor", count = 1}, weight = 2, evolution_min = 0.5, evolution_max = 1}, - { { name = 'centrifuge', count = math_random(1, 2) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'heat-pipe', count = math_random(8, 12) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'heat-exchanger', count = math_random(2, 4) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'arithmetic-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'constant-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'decider-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'power-switch', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'programmable-speaker', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'green-wire', count = math_random(50, 100) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'red-wire', count = math_random(50, 100) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, - { { name = 'chemical-plant', count = math_random(2, 4) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'burner-mining-drill', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 }, - { { name = 'electric-mining-drill', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.6 }, - { { name = 'express-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'express-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'express-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'fast-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'fast-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'fast-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.3 }, - { { name = 'transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, - { { name = 'underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, - { { name = 'splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, - { { name = 'oil-refinery', count = math_random(1, 2) }, weight = 2, evolution_min = 0.3, evolution_max = 1 }, - { { name = 'pipe', count = math_random(40, 50) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, - { { name = 'pipe-to-ground', count = math_random(8, 16) }, weight = 1, evolution_min = 0.2, evolution_max = 0.5 }, - { { name = 'pumpjack', count = math_random(1, 2) }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'pump', count = math_random(1, 4) }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 }, - { { name = 'solar-panel', count = math_random(4, 8) }, weight = 3, evolution_min = 0.4, evolution_max = 0.9 }, - { { name = 'electric-furnace', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'steel-furnace', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'stone-furnace', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 }, - { { name = 'radar', count = math_random(1, 2) }, weight = 1, evolution_min = 0.1, evolution_max = 0.3 }, - { { name = 'rail-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 }, - { { name = 'rail-chain-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 }, - { { name = 'stone-wall', count = math_random(25, 75) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 }, - { { name = 'gate', count = math_random(4, 8) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 }, - { { name = 'storage-tank', count = math_random(2, 4) }, weight = 3, evolution_min = 0.3, evolution_max = 0.6 }, - { { name = 'train-stop', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'express-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.5, evolution_max = 1 }, - { { name = 'fast-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 }, - { { name = 'loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.0, evolution_max = 0.5 }, - { { name = 'lab', count = math_random(2, 4) }, weight = 2, evolution_min = 0.0, evolution_max = 0.1 }, + { { name = 'centrifuge', count = math_random(1, 2) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'heat-pipe', count = math_random(8, 12) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'heat-exchanger', count = math_random(2, 4) }, weight = 2, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'arithmetic-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'constant-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'decider-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'power-switch', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'programmable-speaker', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'green-wire', count = math_random(50, 100) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'red-wire', count = math_random(50, 100) }, weight = 1, evolution_min = 0.1, evolution_max = 1 }, + { { name = 'chemical-plant', count = math_random(2, 4) }, weight = 3, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'burner-mining-drill', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 }, + { { name = 'electric-mining-drill', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.6 }, + { { name = 'express-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'express-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'express-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'fast-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'fast-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'fast-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.3 }, + { { name = 'transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, + { { name = 'underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, + { { name = 'splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0, evolution_max = 0.3 }, + { { name = 'oil-refinery', count = math_random(1, 2) }, weight = 2, evolution_min = 0.3, evolution_max = 1 }, + { { name = 'pipe', count = math_random(40, 50) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 }, + { { name = 'pipe-to-ground', count = math_random(8, 16) }, weight = 1, evolution_min = 0.2, evolution_max = 0.5 }, + { { name = 'pumpjack', count = math_random(1, 2) }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'pump', count = math_random(1, 4) }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 }, + { { name = 'solar-panel', count = math_random(4, 8) }, weight = 3, evolution_min = 0.4, evolution_max = 0.9 }, + { { name = 'electric-furnace', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'steel-furnace', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'stone-furnace', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 }, + { { name = 'radar', count = math_random(1, 2) }, weight = 1, evolution_min = 0.1, evolution_max = 0.3 }, + { { name = 'rail-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 }, + { { name = 'rail-chain-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 }, + { { name = 'stone-wall', count = math_random(25, 75) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 }, + { { name = 'gate', count = math_random(4, 8) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 }, + { { name = 'storage-tank', count = math_random(2, 4) }, weight = 3, evolution_min = 0.3, evolution_max = 0.6 }, + { { name = 'train-stop', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'express-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.5, evolution_max = 1 }, + { { name = 'fast-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 }, + { { name = 'loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.0, evolution_max = 0.5 }, + { { name = 'lab', count = math_random(2, 4) }, weight = 2, evolution_min = 0.0, evolution_max = 0.1 }, --{{name = "roboport", count = math_random(2,4)}, weight = 2, evolution_min = 0.6, evolution_max = 1}, --{{name = "flamethrower-turret", count = math_random(4,8)}, weight = 3, evolution_min = 0.5, evolution_max = 1}, --{{name = "laser-turret", count = math_random(4,8)}, weight = 3, evolution_min = 0.5, evolution_max = 1}, - { { name = 'gun-turret', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.9 } + { { name = 'gun-turret', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.9 } } for _, t in pairs(chest_loot) do for _ = 1, t.weight, 1 do diff --git a/maps/minesweeper/main.lua b/maps/minesweeper/main.lua index a4d0a889..c82d76d3 100644 --- a/maps/minesweeper/main.lua +++ b/maps/minesweeper/main.lua @@ -494,7 +494,7 @@ local function deny_building(event) return end - if not game.item_prototypes[entity.name] then + if not prototypes.item[entity.name] then return end if not Functions.is_minefield_tile(entity.position, true) then diff --git a/maps/mountain_fortress.lua b/maps/mountain_fortress.lua index 93c6cff1..165f0354 100644 --- a/maps/mountain_fortress.lua +++ b/maps/mountain_fortress.lua @@ -239,7 +239,7 @@ local function generate_north_chunk(area, surface) end local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/mountain_fortress_v2/terrain.lua b/maps/mountain_fortress_v2/terrain.lua index 3bb1969d..4188d3a1 100644 --- a/maps/mountain_fortress_v2/terrain.lua +++ b/maps/mountain_fortress_v2/terrain.lua @@ -1012,8 +1012,8 @@ local function rock_chunk(surface, left_top) end for _, entity in pairs(entities) do - if entity_functions[game.entity_prototypes[entity.name].type] then - entity_functions[game.entity_prototypes[entity.name].type](surface, entity) + if entity_functions[prototypes.entity[entity.name].type] then + entity_functions[prototypes.entity[entity.name].type](surface, entity) else if surface.can_place_entity(entity) then surface.create_entity(entity) diff --git a/maps/mountain_fortress_v3/ic/functions.lua b/maps/mountain_fortress_v3/ic/functions.lua index 426979fa..0bb59923 100644 --- a/maps/mountain_fortress_v3/ic/functions.lua +++ b/maps/mountain_fortress_v3/ic/functions.lua @@ -580,7 +580,7 @@ end local function input_filtered(car_inv, chest, chest_inv, free_slots) local request_stacks = {} - local prototypes = game.item_prototypes + local prototypes = prototypes.item for slot_index = 1, 30, 1 do local stack = chest.get_request_slot(slot_index) if stack then diff --git a/maps/mountain_fortress_v3/icw/linked_chests.lua b/maps/mountain_fortress_v3/icw/linked_chests.lua index 7c41ec11..8fd6257d 100644 --- a/maps/mountain_fortress_v3/icw/linked_chests.lua +++ b/maps/mountain_fortress_v3/icw/linked_chests.lua @@ -856,7 +856,7 @@ local function update_gui() local btn for item_name, item_count in pairs(items) do - local localized_name = game.item_prototypes[item_name].localised_name[1] + local localized_name = prototypes.item[item_name].localised_name[1] if container.requested_item and tbl[container.requested_item] then tbl[container.requested_item].number = item_count else diff --git a/maps/mountain_fortress_v3/locomotive.lua b/maps/mountain_fortress_v3/locomotive.lua index 388e440f..40379e3a 100644 --- a/maps/mountain_fortress_v3/locomotive.lua +++ b/maps/mountain_fortress_v3/locomotive.lua @@ -67,7 +67,7 @@ local function add_random_loot_to_main_market(rarity) return false end - local types = game.item_prototypes + local types = prototypes.item for k, v in pairs(main_market_items) do if not v.static then diff --git a/maps/mountain_fortress_v3/loot.lua b/maps/mountain_fortress_v3/loot.lua index 605a2907..b5f4ef28 100644 --- a/maps/mountain_fortress_v3/loot.lua +++ b/maps/mountain_fortress_v3/loot.lua @@ -48,7 +48,7 @@ function Public.add_loot(surface, position, chest, collision) local result = base_amount + budget + distance_mod - local c = game.entity_prototypes[chest] + local c = prototypes.entity[chest] local slots = c.get_inventory_size(defines.inventory.chest) local item_stacks = LootRaffle.roll(result, slots, blacklist) @@ -61,7 +61,7 @@ function Public.add_loot(surface, position, chest, collision) end end - local container = surface.create_entity({name = chest, position = new_position, force = 'neutral', create_build_effect_smoke = false}) + local container = surface.create_entity({ name = chest, position = new_position, force = 'neutral', create_build_effect_smoke = false }) for _, item_stack in pairs(item_stacks) do container.insert(item_stack) @@ -69,20 +69,20 @@ function Public.add_loot(surface, position, chest, collision) container.minable = false if random(1, 8) == 1 then - container.insert({name = 'coin', count = random(1, 32)}) + container.insert({ name = 'coin', count = random(1, 32) }) elseif random(1, 32) == 1 then - container.insert({name = 'coin', count = random(1, 128)}) + container.insert({ name = 'coin', count = random(1, 128) }) elseif random(1, 128) == 1 then - container.insert({name = 'coin', count = random(1, 256)}) + container.insert({ name = 'coin', count = random(1, 256) }) elseif random(1, 256) == 1 then - container.insert({name = 'coin', count = random(1, 512)}) + container.insert({ name = 'coin', count = random(1, 512) }) elseif random(1, 512) == 1 then - container.insert({name = 'coin', count = random(1, 1024)}) + container.insert({ name = 'coin', count = random(1, 1024) }) end for _ = 1, 3, 1 do if random(1, 16) == 1 then - container.insert({name = 'explosives', count = random(25, 50)}) + container.insert({ name = 'explosives', count = random(25, 50) }) else break end @@ -111,31 +111,31 @@ function Public.add_loot_rare(surface, position, chest, magic) local result = base_amount + budget + distance_mod - local c = game.entity_prototypes[chest] + local c = prototypes.entity[chest] local slots = c.get_inventory_size(defines.inventory.chest) local item_stacks = LootRaffle.roll(result, slots, blacklist) - local container = surface.create_entity({name = chest, position = position, force = 'neutral', create_build_effect_smoke = false}) + local container = surface.create_entity({ name = chest, position = position, force = 'neutral', create_build_effect_smoke = false }) for _, item_stack in pairs(item_stacks) do container.insert(item_stack) end container.minable = false if random(1, 8) == 1 then - container.insert({name = 'coin', count = random(1, 32)}) + container.insert({ name = 'coin', count = random(1, 32) }) elseif random(1, 32) == 1 then - container.insert({name = 'coin', count = random(1, 128)}) + container.insert({ name = 'coin', count = random(1, 128) }) elseif random(1, 128) == 1 then - container.insert({name = 'coin', count = random(1, 256)}) + container.insert({ name = 'coin', count = random(1, 256) }) elseif random(1, 256) == 1 then - container.insert({name = 'coin', count = random(1, 512)}) + container.insert({ name = 'coin', count = random(1, 512) }) elseif random(1, 512) == 1 then - container.insert({name = 'coin', count = random(1, 2048)}) + container.insert({ name = 'coin', count = random(1, 2048) }) end for _ = 1, 3, 1 do if random(1, 16) == 1 then - container.insert({name = 'explosives', count = random(25, 50)}) + container.insert({ name = 'explosives', count = random(25, 50) }) else break end diff --git a/maps/mountain_fortress_v3/mystical_chest.lua b/maps/mountain_fortress_v3/mystical_chest.lua index 1c25f789..005bd792 100644 --- a/maps/mountain_fortress_v3/mystical_chest.lua +++ b/maps/mountain_fortress_v3/mystical_chest.lua @@ -440,7 +440,7 @@ function Public.roll_item_stack(remaining_budget, blacklist) end end - local stack_size = game.item_prototypes[item_name].stack_size * 32 + local stack_size = prototypes.item[item_name].stack_size * 32 local item_count = 1 diff --git a/maps/mountain_fortress_v3/rocks_yield_ore_veins.lua b/maps/mountain_fortress_v3/rocks_yield_ore_veins.lua index 5d6a68af..d06f1572 100644 --- a/maps/mountain_fortress_v3/rocks_yield_ore_veins.lua +++ b/maps/mountain_fortress_v3/rocks_yield_ore_veins.lua @@ -15,7 +15,7 @@ local this = { Global.register( this, - function(t) + function (t) this = t end ) @@ -27,22 +27,22 @@ local valid_entities = { } local size_raffle = { - {'giant', 65, 96}, - {'huge', 33, 64}, - {'big', 17, 32}, - {'small', 9, 16}, - {'tiny', 4, 8} + { 'giant', 65, 96 }, + { 'huge', 33, 64 }, + { 'big', 17, 32 }, + { 'small', 9, 16 }, + { 'tiny', 4, 8 } } local function get_chances() local chances = {} - table.insert(chances, {'iron-ore', 25}) - table.insert(chances, {'copper-ore', 18}) - table.insert(chances, {'mixed', 15}) - table.insert(chances, {'coal', 14}) - table.insert(chances, {'stone', 8}) - table.insert(chances, {'uranium-ore', 3}) + table.insert(chances, { 'iron-ore', 25 }) + table.insert(chances, { 'copper-ore', 18 }) + table.insert(chances, { 'mixed', 15 }) + table.insert(chances, { 'coal', 14 }) + table.insert(chances, { 'stone', 8 }) + table.insert(chances, { 'uranium-ore', 3 }) return chances end @@ -55,7 +55,7 @@ local function set_raffle() end end - this.mixed_ores = {'iron-ore', 'copper-ore', 'stone', 'coal'} + this.mixed_ores = { 'iron-ore', 'copper-ore', 'stone', 'coal' } end local function get_amount(position) @@ -66,14 +66,14 @@ local function get_amount(position) end local function draw_chain(surface, count, ore, ore_entities, ore_positions) - local vectors = {{0, -1}, {-1, 0}, {1, 0}, {0, 1}} + local vectors = { { 0, -1 }, { -1, 0 }, { 1, 0 }, { 0, 1 } } local r = random(1, #ore_entities) - local position = {x = ore_entities[r].position.x, y = ore_entities[r].position.y} + local position = { x = ore_entities[r].position.x, y = ore_entities[r].position.y } for _ = 1, count, 1 do table.shuffle_table(vectors) for i = 1, 4, 1 do - local p = {x = position.x + vectors[i][1], y = position.y + vectors[i][2]} - if surface.can_place_entity({name = 'coal', position = p, amount = 1}) then + local p = { x = position.x + vectors[i][1], y = position.y + vectors[i][2] } + if surface.can_place_entity({ name = 'coal', position = p, amount = 1 }) then if not ore_positions[p.x .. '_' .. p.y] then position.x = p.x position.y = p.y @@ -82,7 +82,7 @@ local function draw_chain(surface, count, ore, ore_entities, ore_positions) if ore == 'mixed' then name = this.mixed_ores[random(1, #this.mixed_ores)] end - ore_entities[#ore_entities + 1] = {name = name, position = p, amount = get_amount(position)} + ore_entities[#ore_entities + 1] = { name = name, position = p, amount = get_amount(position) } break end end @@ -95,7 +95,7 @@ local function ore_vein(player, entity) local size = size_raffle[random(1, #size_raffle)] local ore = this.raffle[random(1, #this.raffle)] local icon - if game.entity_prototypes[ore] then + if prototypes.entity[ore] then icon = '[img=entity/' .. ore .. ']' else icon = ' ' @@ -104,20 +104,20 @@ local function ore_vein(player, entity) player.print( { 'rocks_yield_ore_veins.player_print', - {'rocks_yield_ore_veins_colors.' .. ore}, - {'rocks_yield_ore_veins.' .. size[1]}, - {'rocks_yield_ore_veins.' .. ore}, + { 'rocks_yield_ore_veins_colors.' .. ore }, + { 'rocks_yield_ore_veins.' .. size[1] }, + { 'rocks_yield_ore_veins.' .. ore }, icon }, - {r = 0.80, g = 0.80, b = 0.80} + { r = 0.80, g = 0.80, b = 0.80 } ) - local ore_entities = {{name = ore, position = {x = entity.position.x, y = entity.position.y}, amount = get_amount(entity.position)}} + local ore_entities = { { name = ore, position = { x = entity.position.x, y = entity.position.y }, amount = get_amount(entity.position) } } if ore == 'mixed' then ore_entities = { { name = this.mixed_ores[random(1, #this.mixed_ores)], - position = {x = entity.position.x, y = entity.position.y}, + position = { x = entity.position.x, y = entity.position.y }, amount = get_amount(entity.position) } } @@ -125,7 +125,7 @@ local function ore_vein(player, entity) StatData.get_data(player):increase('ore_veins') - local ore_positions = {[entity.position.x .. '_' .. entity.position.y] = true} + local ore_positions = { [entity.position.x .. '_' .. entity.position.y] = true } local count = random(size[2], size[3]) for _ = 1, 128, 1 do diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index 4dc659c3..03a9b0fd 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -1350,7 +1350,7 @@ local function event_on_research_finished(event) -- using a localised string means we have to write this out (recall that "" signals concatenation) memory.force.print({ "", '>> ', { 'pirates.research_notification', research.localised_name } }, CoreData.colors.notify_force_light) - Server.to_discord_embed_raw({ '', '[' .. memory.name .. '] ', { 'pirates.research_notification', game.technology_prototypes[research.name].localised_name } }, true) + Server.to_discord_embed_raw({ '', '[' .. memory.name .. '] ', { 'pirates.research_notification', prototypes.technology[research.name].localised_name } }, true) end for _, e in ipairs(research.effects) do diff --git a/maps/pirates/surfaces/cabin.lua b/maps/pirates/surfaces/cabin.lua index 3bafff20..04d68d8a 100644 --- a/maps/pirates/surfaces/cabin.lua +++ b/maps/pirates/surfaces/cabin.lua @@ -201,7 +201,7 @@ function Public.create_cabin_surface() filter = 'coal' elseif splitter.type <= 6 then priority = 'right' - filter = game.item_prototypes[CoreData.cost_items[splitter.type].name] + filter = prototypes.item[CoreData.cost_items[splitter.type].name] elseif splitter.type == 7 then priority = 'left' elseif splitter.type == 8 then diff --git a/maps/railway_troopers/main.lua b/maps/railway_troopers/main.lua index 3632a94a..ab29052f 100644 --- a/maps/railway_troopers/main.lua +++ b/maps/railway_troopers/main.lua @@ -343,7 +343,7 @@ local function on_init() ['capsule'] = true } - for _, recipe in pairs(game.recipe_prototypes) do + for _, recipe in pairs(prototypes.recipe) do if types_to_disable[recipe.subgroup.name] then force.set_hand_crafting_disabled_for_recipe(recipe.name, true) end diff --git a/maps/railway_troopers_v2/main.lua b/maps/railway_troopers_v2/main.lua index 65abf6dc..5502b49a 100644 --- a/maps/railway_troopers_v2/main.lua +++ b/maps/railway_troopers_v2/main.lua @@ -134,7 +134,7 @@ local function map_reset() ['gun'] = true, ['capsule'] = true } - for _, recipe in pairs(game.recipe_prototypes) do + for _, recipe in pairs(prototypes.recipe) do if types_to_disable[recipe.subgroup.name] then force.set_hand_crafting_disabled_for_recipe(recipe.name, true) end diff --git a/maps/rivers.lua b/maps/rivers.lua index 04965dab..9882a43a 100644 --- a/maps/rivers.lua +++ b/maps/rivers.lua @@ -16,7 +16,7 @@ local disabled_for_deconstruction = { ['fish'] = true } -local rock_raffle = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'} +local rock_raffle = { 'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge' } local tile_replacements = { ['water'] = 'grass-2', @@ -75,26 +75,26 @@ local connections = 0.08 local function process_tiles(surface, pos, noise, noise_2) local tile = surface.get_tile(pos) if tile_replacements[tile.name] then - surface.set_tiles({{name = tile_replacements[tile.name], position = pos}}, true) + surface.set_tiles({ { name = tile_replacements[tile.name], position = pos } }, true) end if noise > water_level * -1 and noise < water_level then if noise_2 < connections * -1 or noise_2 > connections then - surface.set_tiles({{name = 'water', position = pos}}, true) + surface.set_tiles({ { name = 'water', position = pos } }, true) if math_random(1, 256) == 1 then - surface.create_entity({name = 'fish', position = pos}) + surface.create_entity({ name = 'fish', position = pos }) end return else if math_random(1, 2) == 1 then - surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = pos}) + surface.create_entity({ name = rock_raffle[math_random(1, #rock_raffle)], position = pos }) end end end end local function process_entities(surface, pos, noise, noise_2) - if not surface.can_place_entity({name = 'iron-ore', position = pos, amount = 1}) then + if not surface.can_place_entity({ name = 'iron-ore', position = pos, amount = 1 }) then return end @@ -102,10 +102,10 @@ local function process_entities(surface, pos, noise, noise_2) local distance_to_center = math.sqrt(pos.x ^ 2 + pos.y ^ 2) local amount = (600 + distance_to_center) * math.abs(noise) if math.floor(noise * 15) % 3 ~= 0 then - surface.create_entity({name = 'iron-ore', position = pos, amount = amount}) + surface.create_entity({ name = 'iron-ore', position = pos, amount = amount }) return else - surface.create_entity({name = 'coal', position = pos, amount = amount}) + surface.create_entity({ name = 'coal', position = pos, amount = amount }) return end end @@ -114,10 +114,10 @@ local function process_entities(surface, pos, noise, noise_2) local distance_to_center = math.sqrt(pos.x ^ 2 + pos.y ^ 2) local amount = (600 + distance_to_center) * math.abs(noise) if math.floor(noise * 15) % 3 ~= 0 then - surface.create_entity({name = 'copper-ore', position = pos, amount = amount}) + surface.create_entity({ name = 'copper-ore', position = pos, amount = amount }) return else - surface.create_entity({name = 'stone', position = pos, amount = amount}) + surface.create_entity({ name = 'stone', position = pos, amount = amount }) return end end @@ -134,7 +134,7 @@ local function on_chunk_generated(event) for x = 0, 31, 1 do for y = 0, 31, 1 do - local pos = {x = left_top.x + x, y = left_top.y + y} + local pos = { x = left_top.x + x, y = left_top.y + y } local noise_1 = get_noise(1, pos) local noise_2 = get_noise(2, pos) process_tiles(surface, pos, noise_1, noise_2) @@ -143,12 +143,12 @@ local function on_chunk_generated(event) end local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end end - surface.regenerate_decorative(decorative_names, {{left_top.x / 32, left_top.y / 32}}) + surface.regenerate_decorative(decorative_names, { { left_top.x / 32, left_top.y / 32 } }) end local function init_map() @@ -159,15 +159,15 @@ local function init_map() local map_gen_settings = {} map_gen_settings.water = '0' map_gen_settings.starting_area = '1' - map_gen_settings.cliff_settings = {cliff_elevation_interval = 22, cliff_elevation_0 = 22} + map_gen_settings.cliff_settings = { cliff_elevation_interval = 22, cliff_elevation_0 = 22 } map_gen_settings.autoplace_controls = { - ['coal'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['stone'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['copper-ore'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['iron-ore'] = {frequency = 'none', size = 'none', richness = 'none'}, - ['crude-oil'] = {frequency = '4', size = '1', richness = '1'}, - ['trees'] = {frequency = '4', size = '1', richness = '1'}, - ['enemy-base'] = {frequency = '50', size = '1.5', richness = '1'} + ['coal'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['stone'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['copper-ore'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['iron-ore'] = { frequency = 'none', size = 'none', richness = 'none' }, + ['crude-oil'] = { frequency = '4', size = '1', richness = '1' }, + ['trees'] = { frequency = '4', size = '1', richness = '1' }, + ['enemy-base'] = { frequency = '50', size = '1.5', richness = '1' } } game.create_surface('rivers', map_gen_settings) @@ -178,13 +178,13 @@ local function init_map() game.map_settings.enemy_expansion.min_expansion_cooldown = 18000 game.map_settings.enemy_expansion.max_expansion_cooldown = 36000 - surface.request_to_generate_chunks({0, 0}, 3) + surface.request_to_generate_chunks({ 0, 0 }, 3) surface.force_generate_chunk_requests() - map_functions.draw_smoothed_out_ore_circle({x = -3, y = -3}, 'iron-ore', surface, 8, 5000) - map_functions.draw_smoothed_out_ore_circle({x = 3, y = 3}, 'copper-ore', surface, 8, 5000) - map_functions.draw_smoothed_out_ore_circle({x = 3, y = -3}, 'stone', surface, 8, 5000) - map_functions.draw_smoothed_out_ore_circle({x = -3, y = 3}, 'coal', surface, 8, 5000) + map_functions.draw_smoothed_out_ore_circle({ x = -3, y = -3 }, 'iron-ore', surface, 8, 5000) + map_functions.draw_smoothed_out_ore_circle({ x = 3, y = 3 }, 'copper-ore', surface, 8, 5000) + map_functions.draw_smoothed_out_ore_circle({ x = 3, y = -3 }, 'stone', surface, 8, 5000) + map_functions.draw_smoothed_out_ore_circle({ x = -3, y = 3 }, 'coal', surface, 8, 5000) end local function on_player_joined_game(event) @@ -192,9 +192,9 @@ local function on_player_joined_game(event) local player = game.players[event.player_index] if player.online_time == 0 then - player.insert({name = 'iron-plate', count = 32}) - player.insert({name = 'iron-gear-wheel', count = 16}) - player.teleport(game.surfaces['rivers'].find_non_colliding_position('character', {0, 2}, 50, 0.5), 'rivers') + player.insert({ name = 'iron-plate', count = 32 }) + player.insert({ name = 'iron-gear-wheel', count = 16 }) + player.teleport(game.surfaces['rivers'].find_non_colliding_position('character', { 0, 2 }, 50, 0.5), 'rivers') end end diff --git a/maps/scrap_towny_ffa/rocks_yield_ore_veins.lua b/maps/scrap_towny_ffa/rocks_yield_ore_veins.lua index 3f6956de..09e6911f 100644 --- a/maps/scrap_towny_ffa/rocks_yield_ore_veins.lua +++ b/maps/scrap_towny_ffa/rocks_yield_ore_veins.lua @@ -14,21 +14,21 @@ local valid_entities = { } local size_raffle = { - {'giant', 500, 1000}, - {'huge', 300, 500}, - {'big', 150, 300}, - {'small', 80, 150}, - {'tiny', 50, 80} + { 'giant', 500, 1000 }, + { 'huge', 300, 500 }, + { 'big', 150, 300 }, + { 'small', 80, 150 }, + { 'tiny', 50, 80 } } local function get_chances() local chances = {} - table_insert(chances, {'iron-ore', 24}) - table_insert(chances, {'copper-ore', 18}) - table_insert(chances, {'mixed', 12}) - table_insert(chances, {'coal', 14}) - table_insert(chances, {'stone', 12}) - table_insert(chances, {'uranium-ore', 8}) + table_insert(chances, { 'iron-ore', 24 }) + table_insert(chances, { 'copper-ore', 18 }) + table_insert(chances, { 'mixed', 12 }) + table_insert(chances, { 'coal', 14 }) + table_insert(chances, { 'stone', 12 }) + table_insert(chances, { 'uranium-ore', 8 }) return chances end @@ -40,7 +40,7 @@ local function set_raffle() table_insert(this.rocks_yield_ore_veins.raffle, t[1]) end end - this.rocks_yield_ore_veins.mixed_ores = {'iron-ore', 'copper-ore', 'stone', 'coal'} + this.rocks_yield_ore_veins.mixed_ores = { 'iron-ore', 'copper-ore', 'stone', 'coal' } end local function get_amount() @@ -49,35 +49,35 @@ end local function draw_chain(surface, count, ore, ore_entities, ore_positions) local this = ScenarioTable.get_table() - local vectors = {{0, -0.75}, {-0.75, 0}, {0.75, 0}, {0, 0.75}} + local vectors = { { 0, -0.75 }, { -0.75, 0 }, { 0.75, 0 }, { 0, 0.75 } } local r = math_random(1, #ore_entities) - local position = {x = ore_entities[r].ore.position.x, y = ore_entities[r].ore.position.y} + local position = { x = ore_entities[r].ore.position.x, y = ore_entities[r].ore.position.y } for _ = 1, count, 1 do table_shuffle(vectors) for i = 1, 4, 1 do - local p = {x = position.x + vectors[i][1], y = position.y + vectors[i][2]} + local p = { x = position.x + vectors[i][1], y = position.y + vectors[i][2] } -- dispersion will make patches more round local dx = (math_random(0, 100) - 50) / 100 local dy = (math_random(0, 100) - 50) / 100 - local dp = {x = p.x + dx, y = p.y + dy} + local dp = { x = p.x + dx, y = p.y + dy } local name = ore if ore == 'mixed' then name = this.rocks_yield_ore_veins.mixed_ores[math_random(1, #this.rocks_yield_ore_veins.mixed_ores)] end - if surface.can_place_entity({name = name, position = p, force = 'neutral'}) then + if surface.can_place_entity({ name = name, position = p, force = 'neutral' }) then if math_random(1, 2) == 1 then if not ore_positions[p.x .. '_' .. p.y] then position.x = p.x position.y = p.y ore_positions[p.x .. '_' .. p.y] = true - ore_entities[#ore_entities + 1] = {ore = {name = name, position = dp}, amount = get_amount()} + ore_entities[#ore_entities + 1] = { ore = { name = name, position = dp }, amount = get_amount() } break end end else -- existing ore of same name - if surface.can_fast_replace({name = name, position = p, force = 'neutral'}) then + if surface.can_fast_replace({ name = name, position = p, force = 'neutral' }) then local amount = get_amount() local deposit = surface.find_entity(name, p) if deposit ~= nil then @@ -86,7 +86,7 @@ local function draw_chain(surface, count, ore, ore_entities, ore_positions) position.x = p.x position.y = p.y ore_positions[p.x .. '_' .. p.y] = true - ore_entities[#ore_entities + 1] = {ore = {name = name, position = dp}, amount = amount, fast_replace = true} + ore_entities[#ore_entities + 1] = { ore = { name = name, position = dp }, amount = amount, fast_replace = true } break end end @@ -102,7 +102,7 @@ local function ore_vein(event) local size = size_raffle[math_random(1, #size_raffle)] local ore = this.rocks_yield_ore_veins.raffle[math_random(1, #this.rocks_yield_ore_veins.raffle)] local icon - if game.entity_prototypes[ore] then + if prototypes.entity[ore] then icon = '[img=entity/' .. ore .. ']' else icon = ' ' @@ -114,12 +114,12 @@ local function ore_vein(event) p.print( { 'rocks_yield_ore_veins.player_print', - {'rocks_yield_ore_veins_colors.' .. ore}, - {'rocks_yield_ore_veins.' .. size[1]}, - {'rocks_yield_ore_veins.' .. ore}, + { 'rocks_yield_ore_veins_colors.' .. ore }, + { 'rocks_yield_ore_veins.' .. size[1] }, + { 'rocks_yield_ore_veins.' .. ore }, icon }, - {r = 0.80, g = 0.80, b = 0.80} + { r = 0.80, g = 0.80, b = 0.80 } ) else if p.force == player.force then @@ -127,31 +127,31 @@ local function ore_vein(event) { 'rocks_yield_ore_veins.game_print', '[color=' .. player.chat_color.r .. ',' .. player.chat_color.g .. ',' .. player.chat_color.b .. ']' .. player.name .. '[/color]', - {'rocks_yield_ore_veins.' .. size[1]}, - {'rocks_yield_ore_veins.' .. ore}, + { 'rocks_yield_ore_veins.' .. size[1] }, + { 'rocks_yield_ore_veins.' .. ore }, icon }, - {r = 0.80, g = 0.80, b = 0.80} + { r = 0.80, g = 0.80, b = 0.80 } ) end end end local position = event.entity.position - local ore_entities = {{ore = {name = ore, position = {x = position.x, y = position.y}}, amount = get_amount()}} + local ore_entities = { { ore = { name = ore, position = { x = position.x, y = position.y } }, amount = get_amount() } } if ore == 'mixed' then ore_entities = { { ore = { name = this.rocks_yield_ore_veins.mixed_ores[math_random(1, #this.rocks_yield_ore_veins.mixed_ores)], - position = {x = position.x, y = position.y} + position = { x = position.x, y = position.y } }, amount = get_amount() } } end - local ore_positions = {[event.entity.position.x .. '_' .. event.entity.position.y] = true} + local ore_positions = { [event.entity.position.x .. '_' .. event.entity.position.y] = true } local count = math_random(size[2], size[3]) for _ = 1, 128, 1 do diff --git a/maps/scrap_towny_ffa/slots.lua b/maps/scrap_towny_ffa/slots.lua index f688ea17..a6ab6825 100644 --- a/maps/scrap_towny_ffa/slots.lua +++ b/maps/scrap_towny_ffa/slots.lua @@ -21,10 +21,10 @@ local function on_built_entity(event) name = 'flying-text', position = entity.position, text = 'You are not acclimated to this technology!', - color = {r = 0.77, g = 0.0, b = 0.0} + color = { r = 0.77, g = 0.0, b = 0.0 } } ) - player.insert({name = 'laser-turret', count = 1}) + player.insert({ name = 'laser-turret', count = 1 }) entity.destroy() return end @@ -37,10 +37,10 @@ local function on_built_entity(event) name = 'flying-text', position = entity.position, text = 'You do not have enough slots!', - color = {r = 0.77, g = 0.0, b = 0.0} + color = { r = 0.77, g = 0.0, b = 0.0 } } ) - player.insert({name = 'laser-turret', count = 1}) + player.insert({ name = 'laser-turret', count = 1 }) entity.destroy() return end @@ -56,7 +56,7 @@ local function on_built_entity(event) name = 'flying-text', position = entity.position, text = 'Using ' .. locations .. '/' .. slots .. ' slots', - color = {r = 1.0, g = 1.0, b = 1.0} + color = { r = 1.0, g = 1.0, b = 1.0 } } ) end @@ -81,10 +81,10 @@ local function on_robot_built_entity(event) name = 'flying-text', position = entity.position, text = 'Robot not acclimated to this technology!', - color = {r = 0.77, g = 0.0, b = 0.0} + color = { r = 0.77, g = 0.0, b = 0.0 } } ) - robot.insert({name = 'laser-turret', count = 1}) + robot.insert({ name = 'laser-turret', count = 1 }) entity.destroy() return end @@ -96,10 +96,10 @@ local function on_robot_built_entity(event) name = 'flying-text', position = entity.position, text = 'Town does not have enough slots!', - color = {r = 0.77, g = 0.0, b = 0.0} + color = { r = 0.77, g = 0.0, b = 0.0 } } ) - robot.insert({name = 'laser-turret', count = 1}) + robot.insert({ name = 'laser-turret', count = 1 }) entity.destroy() return end @@ -115,7 +115,7 @@ local function on_robot_built_entity(event) name = 'flying-text', position = entity.position, text = 'Using ' .. locations .. '/' .. slots .. ' slots', - color = {r = 1.0, g = 1.0, b = 1.0} + color = { r = 1.0, g = 1.0, b = 1.0 } } ) end diff --git a/maps/spooky_forest.lua b/maps/spooky_forest.lua index dd19f15e..6a121c43 100644 --- a/maps/spooky_forest.lua +++ b/maps/spooky_forest.lua @@ -77,47 +77,47 @@ local rock_raffle = { 'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', local function secret_shop(pos, surface) local secret_market_items = { - { price = { { 'raw-fish', math_random(75, 125) } }, offer = { type = 'give-item', item = 'combat-shotgun' } }, - { price = { { 'raw-fish', math_random(40, 60) } }, offer = { type = 'give-item', item = 'rocket-launcher' } }, - { price = { { 'raw-fish', math_random(1, 2) } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine' } }, - { price = { { 'raw-fish', math_random(3, 6) } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine' } }, - { price = { { 'raw-fish', math_random(1, 4) } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell' } }, - { price = { { 'raw-fish', math_random(1, 2) } }, offer = { type = 'give-item', item = 'rocket' } }, - { price = { { 'raw-fish', math_random(2, 3) } }, offer = { type = 'give-item', item = 'explosive-rocket' } }, - { price = { { 'raw-fish', math_random(1, 2) } }, offer = { type = 'give-item', item = 'explosive-cannon-shell' } }, - { price = { { 'raw-fish', math_random(3, 6) } }, offer = { type = 'give-item', item = 'explosive-uranium-cannon-shell' } }, - { price = { { 'raw-fish', math_random(4, 8) } }, offer = { type = 'give-item', item = 'cluster-grenade' } }, - { price = { { 'raw-fish', math_random(1, 2) } }, offer = { type = 'give-item', item = 'land-mine' } }, - { price = { { 'raw-fish', math_random(25, 50) } }, offer = { type = 'give-item', item = 'heavy-armor' } }, + { price = { { 'raw-fish', math_random(75, 125) } }, offer = { type = 'give-item', item = 'combat-shotgun' } }, + { price = { { 'raw-fish', math_random(40, 60) } }, offer = { type = 'give-item', item = 'rocket-launcher' } }, + { price = { { 'raw-fish', math_random(1, 2) } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine' } }, + { price = { { 'raw-fish', math_random(3, 6) } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine' } }, + { price = { { 'raw-fish', math_random(1, 4) } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell' } }, + { price = { { 'raw-fish', math_random(1, 2) } }, offer = { type = 'give-item', item = 'rocket' } }, + { price = { { 'raw-fish', math_random(2, 3) } }, offer = { type = 'give-item', item = 'explosive-rocket' } }, + { price = { { 'raw-fish', math_random(1, 2) } }, offer = { type = 'give-item', item = 'explosive-cannon-shell' } }, + { price = { { 'raw-fish', math_random(3, 6) } }, offer = { type = 'give-item', item = 'explosive-uranium-cannon-shell' } }, + { price = { { 'raw-fish', math_random(4, 8) } }, offer = { type = 'give-item', item = 'cluster-grenade' } }, + { price = { { 'raw-fish', math_random(1, 2) } }, offer = { type = 'give-item', item = 'land-mine' } }, + { price = { { 'raw-fish', math_random(25, 50) } }, offer = { type = 'give-item', item = 'heavy-armor' } }, { price = { { 'raw-fish', math_random(125, 250) } }, offer = { type = 'give-item', item = 'modular-armor' } }, { price = { { 'raw-fish', math_random(300, 600) } }, offer = { type = 'give-item', item = 'power-armor' } }, { price = { { 'raw-fish', math_random(300, 600) } }, offer = { type = 'give-item', item = 'fusion-reactor-equipment' } }, - { price = { { 'raw-fish', math_random(20, 40) } }, offer = { type = 'give-item', item = 'battery-equipment' } }, + { price = { { 'raw-fish', math_random(20, 40) } }, offer = { type = 'give-item', item = 'battery-equipment' } }, { price = { { 'raw-fish', math_random(100, 150) } }, offer = { type = 'give-item', item = 'belt-immunity-equipment' } }, - { price = { { 'raw-fish', math_random(40, 80) } }, offer = { type = 'give-item', item = 'night-vision-equipment' } }, - { price = { { 'raw-fish', math_random(60, 120) } }, offer = { type = 'give-item', item = 'exoskeleton-equipment' } }, - { price = { { 'raw-fish', math_random(60, 120) } }, offer = { type = 'give-item', item = 'personal-roboport-equipment' } }, - { price = { { 'raw-fish', math_random(3, 9) } }, offer = { type = 'give-item', item = 'construction-robot' } }, + { price = { { 'raw-fish', math_random(40, 80) } }, offer = { type = 'give-item', item = 'night-vision-equipment' } }, + { price = { { 'raw-fish', math_random(60, 120) } }, offer = { type = 'give-item', item = 'exoskeleton-equipment' } }, + { price = { { 'raw-fish', math_random(60, 120) } }, offer = { type = 'give-item', item = 'personal-roboport-equipment' } }, + { price = { { 'raw-fish', math_random(3, 9) } }, offer = { type = 'give-item', item = 'construction-robot' } }, { price = { { 'raw-fish', math_random(100, 200) } }, offer = { type = 'give-item', item = 'energy-shield-equipment' } }, { price = { { 'raw-fish', math_random(200, 400) } }, offer = { type = 'give-item', item = 'personal-laser-defense-equipment' } }, - { price = { { 'raw-fish', math_random(30, 60) } }, offer = { type = 'give-item', item = 'loader' } }, - { price = { { 'raw-fish', math_random(50, 80) } }, offer = { type = 'give-item', item = 'fast-loader' } }, - { price = { { 'raw-fish', math_random(70, 100) } }, offer = { type = 'give-item', item = 'express-loader' } }, - { price = { { 'raw-fish', math_random(30, 60) } }, offer = { type = 'give-item', item = 'locomotive' } }, - { price = { { 'raw-fish', math_random(15, 35) } }, offer = { type = 'give-item', item = 'cargo-wagon' } }, - { price = { { 'raw-fish', math_random(1, 4) } }, offer = { type = 'give-item', item = 'grenade' } }, - { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'rail', count = 4 } }, + { price = { { 'raw-fish', math_random(30, 60) } }, offer = { type = 'give-item', item = 'loader' } }, + { price = { { 'raw-fish', math_random(50, 80) } }, offer = { type = 'give-item', item = 'fast-loader' } }, + { price = { { 'raw-fish', math_random(70, 100) } }, offer = { type = 'give-item', item = 'express-loader' } }, + { price = { { 'raw-fish', math_random(30, 60) } }, offer = { type = 'give-item', item = 'locomotive' } }, + { price = { { 'raw-fish', math_random(15, 35) } }, offer = { type = 'give-item', item = 'cargo-wagon' } }, + { price = { { 'raw-fish', math_random(1, 4) } }, offer = { type = 'give-item', item = 'grenade' } }, + { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'rail', count = 4 } }, -- {price = {{"raw-fish", 1}}, offer = {type = 'give-item', item = 'rail-signal', count = 2}}, -- {price = {{"raw-fish", 1}}, offer = {type = 'give-item', item = 'rail-chain-signal', count = 2}}, - { price = { { 'raw-fish', 5 } }, offer = { type = 'give-item', item = 'train-stop' } }, - { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'small-lamp' } }, - { price = { { 'raw-fish', 2 } }, offer = { type = 'give-item', item = 'firearm-magazine' } }, - { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'wood', count = math_random(25, 75) } }, - { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'iron-ore', count = math_random(25, 75) } }, - { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'copper-ore', count = math_random(25, 75) } }, - { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'stone', count = math_random(25, 75) } }, - { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'coal', count = math_random(25, 75) } }, - { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'uranium-ore', count = math_random(25, 75) } } + { price = { { 'raw-fish', 5 } }, offer = { type = 'give-item', item = 'train-stop' } }, + { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'small-lamp' } }, + { price = { { 'raw-fish', 2 } }, offer = { type = 'give-item', item = 'firearm-magazine' } }, + { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'wood', count = math_random(25, 75) } }, + { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'iron-ore', count = math_random(25, 75) } }, + { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'copper-ore', count = math_random(25, 75) } }, + { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'stone', count = math_random(25, 75) } }, + { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'coal', count = math_random(25, 75) } }, + { price = { { 'raw-fish', 1 } }, offer = { type = 'give-item', item = 'uranium-ore', count = math_random(25, 75) } } } secret_market_items = shuffle(secret_market_items) @@ -270,7 +270,7 @@ local function regenerate_decoratives_for_chunk(surface, position) local chunk = get_chunk_position(position) surface.destroy_decoratives({ area = { { chunk.x * 32, chunk.y * 32 }, { chunk.x * 32 + 32, chunk.y * 32 + 32 } } }) local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/stone_maze/main.lua b/maps/stone_maze/main.lua index ca167065..0381279a 100644 --- a/maps/stone_maze/main.lua +++ b/maps/stone_maze/main.lua @@ -187,7 +187,7 @@ local function regenerate_decoratives(surface, position) end surface.destroy_decoratives({ area = { { chunk.x * 32, chunk.y * 32 }, { chunk.x * 32 + 32, chunk.y * 32 + 32 } } }) local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/stoneblock.lua b/maps/stoneblock.lua index bb46dfa4..dcb93a8f 100644 --- a/maps/stoneblock.lua +++ b/maps/stoneblock.lua @@ -232,7 +232,7 @@ local function generate_north_chunk(area, surface) end local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end diff --git a/maps/tank_battles.lua b/maps/tank_battles.lua index bb805915..93bd51dd 100644 --- a/maps/tank_battles.lua +++ b/maps/tank_battles.lua @@ -15,7 +15,7 @@ local random = math.random Global.register( this, - function(tbl) + function (tbl) this = tbl end ) @@ -39,25 +39,25 @@ local tile_blacklist = { } local loot = { - {{name = 'flamethrower-ammo', count = 16}, weight = 2}, - {{name = 'piercing-shotgun-shell', count = 16}, weight = 2}, - {{name = 'explosive-rocket', count = 8}, weight = 2}, - {{name = 'rocket', count = 8}, weight = 2}, - {{name = 'grenade', count = 16}, weight = 2}, - {{name = 'cluster-grenade', count = 8}, weight = 2}, - {{name = 'defender-capsule', count = 6}, weight = 1}, - {{name = 'distractor-capsule', count = 3}, weight = 1}, - {{name = 'cannon-shell', count = 8}, weight = 16}, - {{name = 'explosive-cannon-shell', count = 8}, weight = 16}, - {{name = 'uranium-cannon-shell', count = 8}, weight = 6}, - {{name = 'explosive-uranium-cannon-shell', count = 8}, weight = 6}, - {{name = 'energy-shield-equipment', count = 1}, weight = 2}, - {{name = 'fusion-reactor-equipment', count = 1}, weight = 2}, - {{name = 'repair-pack', count = 1}, weight = 6}, - {{name = 'coal', count = 16}, weight = 3}, - {{name = 'nuclear-fuel', count = 1}, weight = 1}, - {{name = 'gate', count = 16}, weight = 2}, - {{name = 'stone-wall', count = 16}, weight = 2} + { { name = 'flamethrower-ammo', count = 16 }, weight = 2 }, + { { name = 'piercing-shotgun-shell', count = 16 }, weight = 2 }, + { { name = 'explosive-rocket', count = 8 }, weight = 2 }, + { { name = 'rocket', count = 8 }, weight = 2 }, + { { name = 'grenade', count = 16 }, weight = 2 }, + { { name = 'cluster-grenade', count = 8 }, weight = 2 }, + { { name = 'defender-capsule', count = 6 }, weight = 1 }, + { { name = 'distractor-capsule', count = 3 }, weight = 1 }, + { { name = 'cannon-shell', count = 8 }, weight = 16 }, + { { name = 'explosive-cannon-shell', count = 8 }, weight = 16 }, + { { name = 'uranium-cannon-shell', count = 8 }, weight = 6 }, + { { name = 'explosive-uranium-cannon-shell', count = 8 }, weight = 6 }, + { { name = 'energy-shield-equipment', count = 1 }, weight = 2 }, + { { name = 'fusion-reactor-equipment', count = 1 }, weight = 2 }, + { { name = 'repair-pack', count = 1 }, weight = 6 }, + { { name = 'coal', count = 16 }, weight = 3 }, + { { name = 'nuclear-fuel', count = 1 }, weight = 1 }, + { { name = 'gate', count = 16 }, weight = 2 }, + { { name = 'stone-wall', count = 16 }, weight = 2 } } local loot_raffle = {} for _, item in pairs(loot) do @@ -81,10 +81,10 @@ local function create_gui(player) return end - frame = player.gui.left.add({type = 'frame', name = 'status_players', direction = 'vertical'}) + frame = player.gui.left.add({ type = 'frame', name = 'status_players', direction = 'vertical' }) - local lbl = frame.add({type = 'label', caption = 'Waiting for more players before round starts.'}) - lbl.style.font_color = {r = 0.98, g = 0.66, b = 0.22} + local lbl = frame.add({ type = 'label', caption = 'Waiting for more players before round starts.' }) + lbl.style.font_color = { r = 0.98, g = 0.66, b = 0.22 } lbl.style.font = 'default-listbox' frame.visible = false @@ -142,9 +142,9 @@ local function create_tank_battle_score_gui() local scores = {} Core.iter_connected_players( - function(player_amp) + function (player_amp) if this.tank_battles_score[player_amp.index] then - insert(scores, {name = player_amp.name, score = this.tank_battles_score[player_amp.index], color = player_amp.color}) + insert(scores, { name = player_amp.name, score = this.tank_battles_score[player_amp.index], color = player_amp.color }) end end ) @@ -154,19 +154,19 @@ local function create_tank_battle_score_gui() end Core.iter_connected_players( - function(player) + function (player) local frame = player.gui.left['tank_battle_score'] if frame and frame.valid then frame.destroy() end - frame = player.gui.left.add({type = 'frame', name = 'tank_battle_score', direction = 'vertical'}) + frame = player.gui.left.add({ type = 'frame', name = 'tank_battle_score', direction = 'vertical' }) - local lbl = frame.add({type = 'label', caption = 'Won rounds'}) - lbl.style.font_color = {r = 0.98, g = 0.66, b = 0.22} + local lbl = frame.add({ type = 'label', caption = 'Won rounds' }) + lbl.style.font_color = { r = 0.98, g = 0.66, b = 0.22 } lbl.style.font = 'default-listbox' - local t = frame.add({type = 'table', column_count = 2}) + local t = frame.add({ type = 'table', column_count = 2 }) for _ = 1, #scores, 1 do for y = 1, #scores, 1 do @@ -186,11 +186,11 @@ local function create_tank_battle_score_gui() local player_name = scores[i].name local player_color = scores[i].color local player_score = scores[i].score - local l = t.add({type = 'label', caption = player_name}) - player_color = {r = player_color.r * 0.6 + 0.4, g = player_color.g * 0.6 + 0.4, b = player_color.b * 0.6 + 0.4, a = 1} + local l = t.add({ type = 'label', caption = player_name }) + player_color = { r = player_color.r * 0.6 + 0.4, g = player_color.g * 0.6 + 0.4, b = player_color.b * 0.6 + 0.4, a = 1 } l.style.font_color = player_color l.style.font = 'default-bold' - t.add({type = 'label', caption = player_score}) + t.add({ type = 'label', caption = player_score }) end end end @@ -202,20 +202,20 @@ local function get_valid_random_spawn_position(surface, chunks) for _, chunk in pairs(chunks) do if chunk.x * 32 < arena_size and chunk.y * 32 < arena_size and chunk.x * 32 >= arena_size * -1 and chunk.y * 32 >= arena_size * -1 then - local area = {{chunk.x * 32 - 64, chunk.y * 32 - 64}, {chunk.x * 32 + 64, chunk.y * 32 + 64}} - if surface.count_entities_filtered({name = 'tank', area = area}) == 0 then - local pos = surface.find_non_colliding_position('tank', {chunk.x * 32 + 16, chunk.y * 32 + 16}, 16, 8) + local area = { { chunk.x * 32 - 64, chunk.y * 32 - 64 }, { chunk.x * 32 + 64, chunk.y * 32 + 64 } } + if surface.count_entities_filtered({ name = 'tank', area = area }) == 0 then + local pos = surface.find_non_colliding_position('tank', { chunk.x * 32 + 16, chunk.y * 32 + 16 }, 16, 8) return pos end end end - local pos = surface.find_non_colliding_position('tank', {0, 0}, 32, 4) + local pos = surface.find_non_colliding_position('tank', { 0, 0 }, 32, 4) if pos then return pos end - return {0, 0} + return { 0, 0 } end local function put_players_into_arena() @@ -223,11 +223,11 @@ local function put_players_into_arena() local chunks = {} for chunk in surface.get_chunks() do - insert(chunks, {x = chunk.x, y = chunk.y}) + insert(chunks, { x = chunk.x, y = chunk.y }) end Core.iter_connected_players( - function(player) + function (player) local permissions_group = game.permissions.get_group('Default') permissions_group.add_player(player.name) @@ -238,22 +238,22 @@ local function put_players_into_arena() player.create_character() - player.insert({name = 'combat-shotgun', count = 1}) - player.insert({name = 'rocket-launcher', count = 1}) - player.insert({name = 'flamethrower', count = 1}) + player.insert({ name = 'combat-shotgun', count = 1 }) + player.insert({ name = 'rocket-launcher', count = 1 }) + player.insert({ name = 'flamethrower', count = 1 }) local pos = get_valid_random_spawn_position(surface, chunks) - player.force.chart(surface, {{x = -1 * arena_size, y = -1 * arena_size}, {x = arena_size, y = arena_size}}) + player.force.chart(surface, { { x = -1 * arena_size, y = -1 * arena_size }, { x = arena_size, y = arena_size } }) if pos then player.teleport(pos, surface) else pos = get_valid_random_spawn_position(surface, chunks) end - local tank = surface.create_entity({name = 'tank', force = game.forces[player.name], position = pos}) - tank.insert({name = 'coal', count = 24}) - tank.insert({name = 'cannon-shell', count = 16}) + local tank = surface.create_entity({ name = 'tank', force = game.forces[player.name], position = pos }) + tank.insert({ name = 'coal', count = 24 }) + tank.insert({ name = 'cannon-shell', count = 16 }) tank.set_driver(player) end ) @@ -261,7 +261,7 @@ end local function get_arena_layout_modifiers() this.arena_layout_modifiers = {} - local proto = game.entity_prototypes + local proto = prototypes.entity local tree_raffle = {} for _, e in pairs(proto) do @@ -274,7 +274,7 @@ local function get_arena_layout_modifiers() this.arena_layout_modifiers.arena_tree_noise = random(0, 75) * 0.01 local entity_raffle = {} - local types = {'furnace', 'assembling-machine', 'power-switch', 'programmable-speaker', 'reactor'} + local types = { 'furnace', 'assembling-machine', 'power-switch', 'programmable-speaker', 'reactor' } for _, e in pairs(proto) do for _, t in pairs(types) do if e.type == t then @@ -286,7 +286,7 @@ local function get_arena_layout_modifiers() local tile_raffle = {} - for _, t in pairs(game.tile_prototypes) do + for _, t in pairs(prototypes.tile) do if not tile_blacklist[t.name] then insert(tile_raffle, t.name) end @@ -298,12 +298,12 @@ end local function regenerate_arena() local surface = game.get_surface('nauvis') for chunk in surface.get_chunks() do - surface.set_chunk_generated_status({x = chunk.x, y = chunk.y}, defines.chunk_generated_status.custom_tiles) + surface.set_chunk_generated_status({ x = chunk.x, y = chunk.y }, defines.chunk_generated_status.custom_tiles) end this.noise_seed = nil ---@diagnostic disable-next-line: param-type-mismatch - surface.request_to_generate_chunks({0, 0}, math.ceil(arena_size / 32) + 3) + surface.request_to_generate_chunks({ 0, 0 }, math.ceil(arena_size / 32) + 3) get_arena_layout_modifiers() @@ -331,12 +331,12 @@ local function shrink_arena() for x = arena_size * -1, arena_size, 1 do for y = current_arena_size * -1 - shrink_width, current_arena_size * -1, 1 do - local pos = {x = x, y = y} + local pos = { x = x, y = y } local tile = surface.get_tile(pos.x, pos.y) if tile.name ~= 'water' and tile.name ~= 'deepwater' then if x > current_arena_size or y > current_arena_size or x < current_arena_size * -1 or y < current_arena_size * -1 then if random(1, 3) ~= 1 then - insert(tiles, {name = 'water', position = pos}) + insert(tiles, { name = 'water', position = pos }) end end end @@ -345,12 +345,12 @@ local function shrink_arena() for x = arena_size * -1, arena_size, 1 do for y = current_arena_size, current_arena_size + shrink_width, 1 do - local pos = {x = x, y = y} + local pos = { x = x, y = y } local tile = surface.get_tile(pos.x, pos.y) if tile.name ~= 'water' and tile.name ~= 'deepwater' then if x > current_arena_size or y > current_arena_size or x < current_arena_size * -1 or y < current_arena_size * -1 then if random(1, 3) ~= 1 then - insert(tiles, {name = 'water', position = pos}) + insert(tiles, { name = 'water', position = pos }) end end end @@ -359,12 +359,12 @@ local function shrink_arena() for x = current_arena_size * -1 - shrink_width, current_arena_size * -1, 1 do for y = arena_size * -1, arena_size, 1 do - local pos = {x = x, y = y} + local pos = { x = x, y = y } local tile = surface.get_tile(pos.x, pos.y) if tile.name ~= 'water' and tile.name ~= 'deepwater' then if x > current_arena_size or y > current_arena_size or x < current_arena_size * -1 or y < current_arena_size * -1 then if random(1, 3) ~= 1 then - insert(tiles, {name = 'water', position = pos}) + insert(tiles, { name = 'water', position = pos }) end end end @@ -373,12 +373,12 @@ local function shrink_arena() for x = current_arena_size, current_arena_size + shrink_width, 1 do for y = arena_size * -1, arena_size, 1 do - local pos = {x = x, y = y} + local pos = { x = x, y = y } local tile = surface.get_tile(pos.x, pos.y) if tile.name ~= 'water' and tile.name ~= 'deepwater' then if x > current_arena_size or y > current_arena_size or x < current_arena_size * -1 or y < current_arena_size * -1 then if random(1, 3) ~= 1 then - insert(tiles, {name = 'water', position = pos}) + insert(tiles, { name = 'water', position = pos }) end end end @@ -395,49 +395,49 @@ local function get_arena_entity(surface, pos) local noise2 = get_noise('rocks_2', pos) if noise > -0.1 and noise < 0.1 and noise2 > -0.3 and noise2 < 0.3 then - return {name = 'rock-big', position = pos} + return { name = 'rock-big', position = pos } end if random(1, 16) == 1 and noise2 > 0.78 then - if surface.can_place_entity({name = 'wooden-chest', position = pos, force = 'enemy'}) then - return {name = 'wooden-chest', position = pos, force = 'enemy'} + if surface.can_place_entity({ name = 'wooden-chest', position = pos, force = 'enemy' }) then + return { name = 'wooden-chest', position = pos, force = 'enemy' } end end if random(1, 16) == 1 and noise2 < -0.78 then - if surface.can_place_entity({name = 'wooden-chest', position = pos, force = 'enemy'}) then - return {name = 'wooden-chest', position = pos, force = 'enemy'} + if surface.can_place_entity({ name = 'wooden-chest', position = pos, force = 'enemy' }) then + return { name = 'wooden-chest', position = pos, force = 'enemy' } end end if random(1, this.arena_layout_modifiers.arena_tree_chance) == 1 and noise > this.arena_layout_modifiers.arena_tree_noise then - return {name = this.arena_layout_modifiers.arena_tree, position = pos} + return { name = this.arena_layout_modifiers.arena_tree, position = pos } end if random(1, 1024) == 1 then if random(1, 16) == 1 then - if surface.can_place_entity({name = this.arena_layout_modifiers.secret_entity, position = pos, force = 'enemy'}) then - return {name = this.arena_layout_modifiers.secret_entity, position = pos, force = 'enemy'} + if surface.can_place_entity({ name = this.arena_layout_modifiers.secret_entity, position = pos, force = 'enemy' }) then + return { name = this.arena_layout_modifiers.secret_entity, position = pos, force = 'enemy' } end end if random(1, 64) == 1 then - if surface.can_place_entity({name = 'big-worm-turret', position = pos, force = 'enemy'}) then - return {name = 'big-worm-turret', position = pos, force = 'enemy'} + if surface.can_place_entity({ name = 'big-worm-turret', position = pos, force = 'enemy' }) then + return { name = 'big-worm-turret', position = pos, force = 'enemy' } end end if random(1, 32) == 1 then - if surface.can_place_entity({name = 'medium-worm-turret', position = pos, force = 'enemy'}) then - return {name = 'medium-worm-turret', position = pos, force = 'enemy'} + if surface.can_place_entity({ name = 'medium-worm-turret', position = pos, force = 'enemy' }) then + return { name = 'medium-worm-turret', position = pos, force = 'enemy' } end end if random(1, 512) == 1 then - if surface.can_place_entity({name = 'behemoth-biter', position = pos, force = 'enemy'}) then - return {name = 'behemoth-biter', position = pos, force = 'enemy'} + if surface.can_place_entity({ name = 'behemoth-biter', position = pos, force = 'enemy' }) then + return { name = 'behemoth-biter', position = pos, force = 'enemy' } end end if random(1, 64) == 1 then - if surface.can_place_entity({name = 'big-biter', position = pos, force = 'enemy'}) then - return {name = 'big-biter', position = pos, force = 'enemy'} + if surface.can_place_entity({ name = 'big-biter', position = pos, force = 'enemy' }) then + return { name = 'big-biter', position = pos, force = 'enemy' } end end end @@ -450,7 +450,7 @@ local function render_arena_chunk(event) local surface = event.surface local left_top = event.area.left_top - for _, entity in pairs(surface.find_entities_filtered({area = event.area})) do + for _, entity in pairs(surface.find_entities_filtered({ area = event.area })) do if entity and entity.valid then if entity.name ~= 'character' then entity.destroy() @@ -461,15 +461,15 @@ local function render_arena_chunk(event) local tiles = {} for x = 0, 31, 1 do for y = 0, 31, 1 do - local pos = {x = left_top.x + x, y = left_top.y + y} + local pos = { x = left_top.x + x, y = left_top.y + y } if pos.x > arena_size or pos.y > arena_size or pos.x < arena_size * -1 or pos.y < arena_size * -1 then - insert(tiles, {name = 'water', position = pos}) + insert(tiles, { name = 'water', position = pos }) else local noise = get_noise('terrain', pos) if noise > 0 then - insert(tiles, {name = this.arena_layout_modifiers.arena_tile_1, position = pos}) + insert(tiles, { name = this.arena_layout_modifiers.arena_tile_1, position = pos }) else - insert(tiles, {name = this.arena_layout_modifiers.arena_tile_2, position = pos}) + insert(tiles, { name = this.arena_layout_modifiers.arena_tile_2, position = pos }) end local entity = get_arena_entity(surface, pos) if entity then @@ -483,18 +483,18 @@ end local function kill_idle_players() Core.iter_connected_players( - function(player) + function (player) if player.character then if player.afk_time > 600 then - local area = {{player.position.x - 1, player.position.y - 1}, {player.position.x + 1, player.position.y + 1}} - local water_tile_count = player.surface.count_tiles_filtered({name = {'water', 'deepwater'}, area = area}) + local area = { { player.position.x - 1, player.position.y - 1 }, { player.position.x + 1, player.position.y + 1 } } + local water_tile_count = player.surface.count_tiles_filtered({ name = { 'water', 'deepwater' }, area = area }) if water_tile_count and water_tile_count > 3 then player.character.die() - game.print(player.name .. ' drowned.', {r = 150, g = 150, b = 0}) + game.print(player.name .. ' drowned.', { r = 150, g = 150, b = 0 }) else if player.afk_time > 9000 then player.character.die() - game.print(player.name .. ' was idle for too long.', {r = 150, g = 150, b = 0}) + game.print(player.name .. ' was idle for too long.', { r = 150, g = 150, b = 0 }) end end end @@ -511,7 +511,7 @@ local function check_for_game_over() create_tank_battle_score_gui() Core.iter_connected_players( - function(player) + function (player) if player.character and player.driving then alive_players = alive_players + 1 end @@ -524,7 +524,7 @@ local function check_for_game_over() local player Core.iter_connected_players( - function(player_amp) + function (player_amp) if player_amp.character and player_amp.driving then player = player_amp end @@ -537,13 +537,13 @@ local function check_for_game_over() else this.tank_battles_score[player.index] = this.tank_battles_score[player.index] + 1 end - game.print(player.name .. ' has won the battle!', {r = 150, g = 150, b = 0}) + game.print(player.name .. ' has won the battle!', { r = 150, g = 150, b = 0 }) Server.to_discord_embed(player.name .. ' has won the battle!') create_tank_battle_score_gui() end if alive_players == 0 then - game.print('No players alive! Round ends in a draw!', {r = 150, g = 150, b = 0}) + game.print('No players alive! Round ends in a draw!', { r = 150, g = 150, b = 0 }) Server.to_discord_embed('No players alive! Round ends in a draw!') end @@ -630,7 +630,7 @@ local function on_player_joined_game(event) local permissions_group = game.permissions.get_group('Spectator') permissions_group.add_player(player.name) - player.teleport({0, 0}, 'nauvis') + player.teleport({ 0, 0 }, 'nauvis') end local function on_player_driving_changed_state(event) @@ -672,7 +672,7 @@ local function on_player_respawned(event) player.character.destroy() player.character = nil - player.print('You are now spectating.', {r = 0, g = 150, b = 150}) + player.print('You are now spectating.', { r = 0, g = 150, b = 150 }) end local function lobby() @@ -680,7 +680,7 @@ local function lobby() if connected_players_count < 2 then Core.iter_connected_players( - function(player) + function (player) create_gui(player) local gui = player.gui.left.status_players if gui and gui.valid then @@ -692,7 +692,7 @@ local function lobby() end Core.iter_connected_players( - function(player) + function (player) local gui = player.gui.left.status_players if gui and gui.valid then gui.visible = false @@ -705,10 +705,10 @@ local function lobby() end if this.lobby_timer % 600 == 0 then if this.lobby_timer <= 0 then - game.print('Round has started!', {r = 0, g = 150, b = 150}) + game.print('Round has started!', { r = 0, g = 150, b = 150 }) Server.to_discord_embed('Round has started!') else - game.print('Round will begin in ' .. this.lobby_timer / 60 .. ' seconds.', {r = 0, g = 150, b = 150}) + game.print('Round will begin in ' .. this.lobby_timer / 60 .. ' seconds.', { r = 0, g = 150, b = 150 }) Server.to_discord_embed('Round will begin in ' .. this.lobby_timer / 60 .. ' seconds.') end end @@ -769,9 +769,9 @@ local function on_player_died(event) end end Core.iter_connected_players( - function(target_player) + function (target_player) if target_player.name ~= player.name then - player.print(player.name .. ' was killed' .. str, {r = 0.99, g = 0.0, b = 0.0}) + player.print(player.name .. ' was killed' .. str, { r = 0.99, g = 0.0, b = 0.0 }) end end ) @@ -793,7 +793,7 @@ local function on_console_chat(event) color.a = 1 Core.iter_connected_players( - function(target_player) + function (target_player) if target_player.name ~= player.name then target_player.print(player.name .. ': ' .. event.message, color) end @@ -802,7 +802,7 @@ local function on_console_chat(event) end Event.on_init( - function() + function () local surface = game.get_surface('nauvis') local mgs = surface.map_gen_settings mgs.width = 400 @@ -832,14 +832,14 @@ Event.on_init( T.sub_caption = 'a playground made for tanks' T.text = table.concat( - { - 'The opponent wants your tank destroyed! Destroy their tank to win the round!\n', - '\n', - "The tank doors has oddly malfunctioned and you're locked inside.\n", - '\n', - 'Destroying wooden chests seems to grant loot.\n' - } - ) + { + 'The opponent wants your tank destroyed! Destroy their tank to win the round!\n', + '\n', + "The tank doors has oddly malfunctioned and you're locked inside.\n", + '\n', + 'Destroying wooden chests seems to grant loot.\n' + } + ) end ) Event.add(defines.events.on_tick, on_tick) diff --git a/maps/wip/main.lua b/maps/wip/main.lua index 05613dfc..2a5956ae 100644 --- a/maps/wip/main.lua +++ b/maps/wip/main.lua @@ -187,7 +187,7 @@ local function on_init() ['red-desert-decal'] = true } storage.decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if not blacklist[k] then if v.autoplace_specification then storage.decorative_names[#storage.decorative_names + 1] = k @@ -204,7 +204,7 @@ local function on_init() game.forces.shopping_chests.set_friend('player', true) local tree_raffle = {} - for _, e in pairs(game.entity_prototypes) do + for _, e in pairs(prototypes.entity) do if e.type == 'tree' then table.insert(tree_raffle, e.name) end @@ -213,7 +213,7 @@ local function on_init() storage.tree_raffle = tree_raffle local corpses_raffle = {} - for _, e in pairs(game.entity_prototypes) do + for _, e in pairs(prototypes.entity) do if e.type == 'corpse' then table.insert(corpses_raffle, e.name) end diff --git a/modules/autohotbar.lua b/modules/autohotbar.lua index 23c4865f..397b19f0 100644 --- a/modules/autohotbar.lua +++ b/modules/autohotbar.lua @@ -24,10 +24,10 @@ local function is_item_already_present_in_hotbar(player, item) end local function set_hotbar(player, item) - if not game.entity_prototypes[item] then + if not prototypes.entity[item] then return end - if not game.recipe_prototypes[item] then + if not prototypes.recipe[item] then return end local slot_index = get_empty_hotbar_slot(player) diff --git a/modules/autostash.lua b/modules/autostash.lua index f2a58bda..07d06808 100644 --- a/modules/autostash.lua +++ b/modules/autostash.lua @@ -97,7 +97,7 @@ local function create_floaty_text(surface, position, name, count) position.x, position.y + this.floating_text_y_offsets[position.x .. '_' .. position.y] }, - text = { '', '-', count, ' ', game.item_prototypes[name].localised_name }, + text = { '', '-', count, ' ', prototypes.item[name].localised_name }, color = { r = 255, g = 255, b = 255 } } ) @@ -501,10 +501,10 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa end end - local item_prototypes = game.item_prototypes + local item_prototypes = prototypes.item --Attempt to store in chests with same item subgroup. - local item_subgroup = game.item_prototypes[name].subgroup.name + local item_subgroup = prototypes.item[name].subgroup.name if item_subgroup then for chestnr, chest in pairs(filtered_chests.chest) do if chest.request_slot_count and chest.request_slot_count > 0 then @@ -735,8 +735,8 @@ local function do_whitelist() return end Task.delay(on_init_token, {}) - local resources = game.entity_prototypes - local items = game.item_prototypes + local resources = prototypes.entity + local items = prototypes.item this.whitelist = {} for k, _ in pairs(resources) do if resources[k] and resources[k].type == 'resource' and resources[k].mineable_properties then diff --git a/modules/burden.lua b/modules/burden.lua index 98a0f7c9..e94a6440 100644 --- a/modules/burden.lua +++ b/modules/burden.lua @@ -29,8 +29,8 @@ local function compute_fullness(player) local contents = inv.get_contents() for item, count in pairs(contents) do local stack_size = 1 - if game.item_prototypes[item].stackable then - stack_size = game.item_prototypes[item].stack_size + if prototypes.item[item].stackable then + stack_size = prototypes.item[item].stack_size end num_stacks = num_stacks + count / stack_size diff --git a/modules/dynamic_landfill.lua b/modules/dynamic_landfill.lua index 38ea0771..fb24e441 100644 --- a/modules/dynamic_landfill.lua +++ b/modules/dynamic_landfill.lua @@ -16,16 +16,16 @@ local water_tile_whitelist = { local spiral_coords = {} for r = 1, 96, 1 do for x = r * -1, r - 1, 1 do - table_insert(spiral_coords, {x = x, y = r * -1}) + table_insert(spiral_coords, { x = x, y = r * -1 }) end for y = r * -1, r - 1, 1 do - table_insert(spiral_coords, {x = r, y = y}) + table_insert(spiral_coords, { x = r, y = y }) end for x = r, r * -1 + 1, -1 do - table_insert(spiral_coords, {x = x, y = r}) + table_insert(spiral_coords, { x = x, y = r }) end for y = r, r * -1 + 1, -1 do - table_insert(spiral_coords, {x = r * -1, y = y}) + table_insert(spiral_coords, { x = r * -1, y = y }) end end @@ -51,14 +51,14 @@ local function regenerate_decoratives(surface, position) if not chunk then return end - surface.destroy_decoratives({area = {{chunk.x * 32, chunk.y * 32}, {chunk.x * 32 + 32, chunk.y * 32 + 32}}}) + surface.destroy_decoratives({ area = { { chunk.x * 32, chunk.y * 32 }, { chunk.x * 32 + 32, chunk.y * 32 + 32 } } }) local decorative_names = {} - for k, v in pairs(game.decorative_prototypes) do + for k, v in pairs(prototypes.decorative) do if v.autoplace_specification then decorative_names[#decorative_names + 1] = k end end - surface.regenerate_decorative(decorative_names, {chunk}) + surface.regenerate_decorative(decorative_names, { chunk }) end local function is_this_a_valid_source_tile(pos, tiles) @@ -72,7 +72,7 @@ end local function place_fitting_tile(position, surface, tiles_placed) for _, coord in pairs(spiral_coords) do - local tile = surface.get_tile({position.x + coord.x, position.y + coord.y}) + local tile = surface.get_tile({ position.x + coord.x, position.y + coord.y }) if not tile.collides_with('player-layer') then local valid_source_tile = is_this_a_valid_source_tile(tile.position, tiles_placed) if tile.name == 'out-of-map' then @@ -81,9 +81,9 @@ local function place_fitting_tile(position, surface, tiles_placed) if valid_source_tile then if tile.hidden_tile then - surface.set_tiles({{name = tile.hidden_tile, position = position}}, true) + surface.set_tiles({ { name = tile.hidden_tile, position = position } }, true) else - surface.set_tiles({{name = tile.name, position = position}}, true) + surface.set_tiles({ { name = tile.name, position = position } }, true) end return end diff --git a/modules/fjei/functions.lua b/modules/fjei/functions.lua index ad9540f7..92977c9e 100644 --- a/modules/fjei/functions.lua +++ b/modules/fjei/functions.lua @@ -15,7 +15,7 @@ function Public.get_crafting_machines_for_recipe(force_name, recipe) local i = 1 for _, name in pairs(crafting_machines) do if item_whitelist[name] or name == 'character' then - local crafting_categories = game.entity_prototypes[name].crafting_categories + local crafting_categories = prototypes.entity[name].crafting_categories for category, _ in pairs(crafting_categories) do if recipe_category == category then result[i] = name @@ -32,7 +32,7 @@ local function set_crafting_machines() storage.fjei.crafting_machines = {} local list = storage.fjei.crafting_machines local i = 1 - for _, prototype in pairs(game.entity_prototypes) do + for _, prototype in pairs(prototypes.entity) do if prototype.crafting_categories then list[i] = prototype.name i = i + 1 @@ -93,7 +93,7 @@ end local function set_item_list() storage.fjei.item_list = {} local item_list = storage.fjei.item_list - for recipe_name, recipe in pairs(game.recipe_prototypes) do + for recipe_name, recipe in pairs(prototypes.recipe) do for key, product in pairs(recipe.products) do add_item_list_product(item_list, product.name, recipe_name) end @@ -132,8 +132,8 @@ local function set_sorted_item_list() storage.fjei.sorted_item_list = {} local sorted_item_list = storage.fjei.sorted_item_list local item_list = storage.fjei.item_list - local item_prototypes = game.item_prototypes - local fluid_prototypes = game.fluid_prototypes + local item_prototypes = prototypes.item + local fluid_prototypes = prototypes.fluid local sorted_items = {} local i = 1 @@ -186,13 +186,13 @@ local function add_recipe_to_whitelist(item_whitelist, recipe) --Adding "place_result" in case the inventory item can turn into a differently named entity after placement on the map. for key, product in pairs(recipe.products) do - local p = game.item_prototypes[product.name] + local p = prototypes.item[product.name] if p and p.place_result then item_whitelist[p.place_result.name] = true end end for key, ingredient in pairs(recipe.ingredients) do - local p = game.item_prototypes[ingredient.name] + local p = prototypes.item[ingredient.name] if p and p.place_result then item_whitelist[p.place_result.name] = true end @@ -207,7 +207,7 @@ function Public.add_research_to_whitelist(force, effects) local items_have_been_added = false for _, effect in pairs(effects) do if effect.recipe then - add_recipe_to_whitelist(item_whitelist, game.recipe_prototypes[effect.recipe]) + add_recipe_to_whitelist(item_whitelist, prototypes.recipe[effect.recipe]) items_have_been_added = true end end @@ -241,15 +241,15 @@ local function set_item_whitelists_for_all_forces() end local function get_localised_name(name) - local item = game.item_prototypes[name] + local item = prototypes.item[name] if item then return item.localised_name end - local fluid = game.fluid_prototypes[name] + local fluid = prototypes.fluid[name] if fluid then return fluid.localised_name end - local recipe = game.recipe_prototypes[name] + local recipe = prototypes.recipe[name] if recipe then return recipe.localised_name end diff --git a/modules/fjei/gui.lua b/modules/fjei/gui.lua index d615ac57..b05ba49c 100644 --- a/modules/fjei/gui.lua +++ b/modules/fjei/gui.lua @@ -68,15 +68,15 @@ local function get_formatted_amount(amount) end local function get_localised_name(name) - local item = game.item_prototypes[name] + local item = prototypes.item[name] if item then return item.localised_name end - local fluid = game.fluid_prototypes[name] + local fluid = prototypes.fluid[name] if fluid then return fluid.localised_name end - local recipe = game.recipe_prototypes[name] + local recipe = prototypes.recipe[name] if recipe then return recipe.localised_name end @@ -84,16 +84,16 @@ local function get_localised_name(name) end local function get_sprite_type(name) - if game.item_prototypes[name] then + if prototypes.item[name] then return 'item' end - if game.fluid_prototypes[name] then + if prototypes.fluid[name] then return 'fluid' end - if game.entity_prototypes[name] then + if prototypes.entity[name] then return 'entity' end - if game.recipe_prototypes[name] then + if prototypes.recipe[name] then return 'recipe' end return false @@ -321,7 +321,7 @@ local function draw_recipe_window_header(player, container, item_name, recipes, end local function draw_recipe(player, container, recipe_name) - local recipe = game.recipe_prototypes[recipe_name] + local recipe = prototypes.recipe[recipe_name] local t = container.add({ type = 'table', column_count = 2 }) add_choose_elem_button(t, recipe.name, true) @@ -444,7 +444,7 @@ local function draw_recipe(player, container, recipe_name) element.style.font = 'heading-2' for key, machine in pairs(machines) do - local prototype = game.entity_prototypes[machine] + local prototype = prototypes.entity[machine] if prototype then add_choose_elem_button(t, machine) end @@ -510,7 +510,7 @@ local function create_recipe_window(item_name, player, button, selected_recipe) if not selected_recipe then for key, recipe_name in pairs(recipes) do - if #Functions.get_crafting_machines_for_recipe(player.force.name, game.recipe_prototypes[recipe_name]) > 0 then + if #Functions.get_crafting_machines_for_recipe(player.force.name, prototypes.recipe[recipe_name]) > 0 then selected_recipe = recipe_name break end @@ -559,7 +559,7 @@ local function create_recipe_window(item_name, player, button, selected_recipe) end local function add_to_history(item_name, player) - if not game.item_prototypes[item_name] and not game.fluid_prototypes[item_name] then + if not prototypes.item[item_name] and not prototypes.fluid[item_name] then return end diff --git a/modules/immersive_cargo_wagons/functions.lua b/modules/immersive_cargo_wagons/functions.lua index 1c5f161f..bcd408a1 100644 --- a/modules/immersive_cargo_wagons/functions.lua +++ b/modules/immersive_cargo_wagons/functions.lua @@ -36,10 +36,10 @@ local function connect_power_pole(entity, wagon_area_left_top_y) local surface = entity.surface local max_wire_distance = entity.prototype.max_wire_distance local area = { - {entity.position.x - max_wire_distance, entity.position.y - max_wire_distance}, - {entity.position.x + max_wire_distance, entity.position.y - 1} + { entity.position.x - max_wire_distance, entity.position.y - max_wire_distance }, + { entity.position.x + max_wire_distance, entity.position.y - 1 } } - for _, pole in pairs(surface.find_entities_filtered({area = area, name = entity.name})) do + for _, pole in pairs(surface.find_entities_filtered({ area = area, name = entity.name })) do if pole.position.y < wagon_area_left_top_y then entity.connect_neighbour(pole) return @@ -74,9 +74,9 @@ local function equal_fluid(source_tank, target_tank) return end - local inserted_amount = target_tank.insert_fluid({name = source_fluid.name, amount = amount, temperature = source_fluid.temperature}) + local inserted_amount = target_tank.insert_fluid({ name = source_fluid.name, amount = amount, temperature = source_fluid.temperature }) if inserted_amount > 0 then - source_tank.remove_fluid({name = source_fluid.name, amount = inserted_amount}) + source_tank.remove_fluid({ name = source_fluid.name, amount = inserted_amount }) end end @@ -88,7 +88,7 @@ end local function input_filtered(wagon_inventory, chest, chest_inventory, free_slots) local request_stacks = {} - local prototypes = game.item_prototypes + local prototypes = prototypes.item for slot_index = 1, 4, 1 do local stack = chest.get_request_slot(slot_index) if stack then @@ -213,17 +213,17 @@ local function construct_wagon_doors(icw, wagon) local area = wagon.area local surface = wagon.surface - for _, x in pairs({area.left_top.x - 0.55, area.right_bottom.x + 0.55}) do + for _, x in pairs({ area.left_top.x - 0.55, area.right_bottom.x + 0.55 }) do local e = surface.create_entity( - { - name = 'car', - position = {x, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}, - force = 'neutral', - create_build_effect_smoke = false - } - ) - e.get_inventory(defines.inventory.fuel).insert({name = 'wood', count = 1}) + { + name = 'car', + position = { x, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5) }, + force = 'neutral', + create_build_effect_smoke = false + } + ) + e.get_inventory(defines.inventory.fuel).insert({ name = 'wood', count = 1 }) e.destructible = false e.minable = false e.operable = false @@ -262,7 +262,7 @@ function Public.kill_wagon(icw, entity) local surface = wagon.surface kick_players_out_of_vehicles(wagon) kill_wagon_doors(icw, wagon) - for _, e in pairs(surface.find_entities_filtered({area = wagon.area})) do + for _, e in pairs(surface.find_entities_filtered({ area = wagon.area })) do if e.name == 'character' and e.player then local p = wagon.entity.surface.find_non_colliding_position('character', wagon.entity.position, 128, 0.5) if p then @@ -275,8 +275,8 @@ function Public.kill_wagon(icw, entity) e.die() end end - for _, tile in pairs(surface.find_tiles_filtered({area = wagon.area})) do - surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true) + for _, tile in pairs(surface.find_tiles_filtered({ area = wagon.area })) do + surface.set_tiles({ { name = 'out-of-map', position = tile.position } }, true) end wagon.entity.force.chart(surface, wagon.area) icw.wagons[entity.unit_number] = nil @@ -292,21 +292,21 @@ function Public.create_room_surface(icw, unit_number) ['height'] = 2, ['water'] = 0, ['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}, - ['tile'] = {treat_missing_as_default = true}, - ['decorative'] = {treat_missing_as_default = false} + ['entity'] = { treat_missing_as_default = false }, + ['tile'] = { treat_missing_as_default = true }, + ['decorative'] = { treat_missing_as_default = false } } } local surface = game.create_surface(tostring(unit_number), map_gen_settings) surface.freeze_daytime = true surface.daytime = 0.1 - surface.request_to_generate_chunks({16, 16}, 2) + surface.request_to_generate_chunks({ 16, 16 }, 2) surface.force_generate_chunk_requests() - for _, tile in pairs(surface.find_tiles_filtered({area = {{-2, -2}, {2, 2}}})) do - surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true) + for _, tile in pairs(surface.find_tiles_filtered({ area = { { -2, -2 }, { 2, 2 } } })) do + surface.set_tiles({ { name = 'out-of-map', position = tile.position } }, true) end table_insert(icw.surfaces, surface) return surface @@ -323,20 +323,20 @@ function Public.create_wagon_room(icw, wagon) local tiles = {} for x = -3, 2, 1 do - table_insert(tiles, {name = 'hazard-concrete-right', position = {x, area.left_top.y}}) - table_insert(tiles, {name = 'hazard-concrete-right', position = {x, area.right_bottom.y - 1}}) + table_insert(tiles, { name = 'hazard-concrete-right', position = { x, area.left_top.y } }) + table_insert(tiles, { name = 'hazard-concrete-right', position = { x, area.right_bottom.y - 1 } }) end for x = area.left_top.x, area.right_bottom.x - 1, 1 do for y = area.left_top.y + 2, area.right_bottom.y - 3, 1 do - table_insert(tiles, {name = main_tile_name, position = {x, y}}) + table_insert(tiles, { name = main_tile_name, position = { x, y } }) end end for x = -3, 2, 1 do for y = 1, 3, 1 do - table_insert(tiles, {name = main_tile_name, position = {x, y}}) + table_insert(tiles, { name = main_tile_name, position = { x, y } }) end for y = area.right_bottom.y - 4, area.right_bottom.y - 2, 1 do - table_insert(tiles, {name = main_tile_name, position = {x, y}}) + table_insert(tiles, { name = main_tile_name, position = { x, y } }) end end @@ -346,13 +346,13 @@ function Public.create_wagon_room(icw, wagon) local r2 = math_random(1, 2) for x = math_random(1, 2) * -1, math_random(1, 2), 1 do for y = r1, r2, 1 do - table_insert(vectors, {x, y}) + table_insert(vectors, { x, y }) end end - local position = {x = area.left_top.x + (area.right_bottom.x - area.left_top.x) * 0.5, y = area.left_top.y + (area.right_bottom.y - area.left_top.y) * 0.5} - position = {x = position.x + (-4 + math_random(0, 8)), y = position.y + (-6 + math_random(0, 12))} + local position = { x = area.left_top.x + (area.right_bottom.x - area.left_top.x) * 0.5, y = area.left_top.y + (area.right_bottom.y - area.left_top.y) * 0.5 } + position = { x = position.x + (-4 + math_random(0, 8)), y = position.y + (-6 + math_random(0, 12)) } for _, v in pairs(vectors) do - table_insert(tiles, {name = 'water', position = {position.x + v[1], position.y + v[2]}}) + table_insert(tiles, { name = 'water', position = { position.x + v[1], position.y + v[2] } }) end end @@ -363,57 +363,57 @@ function Public.create_wagon_room(icw, wagon) if wagon.entity.type == 'fluid-wagon' then local height = area.right_bottom.y - area.left_top.y local positions = { - {area.right_bottom.x, area.left_top.y + height * 0.25}, - {area.right_bottom.x, area.left_top.y + height * 0.75}, - {area.left_top.x - 1, area.left_top.y + height * 0.25}, - {area.left_top.x - 1, area.left_top.y + height * 0.75} + { area.right_bottom.x, area.left_top.y + height * 0.25 }, + { area.right_bottom.x, area.left_top.y + height * 0.75 }, + { area.left_top.x - 1, area.left_top.y + height * 0.25 }, + { area.left_top.x - 1, area.left_top.y + height * 0.75 } } table.shuffle_table(positions) local e = surface.create_entity( - { - name = 'storage-tank', - position = positions[1], - force = 'neutral', - create_build_effect_smoke = false - } - ) + { + name = 'storage-tank', + position = positions[1], + force = 'neutral', + create_build_effect_smoke = false + } + ) e.destructible = false e.minable = false - wagon.transfer_entities = {e} + wagon.transfer_entities = { e } return end if wagon.entity.type == 'cargo-wagon' then - local vectors = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}} + local vectors = { { 0, -1 }, { 0, 1 }, { -1, 0 }, { 1, 0 } } local v = vectors[math_random(1, 4)] - local position = {math_random(area.left_top.x + 2, area.right_bottom.x - 3), math_random(area.left_top.y + 5, area.right_bottom.y - 6)} + local position = { math_random(area.left_top.x + 2, area.right_bottom.x - 3), math_random(area.left_top.y + 5, area.right_bottom.y - 6) } local e = surface.create_entity( - { - name = 'logistic-chest-requester', - position = position, - force = 'neutral', - create_build_effect_smoke = false - } - ) + { + name = 'logistic-chest-requester', + position = position, + force = 'neutral', + create_build_effect_smoke = false + } + ) e.destructible = false e.minable = false e2 = surface.create_entity( - { - name = 'logistic-chest-passive-provider', - position = {position[1] + v[1], position[2] + v[2]}, - force = 'neutral', - create_build_effect_smoke = false - } - ) + { + name = 'logistic-chest-passive-provider', + position = { position[1] + v[1], position[2] + v[2] }, + force = 'neutral', + create_build_effect_smoke = false + } + ) e2.destructible = false e2.minable = false - wagon.transfer_entities = {e, e2} + wagon.transfer_entities = { e, e2 } return end end @@ -432,7 +432,7 @@ function Public.create_wagon(icw, created_entity, delay_surface) icw.wagons[created_entity.unit_number] = { entity = created_entity, - area = {left_top = {x = wagon_area.left_top.x, y = wagon_area.left_top.y}, right_bottom = {x = wagon_area.right_bottom.x, y = wagon_area.right_bottom.y}}, + area = { left_top = { x = wagon_area.left_top.x, y = wagon_area.left_top.y }, right_bottom = { x = wagon_area.right_bottom.x, y = wagon_area.right_bottom.y } }, doors = {}, entity_count = 0 } @@ -499,12 +499,12 @@ function Public.use_cargo_wagon_door(icw, player, door) end player_data.fallback_surface = wagon.entity.surface.index - player_data.fallback_position = {wagon.entity.position.x, wagon.entity.position.y} + player_data.fallback_position = { wagon.entity.position.x, wagon.entity.position.y } if wagon.entity.surface.name ~= player.surface.name then local surface = wagon.entity.surface local x_vector = (door.position.x / math.abs(door.position.x)) * 2 - local position = {wagon.entity.position.x + x_vector, wagon.entity.position.y} + local position = { wagon.entity.position.x + x_vector, wagon.entity.position.y } local position = surface.find_non_colliding_position('character', position, 128, 0.5) if not position then return @@ -520,9 +520,9 @@ function Public.use_cargo_wagon_door(icw, player, door) local x_vector = door.position.x - player.position.x local position if x_vector > 0 then - position = {area.left_top.x + 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)} + position = { area.left_top.x + 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5) } else - position = {area.right_bottom.x - 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)} + position = { area.right_bottom.x - 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5) } end local p = surface.find_non_colliding_position('character', position, 128, 0.5) if p then @@ -542,8 +542,8 @@ local function move_room_to_train(icw, train, wagon) table_insert(train.wagons, wagon.entity.unit_number) local destination_area = { - left_top = {x = wagon.area.left_top.x, y = train.top_y}, - right_bottom = {x = wagon.area.right_bottom.x, y = train.top_y + (wagon.area.right_bottom.y - wagon.area.left_top.y)} + left_top = { x = wagon.area.left_top.x, y = train.top_y }, + right_bottom = { x = wagon.area.right_bottom.x, y = train.top_y + (wagon.area.right_bottom.y - wagon.area.left_top.y) } } train.top_y = destination_area.right_bottom.y @@ -554,11 +554,11 @@ local function move_room_to_train(icw, train, wagon) kick_players_out_of_vehicles(wagon) local player_positions = {} - for _, e in pairs(wagon.surface.find_entities_filtered({name = 'character', area = wagon.area})) do + for _, e in pairs(wagon.surface.find_entities_filtered({ name = 'character', area = wagon.area })) do local player = e.player if player then - player_positions[player.index] = {player.position.x, player.position.y + (destination_area.left_top.y - wagon.area.left_top.y)} - player.teleport({0, 0}, game.surfaces.nauvis) + player_positions[player.index] = { player.position.x, player.position.y + (destination_area.left_top.y - wagon.area.left_top.y) } + player.teleport({ 0, 0 }, game.surfaces.nauvis) end end @@ -583,8 +583,8 @@ local function move_room_to_train(icw, train, wagon) player.teleport(position, train.surface) end - for _, tile in pairs(wagon.surface.find_tiles_filtered({area = wagon.area})) do - wagon.surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true) + for _, tile in pairs(wagon.surface.find_tiles_filtered({ area = wagon.area })) do + wagon.surface.set_tiles({ { name = 'out-of-map', position = tile.position } }, true) end wagon.entity.force.chart(wagon.surface, wagon.area) @@ -594,11 +594,11 @@ local function move_room_to_train(icw, train, wagon) construct_wagon_doors(icw, wagon) local left_top_y = wagon.area.left_top.y - for _, e in pairs(wagon.surface.find_entities_filtered({type = 'electric-pole', area = wagon.area})) do + for _, e in pairs(wagon.surface.find_entities_filtered({ type = 'electric-pole', area = wagon.area })) do connect_power_pole(e, left_top_y) end - for _, e in pairs(wagon.surface.find_entities_filtered({area = wagon.area, force = 'neutral'})) do + for _, e in pairs(wagon.surface.find_entities_filtered({ area = wagon.area, force = 'neutral' })) do if transfer_functions[e.name] then table_insert(wagon.transfer_entities, e) end @@ -612,7 +612,7 @@ function Public.construct_train(icw, carriages) return end - local train = {surface = Public.create_room_surface(icw, unit_number), wagons = {}, top_y = 0} + local train = { surface = Public.create_room_surface(icw, unit_number), wagons = {}, top_y = 0 } icw.trains[unit_number] = train for k, carriage in pairs(carriages) do @@ -656,15 +656,15 @@ function Public.draw_minimap(icw, player, surface, position) local player_data = get_player_data(icw, player) element = player.gui.left.add( - { - type = 'camera', - name = 'icw_map', - position = position, - surface_index = surface.index, - zoom = player_data.zoom, - tooltip = 'LMB: Increase zoom level.\nRMB: Decrease zoom level.\nMMB: Toggle camera size.' - } - ) + { + type = 'camera', + name = 'icw_map', + position = position, + surface_index = surface.index, + zoom = player_data.zoom, + tooltip = 'LMB: Increase zoom level.\nRMB: Decrease zoom level.\nMMB: Toggle camera size.' + } + ) element.style.margin = 1 element.style.minimal_height = player_data.map_size element.style.minimal_width = player_data.map_size diff --git a/modules/infinity_chest.lua b/modules/infinity_chest.lua index dd5a121b..dd3b8126 100644 --- a/modules/infinity_chest.lua +++ b/modules/infinity_chest.lua @@ -23,7 +23,7 @@ Public.storage = {} Global.register( this, - function(tbl) + function (tbl) this = tbl end ) @@ -33,8 +33,8 @@ function Public.get_table() end function Public.create_chest(surface, position, storage) - local entity = surface.create_entity {name = 'infinity-chest', position = position, force = 'player'} - this.inf_chests[entity.unit_number] = {entity = entity, storage = storage} + local entity = surface.create_entity { name = 'infinity-chest', position = position, force = 'player' } + this.inf_chests[entity.unit_number] = { entity = entity, storage = storage } return entity end @@ -115,9 +115,9 @@ local function built_entity(event) text = '♾', surface = entity.surface, target = entity, - target_offset = {0, -0.6}, + target_offset = { 0, -0.6 }, scale = 2, - color = {r = 0, g = 0.6, b = 1}, + color = { r = 0, g = 0.6, b = 1 }, alignment = 'center' } end @@ -135,7 +135,7 @@ local function built_entity_robot(event) end local function item(item_name, item_count, inv, unit_number) - local item_stack = game.item_prototypes[item_name].stack_size + local item_stack = prototypes.item[item_name].stack_size local diff = item_count - item_stack if not this.inf_storage[unit_number] then @@ -151,7 +151,7 @@ local function item(item_name, item_count, inv, unit_number) end if diff > 0 then if not storage[item_name] then - local count = inv.remove({name = item_name, count = diff}) + local count = inv.remove({ name = item_name, count = diff }) this.inf_storage[unit_number][item_name] = count else if this.inf_storage[unit_number][item_name] >= this.limits[unit_number] then @@ -159,13 +159,13 @@ local function item(item_name, item_count, inv, unit_number) if mode == 1 then this.inf_mode[unit_number] = 3 end - if inv.can_insert({name = item_name, count = item_stack}) then - local count = inv.insert({name = item_name, count = item_stack}) + if inv.can_insert({ name = item_name, count = item_stack }) then + local count = inv.insert({ name = item_name, count = item_stack }) this.inf_storage[unit_number][item_name] = storage[item_name] - count end return end - local count = inv.remove({name = item_name, count = diff}) + local count = inv.remove({ name = item_name, count = diff }) this.inf_storage[unit_number][item_name] = storage[item_name] + count end elseif diff < 0 then @@ -173,10 +173,10 @@ local function item(item_name, item_count, inv, unit_number) return end if storage[item_name] > (diff * -1) then - local inserted = inv.insert({name = item_name, count = (diff * -1)}) + local inserted = inv.insert({ name = item_name, count = (diff * -1) }) this.inf_storage[unit_number][item_name] = storage[item_name] - inserted else - inv.insert({name = item_name, count = storage[item_name]}) + inv.insert({ name = item_name, count = storage[item_name] }) this.inf_storage[unit_number][item_name] = nil end end @@ -359,60 +359,60 @@ local function gui_opened(event) local player = game.players[event.player_index] local frame = player.gui.center.add { - type = 'frame', - caption = 'Unlimited Chest', - direction = 'vertical', - name = entity.unit_number - } - local controls = frame.add {type = 'flow', direction = 'horizontal'} - local items = frame.add {type = 'flow', direction = 'vertical'} + type = 'frame', + caption = 'Unlimited Chest', + direction = 'vertical', + name = entity.unit_number + } + local controls = frame.add { type = 'flow', direction = 'horizontal' } + local items = frame.add { type = 'flow', direction = 'vertical' } local mode = this.inf_mode[entity.unit_number] local selected = mode and mode or 1 - local tbl = controls.add {type = 'table', column_count = 1} + local tbl = controls.add { type = 'table', column_count = 1 } local limit_tooltip = '[color=yellow]Limit Info:[/color]\nThis is only usable if you intend to use this chest for one item.' local mode_tooltip = - '[color=yellow]Mode Info:[/color]\nEnabled: will active the chest and allow for insertions.\nDisabled: will deactivate the chest and let´s the player utilize the GUI to retrieve items.\nLimited: will deactivate the chest as per limit.' + '[color=yellow]Mode Info:[/color]\nEnabled: will active the chest and allow for insertions.\nDisabled: will deactivate the chest and let´s the player utilize the GUI to retrieve items.\nLimited: will deactivate the chest as per limit.' local btn = tbl.add { - type = 'sprite-button', - tooltip = '[color=blue]Info![/color]\nThis chest stores unlimited quantity of items (up to 48 different item types).\nThe chest is best used with an inserter to add / remove items.\nThe chest is mineable if state is disabled.\nContent is kept when mined.\n[color=yellow]Limit:[/color]\nThis is only usable if you intend to use this chest for one item.', - sprite = 'utility/questionmark' - } + type = 'sprite-button', + tooltip = '[color=blue]Info![/color]\nThis chest stores unlimited quantity of items (up to 48 different item types).\nThe chest is best used with an inserter to add / remove items.\nThe chest is mineable if state is disabled.\nContent is kept when mined.\n[color=yellow]Limit:[/color]\nThis is only usable if you intend to use this chest for one item.', + sprite = 'utility/questionmark' + } btn.style.height = 20 btn.style.width = 20 btn.enabled = false btn.focus() - local tbl_2 = tbl.add {type = 'table', column_count = 4} + local tbl_2 = tbl.add { type = 'table', column_count = 4 } - tbl_2.add {type = 'label', caption = 'Mode: ', tooltip = mode_tooltip} + tbl_2.add { type = 'label', caption = 'Mode: ', tooltip = mode_tooltip } local drop_down if player.admin and this.editor[player.name] then drop_down = tbl_2.add { - type = 'drop-down', - items = {'Enabled', 'Disabled', 'Limited', 'Editor'}, - selected_index = selected, - name = entity.unit_number, - tooltip = mode_tooltip - } + type = 'drop-down', + items = { 'Enabled', 'Disabled', 'Limited', 'Editor' }, + selected_index = selected, + name = entity.unit_number, + tooltip = mode_tooltip + } else drop_down = tbl_2.add { - type = 'drop-down', - items = {'Enabled', 'Disabled', 'Limited'}, - selected_index = selected, - name = entity.unit_number, - tooltip = mode_tooltip - } + type = 'drop-down', + items = { 'Enabled', 'Disabled', 'Limited' }, + selected_index = selected, + name = entity.unit_number, + tooltip = mode_tooltip + } end - tbl_2.add({type = 'label', caption = ' Limit: ', tooltip = limit_tooltip}) - local text_field = tbl_2.add({type = 'textfield', text = this.limits[entity.unit_number]}) + tbl_2.add({ type = 'label', caption = ' Limit: ', tooltip = limit_tooltip }) + local text_field = tbl_2.add({ type = 'textfield', text = this.limits[entity.unit_number] }) text_field.style.width = 80 text_field.numeric = true text_field.tooltip = limit_tooltip @@ -448,7 +448,7 @@ local function update_gui() end frame.clear() - local tbl = frame.add {type = 'table', column_count = 10, name = 'infinity_chest_inventory'} + local tbl = frame.add { type = 'table', column_count = 10, name = 'infinity_chest_inventory' } local total = 0 local items = {} @@ -490,23 +490,23 @@ local function update_gui() if mode == 1 or mode == 3 then btn = tbl.add { - type = 'sprite-button', - sprite = 'item/' .. item_name, - style = 'slot_button', - number = item_count, - name = item_name, - tooltip = 'Withdrawal is possible when state is disabled!' - } + type = 'sprite-button', + sprite = 'item/' .. item_name, + style = 'slot_button', + number = item_count, + name = item_name, + tooltip = 'Withdrawal is possible when state is disabled!' + } btn.enabled = false elseif mode == 2 or mode == 4 then btn = tbl.add { - type = 'sprite-button', - sprite = 'item/' .. item_name, - style = 'slot_button', - number = item_count, - name = item_name - } + type = 'sprite-button', + sprite = 'item/' .. item_name, + style = 'slot_button', + number = item_count, + name = item_name + } btn.enabled = true end end @@ -514,10 +514,10 @@ local function update_gui() while total < 48 do local btns if mode == 1 or mode == 2 or mode == 3 then - btns = tbl.add {type = 'sprite-button', style = 'slot_button'} + btns = tbl.add { type = 'sprite-button', style = 'slot_button' } btns.enabled = false elseif mode == 4 then - btns = tbl.add {type = 'choose-elem-button', style = 'slot_button', elem_type = 'item'} + btns = tbl.add { type = 'choose-elem-button', style = 'slot_button', elem_type = 'item' } btns.enabled = true end @@ -628,7 +628,7 @@ local function gui_click(event) if not count then return end - local inserted = player.insert {name = name, count = count} + local inserted = player.insert { name = name, count = count } if not inserted then return end @@ -639,7 +639,7 @@ local function gui_click(event) end elseif shift then local count = storage[name] - local stack = game.item_prototypes[name].stack_size + local stack = prototypes.item[name].stack_size if not count then return end @@ -647,10 +647,10 @@ local function gui_click(event) return end if count > stack then - local inserted = player.insert {name = name, count = stack} + local inserted = player.insert { name = name, count = stack } storage[name] = storage[name] - inserted else - player.insert {name = name, count = count} + player.insert { name = name, count = count } storage[name] = nil end else @@ -658,7 +658,7 @@ local function gui_click(event) return end storage[name] = storage[name] - 1 - player.insert {name = name, count = 1} + player.insert { name = name, count = 1 } if storage[name] <= 0 then storage[name] = nil end diff --git a/modules/mobs_drop_loot.lua b/modules/mobs_drop_loot.lua index 545b46be..e6aa1e4d 100644 --- a/modules/mobs_drop_loot.lua +++ b/modules/mobs_drop_loot.lua @@ -231,7 +231,7 @@ local function roll_item_stack(entity, wave) end end - local stack_size = game.item_prototypes[item_name].stack_size + local stack_size = prototypes.item[item_name].stack_size local item_count = 1 diff --git a/modules/portable_chest.lua b/modules/portable_chest.lua index 367b3ba4..28c6dec7 100644 --- a/modules/portable_chest.lua +++ b/modules/portable_chest.lua @@ -39,7 +39,7 @@ local Public = {} Global.register( this, - function(tbl) + function (tbl) this = tbl end ) @@ -98,15 +98,15 @@ local function item(item_name, item_count, player, storage) local stack_size = this.stack_size[player.index] local item_stack if stack_size then - item_stack = game.item_prototypes[item_name].stack_size * stack_size + item_stack = prototypes.item[item_name].stack_size * stack_size else - item_stack = game.item_prototypes[item_name].stack_size + item_stack = prototypes.item[item_name].stack_size end local diff = item_count - item_stack if diff > 0 then - local count = player.remove({name = item_name, count = diff}) + local count = player.remove({ name = item_name, count = diff }) if not storage[item_name] then storage[item_name] = count else @@ -117,10 +117,10 @@ local function item(item_name, item_count, player, storage) goto continue end if storage[item_name] > (diff * -1) then - local inserted = player.insert({name = item_name, count = (diff * -1)}) + local inserted = player.insert({ name = item_name, count = (diff * -1) }) storage[item_name] = storage[item_name] - inserted else - player.insert({name = item_name, count = storage[item_name]}) + player.insert({ name = item_name, count = storage[item_name] }) storage[item_name] = 0 end end @@ -167,25 +167,25 @@ local function draw_main_frame(player, target, chest_id) local p = target or player local frame = player.gui.screen.add { - type = 'frame', - caption = p.name .. '´s private portable stash', - direction = 'vertical', - name = main_frame_name - } + type = 'frame', + caption = p.name .. '´s private portable stash', + direction = 'vertical', + name = main_frame_name + } frame.auto_center = true local data = {} - local controls = frame.add {type = 'flow', direction = 'horizontal'} - local items = frame.add {type = 'flow', direction = 'vertical'} + local controls = frame.add { type = 'flow', direction = 'horizontal' } + local items = frame.add { type = 'flow', direction = 'vertical' } - local tbl = controls.add {type = 'table', column_count = 1} + local tbl = controls.add { type = 'table', column_count = 1 } local btn = tbl.add { - type = 'sprite-button', - tooltip = '[color=blue]Info![/color]\nYou can easily remove an item by left/right-clicking it.\n\nItems selected in the table below will remove all stacks except one from the player inventory.\nIf the stack-size is bigger in the personal stash than the players inventory stack then the players inventory will automatically refill from the personal stash.\n\n[color=red]Usage[/color]\nPressing the following keys will do the following actions:\nCTRL: Retrieves all stacks from clicked item\nSHIFT:Retrieves a stack from clicked item.\nStack-Size slider will always ensure that you have amounts of stacks in your inventory.\n\n[color=red]Deleting[/color]\nDelete Mode: Will delete the clicked item instantly.', - sprite = 'utility/questionmark' - } + type = 'sprite-button', + tooltip = '[color=blue]Info![/color]\nYou can easily remove an item by left/right-clicking it.\n\nItems selected in the table below will remove all stacks except one from the player inventory.\nIf the stack-size is bigger in the personal stash than the players inventory stack then the players inventory will automatically refill from the personal stash.\n\n[color=red]Usage[/color]\nPressing the following keys will do the following actions:\nCTRL: Retrieves all stacks from clicked item\nSHIFT:Retrieves a stack from clicked item.\nStack-Size slider will always ensure that you have amounts of stacks in your inventory.\n\n[color=red]Deleting[/color]\nDelete Mode: Will delete the clicked item instantly.', + sprite = 'utility/questionmark' + } btn.style.height = 20 btn.style.width = 20 btn.enabled = false @@ -204,40 +204,40 @@ local function draw_main_frame(player, target, chest_id) local text = tbl.add { - type = 'label', - caption = format('Stores unlimited quantity of items (up to ' .. amount_and_types .. ' types).\nRead the tooltip by hovering the question-mark above!') - } + type = 'label', + caption = format('Stores unlimited quantity of items (up to ' .. amount_and_types .. ' types).\nRead the tooltip by hovering the question-mark above!') + } text.style.single_line = false - local tbl_2 = tbl.add {type = 'table', column_count = 4} + local tbl_2 = tbl.add { type = 'table', column_count = 4 } local stack_size = this.stack_size[player.index] - local stack_value = tbl_2.add({type = 'label', caption = 'Stack Size: ' .. stack_size .. ' '}) + local stack_value = tbl_2.add({ type = 'label', caption = 'Stack Size: ' .. stack_size .. ' ' }) stack_value.style.font = 'default-bold' data.stack_value = stack_value local slider = tbl_2.add( - { - type = 'slider', - minimum_value = 1, - maximum_value = 10, - name = stack_slider_name, - value = stack_size - } - ) + { + type = 'slider', + minimum_value = 1, + maximum_value = 10, + name = stack_slider_name, + value = stack_size + } + ) data.slider = slider slider.style.width = 115 Gui.set_data(slider, data) - local delete_mode = tbl_2.add({type = 'label', caption = ' Delete Mode: '}) + local delete_mode = tbl_2.add({ type = 'label', caption = ' Delete Mode: ' }) delete_mode.style.font = 'default-bold' - local checkbox = tbl_2.add({type = 'checkbox', name = delete_mode_name, state = false}) + local checkbox = tbl_2.add({ type = 'checkbox', name = delete_mode_name, state = false }) data.checkbox = checkbox Gui.set_data(checkbox, data) - tbl.add({type = 'line'}) + tbl.add({ type = 'line' }) player.opened = frame if target and target.valid then @@ -281,7 +281,7 @@ local function update_gui() end frame.clear() - local tbl = frame.add {type = 'table', column_count = 10, name = 'personal_inventory'} + local tbl = frame.add { type = 'table', column_count = 10, name = 'personal_inventory' } local total = 0 local items = {} @@ -302,12 +302,12 @@ local function update_gui() for item_name, item_count in pairs(items) do btn = tbl.add { - type = 'sprite-button', - sprite = 'item/' .. item_name, - style = 'slot_button', - number = item_count, - name = item_name - } + type = 'sprite-button', + sprite = 'item/' .. item_name, + style = 'slot_button', + number = item_count, + name = item_name + } btn.enabled = true btn.style.height = size btn.style.width = size @@ -318,7 +318,7 @@ local function update_gui() end while total < this.total_slots[player.index] do - local btns = tbl.add {type = 'choose-elem-button', style = 'slot_button', elem_type = 'item'} + local btns = tbl.add { type = 'choose-elem-button', style = 'slot_button', elem_type = 'item' } btns.enabled = true btns.style.height = size btns.style.width = size @@ -406,7 +406,7 @@ local function gui_click(event) if not count then return end - local inserted = player.insert {name = name, count = count} + local inserted = player.insert { name = name, count = count } if not inserted then return end @@ -420,7 +420,7 @@ local function gui_click(event) end elseif shift then local count = storage[name] - local stack = game.item_prototypes[name].stack_size + local stack = prototypes.item[name].stack_size if not count then return end @@ -428,10 +428,10 @@ local function gui_click(event) return end if count > stack then - local inserted = player.insert {name = name, count = stack} + local inserted = player.insert { name = name, count = stack } storage[name] = storage[name] - inserted else - player.insert {name = name, count = count} + player.insert { name = name, count = count } storage[name] = nil end if this.inf_gui[player.index] then @@ -568,7 +568,7 @@ end Gui.on_click( main_button_name, - function(event) + function (event) local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Portable Chest Main Button') if is_spamming then return @@ -590,7 +590,7 @@ Gui.on_click( Gui.on_value_changed( stack_slider_name, - function(event) + function (event) local player = event.player local element = event.element @@ -617,7 +617,7 @@ Gui.on_value_changed( Gui.on_checked_state_changed( delete_mode_name, - function(event) + function (event) local player = event.player local element = event.element @@ -639,7 +639,7 @@ Gui.on_checked_state_changed( commands.add_command( 'open_stash', 'Opens a players private stash!', - function(cmd) + function (cmd) local player = game.player if not validate_player(player) then diff --git a/modules/rocks_yield_ore.lua b/modules/rocks_yield_ore.lua index dcaa2f48..b108d9aa 100644 --- a/modules/rocks_yield_ore.lua +++ b/modules/rocks_yield_ore.lua @@ -27,7 +27,7 @@ local particles = { local function get_chances() local chances = {} - if game.entity_prototypes['angels-ore1'] then + if prototypes.entity['angels-ore1'] then for i = 1, 6, 1 do table.insert(chances, { 'angels-ore' .. i, 1 }) end diff --git a/modules/rocks_yield_ore_veins.lua b/modules/rocks_yield_ore_veins.lua index 2b15caf6..f259ad57 100644 --- a/modules/rocks_yield_ore_veins.lua +++ b/modules/rocks_yield_ore_veins.lua @@ -18,7 +18,7 @@ local size_raffle = { local function get_chances() local chances = {} - if game.entity_prototypes['angels-ore1'] then + if prototypes.entity['angels-ore1'] then for i = 1, 6, 1 do table.insert(chances, { 'angels-ore' .. i, 1 }) end @@ -45,7 +45,7 @@ local function set_raffle() end end - if game.entity_prototypes['angels-ore1'] then + if prototypes.entity['angels-ore1'] then storage.rocks_yield_ore_veins.mixed_ores = { 'angels-ore1', 'angels-ore2', 'angels-ore3', 'angels-ore4', 'angels-ore5', 'angels-ore6', 'coal' } return end @@ -90,7 +90,7 @@ local function ore_vein(event) local size = size_raffle[math_random(1, #size_raffle)] local ore = storage.rocks_yield_ore_veins.raffle[math_random(1, #storage.rocks_yield_ore_veins.raffle)] local icon - if game.entity_prototypes[ore] then + if prototypes.entity[ore] then icon = '[img=entity/' .. ore .. ']' else icon = ' ' diff --git a/modules/scramble_ores.lua b/modules/scramble_ores.lua index 75c810df..67cf1eaf 100644 --- a/modules/scramble_ores.lua +++ b/modules/scramble_ores.lua @@ -8,7 +8,7 @@ local stone_ratio = 0.25 --If math.random() is between diversity and this, --Build a table of potential ores to pick from. Uranium is exempt from popping up randomly. local function init() storage.diverse_ores = {} - for k, v in pairs(game.entity_prototypes) do + for k, v in pairs(prototypes.entity) do if v.type == 'resource' and v.resource_category == 'basic-solid' and v.mineable_properties.required_fluid == nil then table.insert(storage.diverse_ores, v.name) end diff --git a/modules/show_inventory.lua b/modules/show_inventory.lua index ff6653e4..ecad4833 100644 --- a/modules/show_inventory.lua +++ b/modules/show_inventory.lua @@ -182,7 +182,7 @@ local function redraw_inventory(gui, source, target, caption, panel_type) gui.clear() local items_table = gui.add({ type = 'table', column_count = 11 }) - local types = game.item_prototypes + local types = prototypes.item local screen = source.gui.screen diff --git a/modules/towny/biters.lua b/modules/towny/biters.lua index f8b2a0cf..f59150b8 100644 --- a/modules/towny/biters.lua +++ b/modules/towny/biters.lua @@ -10,13 +10,13 @@ local table_remove = table.remove local function get_commmands(target, group) local commands = {} - local group_position = {x = group.position.x, y = group.position.y} + local group_position = { x = group.position.x, y = group.position.y } local step_length = 128 local target_position = target.position local distance_to_target = math_floor(math_sqrt((target_position.x - group_position.x) ^ 2 + (target_position.y - group_position.y) ^ 2)) local steps = math_floor(distance_to_target / step_length) + 1 - local vector = {math_round((target_position.x - group_position.x) / steps, 3), math_round((target_position.y - group_position.y) / steps, 3)} + local vector = { math_round((target_position.x - group_position.x) / steps, 3), math_round((target_position.y - group_position.y) / steps, 3) } for i = 1, steps, 1 do group_position.x = group_position.x + vector[1] @@ -25,7 +25,7 @@ local function get_commmands(target, group) if position then commands[#commands + 1] = { type = defines.command.attack_area, - destination = {x = position.x, y = position.y}, + destination = { x = position.x, y = position.y }, radius = 16, distraction = defines.distraction.by_anything } @@ -53,7 +53,7 @@ local function roll_market() local town_centers = townytable.town_centers --Skip Towns that are too low in reserach for the current biter evolution. - local research_threshold = game.forces.enemy.evolution_factor * #game.technology_prototypes * 0.175 + local research_threshold = game.forces.enemy.evolution_factor * #prototypes.technology * 0.175 for k, town_center in pairs(town_centers) do if town_center.research_counter >= research_threshold then @@ -77,7 +77,7 @@ local function roll_market() end local function get_random_close_spawner(surface, market) - local spawners = surface.find_entities_filtered({type = 'unit-spawner'}) + local spawners = surface.find_entities_filtered({ type = 'unit-spawner' }) if not spawners[1] then return false end @@ -135,15 +135,15 @@ function Public.wipe_units_out_of_evo_range() units_to_wipe[#units_to_wipe + 1] = 'medium-spitter' end for k, surface in pairs(game.surfaces) do - for k2, unit in pairs(surface.find_entities_filtered({name = units_to_wipe, force = 'enemy'})) do + for k2, unit in pairs(surface.find_entities_filtered({ name = units_to_wipe, force = 'enemy' })) do unit.destroy() end end end function Public.clear_spawn_for_player(player) - local area = {{player.position.x - 64, player.position.y - 64}, {player.position.x + 64, player.position.y + 64}} - for _, e in pairs(player.surface.find_entities_filtered({force = 'enemy', type = {'unit-spawner', 'unit', 'turret'}, area = area})) do + local area = { { player.position.x - 64, player.position.y - 64 }, { player.position.x + 64, player.position.y + 64 } } + for _, e in pairs(player.surface.find_entities_filtered({ force = 'enemy', type = { 'unit-spawner', 'unit', 'turret' }, area = area })) do e.destroy() end end @@ -187,7 +187,7 @@ function Public.swarm() if not unit_group_position then return end - local unit_group = surface.create_unit_group({position = unit_group_position, force = units[1].force}) + local unit_group = surface.create_unit_group({ position = unit_group_position, force = units[1].force }) local count = (town_center.research_counter * 1.5) + 4 for key, unit in pairs(units) do if key > count then @@ -202,7 +202,7 @@ function Public.swarm() commands = get_commmands(market, unit_group) } ) - table_insert(townytable.swarms, {group = unit_group, timeout = game.tick + 36000}) + table_insert(townytable.swarms, { group = unit_group, timeout = game.tick + 36000 }) end function Public.set_evolution() @@ -213,7 +213,7 @@ function Public.set_evolution() return end - local max_research_count = math_floor(#game.technology_prototypes * 0.30) + local max_research_count = math_floor(#prototypes.technology * 0.30) local evo = 0 for _, town_center in pairs(townytable.town_centers) do diff --git a/utils/commands/misc.lua b/utils/commands/misc.lua index 3e4b81bd..286e97b5 100644 --- a/utils/commands/misc.lua +++ b/utils/commands/misc.lua @@ -355,7 +355,7 @@ function Public.insert_all_items(player) player.get_inventory(defines.inventory.character_armor).clear() end player.insert { name = 'power-armor-mk2', count = 1 } - Modifiers.update_single_modifier(player, 'character_inventory_slots_bonus', 'creative', #game.item_prototypes) + Modifiers.update_single_modifier(player, 'character_inventory_slots_bonus', 'creative', #prototypes.item) Modifiers.update_single_modifier(player, 'character_mining_speed_modifier', 'creative', 150) Modifiers.update_single_modifier(player, 'character_health_bonus', 'creative', 2000) Modifiers.update_single_modifier(player, 'character_crafting_speed_modifier', 'creative', 150) @@ -382,7 +382,7 @@ function Public.insert_all_items(player) p_armor.put({ name = 'battery-mk2-equipment' }) p_armor.put({ name = 'battery-mk2-equipment' }) end - local item = game.item_prototypes + local item = prototypes.item local i = 0 for _k, _v in pairs(item) do i = i + 1 diff --git a/utils/functions/loot_raffle.lua b/utils/functions/loot_raffle.lua index 1f806354..8b06bfdd 100644 --- a/utils/functions/loot_raffle.lua +++ b/utils/functions/loot_raffle.lua @@ -458,7 +458,7 @@ function Public.roll_item_stack(remaining_budget, blacklist) end end - local stack_size = game.item_prototypes[item_name] and game.item_prototypes[item_name].stack_size and game.item_prototypes[item_name].stack_size + local stack_size = prototypes.item[item_name] and prototypes.item[item_name].stack_size and prototypes.item[item_name].stack_size if not stack_size then stack_size = 1 end local item_count = 1 diff --git a/utils/terrain_layouts/watery_world.lua b/utils/terrain_layouts/watery_world.lua index 86c7c024..e2a37da8 100644 --- a/utils/terrain_layouts/watery_world.lua +++ b/utils/terrain_layouts/watery_world.lua @@ -70,7 +70,7 @@ end local function on_init() storage.watery_world_fishes = {} - for _, prototype in pairs(game.entity_prototypes) do + for _, prototype in pairs(prototypes.entity) do if prototype.type == 'fish' then table.insert(storage.watery_world_fishes, prototype.name) end