From af0d9e322692daa9f9b23d762d22de2d7c916200 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 14 Jan 2025 17:01:17 +0100 Subject: [PATCH] Update for journey --- locale/en/journey.cfg | 2 +- maps/journey/functions.lua | 30 +++++++++++++++++++----------- maps/journey/main.lua | 3 +++ maps/journey/unique_modifiers.lua | 4 ++-- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/locale/en/journey.cfg b/locale/en/journey.cfg index 73049f28..120d0a81 100644 --- a/locale/en/journey.cfg +++ b/locale/en/journey.cfg @@ -1,6 +1,6 @@ [journey] map_info_main_caption=The Journey -map_info_sub_caption=v 1.9 +map_info_sub_caption=v 2.0 map_info_text=The selectors in the mothership, allow you to choose a destination.\nWorlds can be rerolled by spending a satellite at the top selector.\nOnce enough players are on a selector, mothership will start traveling.\n\nA teleporter will be deployed, after reaching the target.\nIt is however, only capable of transfering the subjects body.\n\nWorlds will get more difficult with each jump, stacking the chosen modifiers.\nLaunch uranium fuel cells via rocket cargo, to advance to the next world.\nThe tooltips on the top buttons yield informations about the current world.\nIf the journey ends, an admin can fully reset the map via command "/journey-reset".\n\nHow far will the journey lead? tooltip_satellite=Satellites stored: __1__ / __2__\nSatellites are used by Mothership to scout for alternative destinations. diff --git a/maps/journey/functions.lua b/maps/journey/functions.lua index c031498c..60660f8a 100644 --- a/maps/journey/functions.lua +++ b/maps/journey/functions.lua @@ -27,7 +27,7 @@ local function clear_selectors(journey) end local function protect(entity, operable) - entity.minable = false + entity.minable_flag = false entity.destructible = false entity.operable = operable end @@ -62,7 +62,7 @@ local function place_teleporter(journey, surface, position, build_beacon) local beacon = surface.create_entity({ name = 'cargo-landing-pad', position = { x = position.x + 3, y = position.y + 2 }, force = 'player' }) journey.beacon_objective_health = 10000 beacon.operable = true - beacon.minable = false + beacon.minable_flag = false beacon.active = true rendering.draw_text { text = { 'journey.teleporter' }, @@ -235,7 +235,7 @@ local function delete_nauvis_chunks(journey) 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', 'roboport', 'spider-vehicle'} }) do e.destroy() end for _, player in pairs(game.players) do @@ -253,7 +253,7 @@ local function delete_nauvis_chunks(journey) return end - for _ = 1, 12, 1 do + for _ = 1, 1, 1 do --1 chunk per action until 2.0.31! TODO: fix back to 12 when version released local chunk_position = journey.nauvis_chunk_positions[journey.size_of_nauvis_chunk_positions] if chunk_position then surface.delete_chunk(chunk_position) @@ -526,6 +526,7 @@ function Public.hard_reset(journey) Autostash.bottom_button(true) Misc.bottom_button(true) if game.surfaces.mothership and game.surfaces.mothership.valid then + game.surfaces.mothership.destroy_global_electric_network() game.delete_surface(game.surfaces.mothership) end @@ -608,6 +609,7 @@ 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.force_generate_chunk_requests() + surface.create_global_electric_network() surface.freeze_daytime = true journey.game_state = 'draw_mothership' end @@ -694,7 +696,7 @@ function Public.draw_mothership(journey) only_in_alt_mode = false } - for k, item_name in pairs({ 'arithmetic-combinator', 'constant-combinator', 'decider-combinator', 'selector-combinator', 'display-panel', 'programmable-speaker', 'small-lamp', 'substation', 'pipe', 'gate', 'stone-wall', 'transport-belt' }) do + for k, item_name in pairs({ 'arithmetic-combinator', 'constant-combinator', 'decider-combinator', 'selector-combinator', 'display-panel', 'programmable-speaker', 'small-lamp', 'pipe', 'gate', 'stone-wall', 'transport-belt' }) do local chest = surface.create_entity({ name = 'infinity-chest', position = { -7 + k, Constants.mothership_radius - 3 }, force = 'player' }) if not chest or not chest.valid then break end chest.set_infinity_container_filter(1, { name = item_name, count = prototypes.item[item_name].stack_size, index = 1 }) @@ -707,8 +709,6 @@ function Public.draw_mothership(journey) for m = -1, 1, 2 do 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' }) - protect(sub, true) end for m = -1, 1, 2 do @@ -1445,10 +1445,15 @@ function Public.dispatch_goods(journey) if journey.dispatch_beacon_position then local good = goods_to_dispatch[journey.dispatch_key] local pod = surface.create_entity({name = 'cargo-pod-container', position = journey.dispatch_beacon_position, force = game.forces.player}) + local itemcount = good[2] if pod and pod.valid then - pod.insert({name = good[1], count = good[2]}) - else - surface.spill_item_stack({ position = journey.dispatch_beacon_position, stack = { name = good[1], count = good[2] }, enable_looted = true, allow_belts = false }) + local inserted = pod.insert({name = good[1], count = itemcount}) + if inserted > 0 then + itemcount = itemcount - inserted + end + end + if itemcount > 0 then + surface.spill_item_stack({ position = journey.dispatch_beacon_position, stack = { name = good[1], count = itemcount }, enable_looted = true, allow_belts = false }) end table.remove(journey.goods_to_dispatch, journey.dispatch_key) journey.dispatch_beacon = nil @@ -1469,7 +1474,7 @@ function Public.dispatch_goods(journey) end journey.dispatch_beacon = surface.create_entity({ name = 'stone-wall', position = position, force = 'neutral' }) - journey.dispatch_beacon.minable = false + journey.dispatch_beacon.minable_flag = false journey.dispatch_beacon_position = { x = position.x, y = position.y } journey.dispatch_key = Math.random(1, size_of_goods_to_dispatch) @@ -1576,6 +1581,9 @@ function Public.teleporters(journey, player) if not player.character.valid then return end + if player.vehicle then + return + end local surface = player.physical_surface local tile = surface.get_tile(player.physical_position) if not tile or not tile.valid then diff --git a/maps/journey/main.lua b/maps/journey/main.lua index 76f482b2..189efd3e 100644 --- a/maps/journey/main.lua +++ b/maps/journey/main.lua @@ -194,6 +194,9 @@ local function on_rocket_launched(event) force.technologies['space-science-pack'].researched = true force.print('[technology=space-science-pack] researched.') force.play_sound({path = 'utility/research_completed'}) + table.insert(journey.goods_to_dispatch, { 'loader', 3 }) + table.insert(journey.mothership_messages, 'I am sending you some loaders. Use them to load the rocket silos with all needed items.') + journey.game_state = 'dispatch_goods' end Functions.draw_gui(journey) end diff --git a/maps/journey/unique_modifiers.lua b/maps/journey/unique_modifiers.lua index e6c04b55..3783df3d 100644 --- a/maps/journey/unique_modifiers.lua +++ b/maps/journey/unique_modifiers.lua @@ -239,7 +239,7 @@ Public.tarball = { if tarball_minable[entity.type] then return end - entity.minable = false + entity.minable_flag = false end, on_built_entity = function (event) local entity = event.entity @@ -252,7 +252,7 @@ Public.tarball = { if tarball_minable[entity.type] then return end - entity.minable = false + entity.minable_flag = false end, on_chunk_generated = function (event, journey) table.insert(