Split mod
This commit is contained in:
parent
4ea352f466
commit
f47a9121e9
101 changed files with 803 additions and 786 deletions
34
lignumis-base/scripts/init-existing.lua
Normal file
34
lignumis-base/scripts/init-existing.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
local InitExisting = {}
|
||||
|
||||
-- Initialization for existing games
|
||||
-- Don't send players to Lignumis but instead print a warning
|
||||
|
||||
InitExisting.on_init = function()
|
||||
if game.tick == 0 then return end
|
||||
|
||||
storage.target_planet = settings.startup["lignumis-second-planet"].value or "nauvis"
|
||||
|
||||
if script.active_mods["any-planet-start"] then
|
||||
storage.target_planet = settings.startup["aps-planet"].value ~= "none" and settings.startup["aps-planet"].value or storage.target_planet
|
||||
end
|
||||
|
||||
storage.init = {}
|
||||
for _, player in pairs(game.players) do
|
||||
storage.init[player.index] = true
|
||||
if player.physical_surface.name == "nauvis" then
|
||||
storage.nauvis_visited = true
|
||||
end
|
||||
end
|
||||
|
||||
for _, force in pairs(game.forces) do
|
||||
if force.is_space_location_unlocked("nauvis") then
|
||||
force.technologies["planet-discovery-nauvis"].researched = true
|
||||
end
|
||||
force.technologies["iron-processing"].researched = true
|
||||
force.technologies["copper-processing"].researched = true
|
||||
end
|
||||
|
||||
game.print { "", { "lignumis.start-new-game" } }
|
||||
end
|
||||
|
||||
return InitExisting
|
||||
79
lignumis-base/scripts/init-new.lua
Normal file
79
lignumis-base/scripts/init-new.lua
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
local InitNew = {}
|
||||
|
||||
-- Initialization for new games
|
||||
-- Send all players to Lignumis and clear Nauvis
|
||||
|
||||
|
||||
-- Initialize the freeplay intro
|
||||
local function init_intro()
|
||||
if not remote.interfaces.freeplay then return end
|
||||
|
||||
-- Disable Nauvis intro
|
||||
remote.call("freeplay", "set_disable_crashsite", true)
|
||||
remote.call("freeplay", "set_skip_intro", true)
|
||||
|
||||
-- Replace yellow ammo with wood ammo
|
||||
-- Wooden military does the same already
|
||||
if not script.active_mods["wood-military"] then
|
||||
local respawn_items = remote.call("freeplay", "get_respawn_items")
|
||||
respawn_items["wood-darts-magazine"] = respawn_items["firearm-magazine"]
|
||||
respawn_items["firearm-magazine"] = nil
|
||||
remote.call("freeplay", "set_respawn_items", respawn_items)
|
||||
|
||||
local created_items = remote.call("freeplay", "get_created_items")
|
||||
created_items["wood-darts-magazine"] = created_items["firearm-magazine"]
|
||||
created_items["firearm-magazine"] = nil
|
||||
remote.call("freeplay", "set_created_items", created_items)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Initialize space locations
|
||||
-- Lock Nauvis, unlock Lignumis
|
||||
local function init_space_locations()
|
||||
local force = game.forces.player
|
||||
force.technologies["planet-discovery-lignumis"].researched = true
|
||||
if game.planets["nauvis"] and force.technologies["planet-discovery-nauvis"] and not force.technologies["planet-discovery-nauvis"].researched then
|
||||
force.lock_space_location("nauvis")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Initialize Lignumis
|
||||
local function init_lignumis()
|
||||
storage.surface = game.planets["lignumis"].create_surface()
|
||||
storage.surface.request_to_generate_chunks({ 0, 0 }, 3)
|
||||
storage.surface.force_generate_chunk_requests()
|
||||
storage.surface.daytime = 0.7
|
||||
|
||||
-- Chart starting area
|
||||
local r = 200
|
||||
local force = game.forces.player
|
||||
local origin = force.get_spawn_position(storage.surface)
|
||||
force.chart(storage.surface, { { origin.x - r, origin.y - r }, { origin.x + r, origin.y + r } })
|
||||
end
|
||||
|
||||
|
||||
-- Clear Nauvis surface as we start on Lignumis
|
||||
local function clear_nauvis()
|
||||
game.get_surface("nauvis").clear()
|
||||
end
|
||||
|
||||
|
||||
InitNew.on_init = function()
|
||||
if game.tick > 0 then return end
|
||||
|
||||
storage.target_planet = settings.startup["lignumis-second-planet"].value or "nauvis"
|
||||
|
||||
if script.active_mods["any-planet-start"] then
|
||||
storage.target_planet = settings.startup["aps-planet"].value ~= "none" and settings.startup["aps-planet"].value or storage.target_planet
|
||||
remote.call("APS", "override_planet", "lignumis")
|
||||
end
|
||||
|
||||
init_intro()
|
||||
init_space_locations()
|
||||
init_lignumis()
|
||||
clear_nauvis()
|
||||
end
|
||||
|
||||
return InitNew
|
||||
152
lignumis-base/scripts/init.lua
Normal file
152
lignumis-base/scripts/init.lua
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
local crash_site = require("crash-site")
|
||||
local util = require("util")
|
||||
|
||||
-- General initialization
|
||||
|
||||
local Init = {
|
||||
events = {}
|
||||
}
|
||||
|
||||
-- Initialize the player
|
||||
-- Teleport to Lignumis and give some starting items
|
||||
local function init_player(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local surface = storage.surface or game.planets["lignumis"].surface
|
||||
|
||||
if not player.character or not surface then return end
|
||||
|
||||
player.teleport(surface.find_non_colliding_position("character", { 0, 0 }, 0, 1), "lignumis")
|
||||
local main_inventory = player.character.get_main_inventory()
|
||||
|
||||
-- Add some starting items to player inventory
|
||||
main_inventory.insert({ name = "lumber", count = 8 })
|
||||
end
|
||||
|
||||
|
||||
-- Initialize the freeplay scenario
|
||||
local function init_freeplay(event)
|
||||
if storage.crashed_ship_lignumis then return end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
if not player or not remote.interfaces.freeplay then return end
|
||||
|
||||
storage.crashed_ship_lignumis = true
|
||||
local surface = storage.surface or game.planets["lignumis"].surface
|
||||
storage.crashed_ship_items = remote.call("freeplay", "get_ship_items")
|
||||
storage.crashed_debris_items = remote.call("freeplay", "get_debris_items")
|
||||
storage.crashed_ship_parts = remote.call("freeplay", "get_ship_parts")
|
||||
storage.starting_message = remote.call("freeplay", "get_custom_intro_message")
|
||||
|
||||
local ship_items = {
|
||||
["burner-mining-drill"] = 1,
|
||||
["burner-agricultural-tower"] = 2
|
||||
}
|
||||
local debris_items = {
|
||||
["lumber"] = 8,
|
||||
["wood-darts-magazine"] = 2
|
||||
}
|
||||
|
||||
crash_site.create_crash_site(surface, { -5, -6 }, ship_items, debris_items,
|
||||
table.deepcopy(storage.crashed_ship_parts))
|
||||
util.remove_safe(player, storage.crashed_ship_items)
|
||||
util.remove_safe(player, storage.crashed_debris_items)
|
||||
if player.character then
|
||||
player.character.get_main_inventory().sort_and_merge()
|
||||
end
|
||||
|
||||
storage.crash_site_cutscene_active = true
|
||||
crash_site.create_cutscene(player, { -5, -4 })
|
||||
end
|
||||
|
||||
|
||||
Init.events[defines.events.on_player_created] = function(event)
|
||||
storage.init = storage.init or {}
|
||||
|
||||
if storage.init[event.player_index] then return end
|
||||
|
||||
storage.init[event.player_index] = true
|
||||
|
||||
if not script.active_mods["Burner-Leech-Fork"] and not script.active_mods["Burner-Leech"] and not script.active_mods["InserterFuelLeech"] then
|
||||
game.print("Lignumis: You are starting a new game without a burner leech mod. The intended experience is to use one of the available options. You can disable such a mod after the burner phase of the game. See the mod page for more details.")
|
||||
end
|
||||
|
||||
if not script.active_mods["any-planet-start"] then
|
||||
init_player(event)
|
||||
init_freeplay(event)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Watch Nauvis being visited for the first time
|
||||
Init.events[defines.events.on_player_changed_surface] = function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
if player.controller_type ~= defines.controllers.character then return end
|
||||
|
||||
if player and player.surface.name == storage.target_planet then
|
||||
storage.nauvis_visited = true
|
||||
end
|
||||
|
||||
if player and player.surface.name ~= "lignumis" and player.force then
|
||||
local automation = player.force.technologies["automation-science-pack"]
|
||||
if not automation.researched then
|
||||
automation.enabled = true
|
||||
automation.researched = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- End intro and show starting message
|
||||
Init.events[defines.events.on_cutscene_waypoint_reached] = function(event)
|
||||
if not storage.crash_site_cutscene_active then return end
|
||||
if not crash_site.is_crash_site_cutscene(event) then return end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
player.exit_cutscene()
|
||||
|
||||
if storage.skip_intro then return end
|
||||
|
||||
local intro_message = storage.custom_intro_message or { "msg-intro-space-age" }
|
||||
|
||||
if game.is_multiplayer() then
|
||||
player.print(intro_message)
|
||||
else
|
||||
game.show_message_dialog { text = intro_message }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Cancel intro
|
||||
Init.events["crash-site-skip-cutscene"] = function(event)
|
||||
if not storage.crash_site_cutscene_active then return end
|
||||
if event.player_index ~= 1 then return end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
if player.controller_type == defines.controllers.cutscene then
|
||||
player.exit_cutscene()
|
||||
end
|
||||
end
|
||||
|
||||
Init.events[defines.events.on_cutscene_cancelled] = function(event)
|
||||
if not storage.crash_site_cutscene_active then return end
|
||||
if event.player_index ~= 1 then return end
|
||||
|
||||
storage.crash_site_cutscene_active = nil
|
||||
local player = game.get_player(event.player_index)
|
||||
if player.gui.screen.skip_cutscene_label then
|
||||
player.gui.screen.skip_cutscene_label.destroy()
|
||||
end
|
||||
player.zoom = 1.5
|
||||
end
|
||||
|
||||
Init.on_configuration_changed = function()
|
||||
storage.target_planet = settings.startup["lignumis-second-planet"].value or "nauvis"
|
||||
|
||||
if script.active_mods["any-planet-start"] then
|
||||
storage.target_planet = settings.startup["aps-planet"].value ~= "none" and settings.startup["aps-planet"].value or storage.target_planet
|
||||
end
|
||||
end
|
||||
|
||||
return Init
|
||||
207
lignumis-base/scripts/to-nauvis.lua
Normal file
207
lignumis-base/scripts/to-nauvis.lua
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
local crash_site = require("crash-site")
|
||||
|
||||
-- Transition from Lignumis to Nauvis with the provisional rocket silo
|
||||
|
||||
local ToNauvis = {
|
||||
events = {}
|
||||
}
|
||||
|
||||
-- Chart the starting area for the player
|
||||
local function chart_starting_area(surface, player)
|
||||
local r = 200
|
||||
local force = player.force
|
||||
local origin = force.get_spawn_position(surface)
|
||||
force.chart(surface, { { origin.x - r, origin.y - r }, { origin.x + r, origin.y + r } })
|
||||
end
|
||||
|
||||
|
||||
-- Initialize Nauvis
|
||||
local function init_nauvis()
|
||||
if storage.nauvis_visited then return end
|
||||
local nauvis = game.planets[storage.target_planet].create_surface()
|
||||
nauvis.request_to_generate_chunks({ 0, 0 }, 3)
|
||||
nauvis.force_generate_chunk_requests()
|
||||
nauvis.daytime = 0.7
|
||||
end
|
||||
|
||||
|
||||
-- Removes enemies around the crash site to not mess with the player start
|
||||
local function clear_enemies()
|
||||
local nauvis = game.planets[storage.target_planet].surface
|
||||
local enemies = nauvis.find_entities_filtered({
|
||||
position = { 0, 0 },
|
||||
radius = 200,
|
||||
force = "enemy"
|
||||
})
|
||||
for _, enemy in pairs(enemies) do
|
||||
enemy.destroy()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Teleport player to Nauvis and show welcome message
|
||||
local function teleport_player(player)
|
||||
local nauvis = game.planets[storage.target_planet].surface
|
||||
if player.surface.name == "lignumis" then
|
||||
local position = nauvis.find_non_colliding_position("character", { 2, 2 }, 100, 1) or { 0, 0 }
|
||||
player.teleport(position, storage.target_planet)
|
||||
chart_starting_area(nauvis, player)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Initialize the Nauvis freeplay scenario
|
||||
local function init_freeplay()
|
||||
if storage.crashed_ship_nauvis then return end
|
||||
if not remote.interfaces.freeplay then return end
|
||||
|
||||
storage.crashed_ship_nauvis = true
|
||||
local nauvis = game.planets[storage.target_planet].surface
|
||||
local ship_items = {
|
||||
["burner-mining-drill"] = 2,
|
||||
["stone-furnace"] = 2,
|
||||
["burner-assembling-machine"] = 2,
|
||||
["burner-agricultural-tower"] = 2,
|
||||
["wood-lab"] = 2
|
||||
}
|
||||
local debris_items = { ["wood-darts-magazine"] = 20, ["wood"] = 20, ["lumber"] = 20 }
|
||||
local crashed_ship_parts = remote.call("freeplay", "get_ship_parts")
|
||||
|
||||
crash_site.create_crash_site(nauvis, { -5, -6 }, ship_items, debris_items, table.deepcopy(crashed_ship_parts))
|
||||
end
|
||||
|
||||
|
||||
local function transit_player(player_index)
|
||||
local player = game.get_player(player_index)
|
||||
local transition = storage.transitions[player_index]
|
||||
|
||||
if transition.rocket_entry.cargo_pod then
|
||||
transition.rocket_entry.cargo_pod.set_passenger(nil)
|
||||
transition.rocket_entry.cargo_pod.destroy()
|
||||
end
|
||||
|
||||
init_nauvis()
|
||||
clear_enemies()
|
||||
teleport_player(player)
|
||||
init_freeplay()
|
||||
|
||||
-- Give the player the content of the rocket
|
||||
if transition.rocket_entry.rocket_content then
|
||||
local inventory = player.get_main_inventory()
|
||||
if inventory then
|
||||
for _, item in pairs(transition.rocket_entry.rocket_content) do
|
||||
inventory.insert(item)
|
||||
end
|
||||
inventory.sort_and_merge()
|
||||
end
|
||||
end
|
||||
table.remove(storage.rocket_silos, transition.rocket_entry_index)
|
||||
end
|
||||
|
||||
|
||||
local function explode_silo(silo)
|
||||
silo.die()
|
||||
end
|
||||
|
||||
|
||||
local get_random_position = function(box, x_scale, y_scale)
|
||||
x_scale = x_scale or 1
|
||||
y_scale = y_scale or 1
|
||||
local x1 = box.left_top.x
|
||||
local y1 = box.left_top.y
|
||||
local x2 = box.right_bottom.x
|
||||
local y2 = box.right_bottom.y
|
||||
local x = ((x2 - x1) * x_scale * (math.random() - 0.5)) + ((x1 + x2) / 2)
|
||||
local y = ((y2 - y1) * y_scale * (math.random() - 0.5)) + ((y1 + y2) / 2)
|
||||
return { x, y }
|
||||
end
|
||||
|
||||
|
||||
local function burn_silo(silo)
|
||||
local surface = silo.surface
|
||||
local box = silo.bounding_box
|
||||
for k = 1, 6 do
|
||||
local position = get_random_position(box, 0.8, 0.5)
|
||||
surface.create_entity
|
||||
{
|
||||
name = "crash-site-fire-flame",
|
||||
position = position
|
||||
}
|
||||
local fire = surface.create_entity
|
||||
{
|
||||
name = "crash-site-fire-smoke",
|
||||
position = position
|
||||
}
|
||||
fire.time_to_live = math.random(59 * 9, 59 * 14 - 1)
|
||||
fire.time_to_next_effect = math.random(59 * 2)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function pre_explode_silo(silo)
|
||||
local surface = silo.surface
|
||||
local box = silo.bounding_box
|
||||
for k = 1, 3 do
|
||||
local explosions = surface.create_entity
|
||||
{
|
||||
name = "crash-site-explosion-smoke",
|
||||
position = get_random_position(box, 0.8, 0.5)
|
||||
}
|
||||
explosions.time_to_live = math.random(59 * 6, 59 * 11 - 1)
|
||||
explosions.time_to_next_effect = math.random(59 * 3)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ToNauvis.events[defines.events.on_rocket_launch_ordered] = function(event)
|
||||
if not event.rocket_silo or event.rocket_silo.name ~= "provisional-rocket-silo" then return end
|
||||
|
||||
local player
|
||||
|
||||
for i, entry in pairs(storage.rocket_silos) do
|
||||
if entry.real_silo == event.rocket_silo then
|
||||
if not storage.transitions then
|
||||
storage.transitions = {}
|
||||
end
|
||||
player = entry.player and game.get_player(entry.player) or game.players[1]
|
||||
storage.transitions[player.index] = {
|
||||
rocket_entry = entry,
|
||||
rocket_entry_index = i
|
||||
}
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local burn_tick = game.tick + (14 * 59)
|
||||
local pre_explode_tick = game.tick + (17 * 59)
|
||||
local transit_tick = game.tick + (23 * 59)
|
||||
local explode_tick = game.tick + (28 * 59)
|
||||
|
||||
script.on_nth_tick(burn_tick, function()
|
||||
burn_silo(event.rocket_silo)
|
||||
script.on_nth_tick(burn_tick, nil)
|
||||
end)
|
||||
|
||||
script.on_nth_tick(pre_explode_tick, function()
|
||||
pre_explode_silo(event.rocket_silo)
|
||||
script.on_nth_tick(pre_explode_tick, nil)
|
||||
end)
|
||||
|
||||
script.on_nth_tick(transit_tick, function()
|
||||
transit_player(player.index)
|
||||
script.on_nth_tick(transit_tick, nil)
|
||||
end)
|
||||
|
||||
script.on_nth_tick(explode_tick, function()
|
||||
explode_silo(event.rocket_silo)
|
||||
script.on_nth_tick(explode_tick, nil)
|
||||
end)
|
||||
end
|
||||
|
||||
ToNauvis.events[defines.events.on_post_entity_died] = function(event)
|
||||
if not event.ghost or event.prototype.name ~= "provisional-rocket-silo" then return end
|
||||
event.ghost.destroy()
|
||||
end
|
||||
|
||||
return ToNauvis
|
||||
159
lignumis-base/scripts/wooden-rocket-silo.lua
Normal file
159
lignumis-base/scripts/wooden-rocket-silo.lua
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
local RocketSilo = {
|
||||
events = {}
|
||||
}
|
||||
|
||||
|
||||
-- Logic for provisional rocket silo with fake silo with inventory and custom launch GUI
|
||||
|
||||
local function build_gui(player, rocket_silo)
|
||||
local anchor = {
|
||||
gui = defines.relative_gui_type.container_gui,
|
||||
names = { "provisional-rocket-silo-ready" },
|
||||
position = defines.relative_gui_position.right
|
||||
}
|
||||
|
||||
local target_planet_name = { "space-location-name." .. storage.target_planet }
|
||||
local launch_button = { type = "button", name = "provisional-rocket-silo-launch-button", caption = { "lignumis.provisional-rocket-silo-button", target_planet_name } }
|
||||
|
||||
local inventory = player.get_main_inventory()
|
||||
local is_inventory_empty = inventory.is_empty()
|
||||
local is_nauvis_researched = player.force.technologies["planet-discovery-" .. storage.target_planet].researched
|
||||
launch_button.enabled = is_inventory_empty and is_nauvis_researched
|
||||
if not is_inventory_empty then
|
||||
launch_button.tooltip = { "lignumis.provisional-rocket-silo-button-tooltip-inventory" }
|
||||
elseif not is_nauvis_researched then
|
||||
launch_button.tooltip = { "lignumis.provisional-rocket-silo-button-tooltip-target" }
|
||||
end
|
||||
|
||||
|
||||
storage.rocket_silo_guis = storage.rocket_silo_guis or {}
|
||||
storage.rocket_silo_guis[player.index] = {
|
||||
fake_silo = rocket_silo,
|
||||
gui = gui.add(player.gui.relative, {
|
||||
{
|
||||
type = "frame",
|
||||
name = "provisional-rocket-silo-relative-frame",
|
||||
direction = "vertical",
|
||||
anchor = anchor,
|
||||
children = {
|
||||
{ type = "label", style = "frame_title", caption = { "lignumis.provisional-rocket-silo-button", target_planet_name }, ignored_by_interaction = true },
|
||||
{
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
style = "inside_shallow_frame_with_padding",
|
||||
children = {
|
||||
{
|
||||
type = "flow",
|
||||
direction = "vertical",
|
||||
style = "inset_frame_container_vertical_flow",
|
||||
children = {
|
||||
{ type = "label", caption = { "lignumis.provisional-rocket-silo-description", target_planet_name } },
|
||||
launch_button
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
local function on_gui_opened(event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then return end
|
||||
if entity.name ~= "provisional-rocket-silo-ready" then return end
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
if player.gui.relative["provisional-rocket-silo-relative-frame"] then
|
||||
player.gui.relative["provisional-rocket-silo-relative-frame"].destroy()
|
||||
end
|
||||
|
||||
if player.controller_type ~= defines.controllers.character then return end
|
||||
|
||||
build_gui(player, entity)
|
||||
end
|
||||
|
||||
|
||||
local function on_gui_closed(event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then return end
|
||||
if entity.name ~= "provisional-rocket-silo-ready" then return end
|
||||
end
|
||||
|
||||
|
||||
local function launch(event)
|
||||
if event.element.name ~= "provisional-rocket-silo-launch-button" then return end
|
||||
local player = game.get_player(event.player_index)
|
||||
local fake_silo = storage.rocket_silo_guis[player.index].fake_silo
|
||||
rocket_content = fake_silo.get_inventory(defines.inventory.chest).get_contents()
|
||||
for _, entry in pairs(storage.rocket_silos) do
|
||||
if entry.fake_silo == fake_silo then
|
||||
entry.player = event.player_index
|
||||
entry.rocket_content = rocket_content
|
||||
entry.cargo_pod = entry.real_silo.rocket.attached_cargo_pod
|
||||
fake_silo.destroy()
|
||||
entry.real_silo.launch_rocket()
|
||||
entry.cargo_pod.set_passenger(player)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function on_silo_mined(event)
|
||||
if event.entity.name ~= "provisional-rocket-silo-ready" then return end
|
||||
local fake_silo = event.entity
|
||||
local player = game.get_player(event.player_index)
|
||||
for i, entry in pairs(storage.rocket_silos) do
|
||||
if entry.fake_silo == fake_silo then
|
||||
if entry.real_silo.valid then
|
||||
player.mine_entity(entry.real_silo, true)
|
||||
end
|
||||
table.remove(storage.rocket_silos, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
RocketSilo.on_init = function()
|
||||
storage.rocket_silos = {}
|
||||
storage.rocket_silo_guis = {}
|
||||
end
|
||||
|
||||
|
||||
RocketSilo.events[defines.events.on_script_trigger_effect] = function(event)
|
||||
if event.effect_id ~= "provisional-rocket-ready" then return end
|
||||
|
||||
local lignumis = game.planets["lignumis"].surface
|
||||
|
||||
if event.surface_index ~= lignumis.index then return end
|
||||
|
||||
local real_silo = event.cause_entity
|
||||
local fake_silo = real_silo.surface.create_entity({
|
||||
name = "provisional-rocket-silo-ready",
|
||||
position = real_silo.position,
|
||||
force = real_silo.force,
|
||||
create_build_effect_smoke = false,
|
||||
})
|
||||
storage.rocket_silos = storage.rocket_silos or {}
|
||||
table.insert(storage.rocket_silos, {
|
||||
real_silo = real_silo,
|
||||
fake_silo = fake_silo
|
||||
})
|
||||
for _, player in pairs(real_silo.force.players) do
|
||||
if player.selected == real_silo then
|
||||
player.selected = fake_silo
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RocketSilo.events[defines.events.on_gui_opened] = on_gui_opened
|
||||
RocketSilo.events[defines.events.on_gui_closed] = on_gui_closed
|
||||
RocketSilo.events[defines.events.on_gui_click] = launch
|
||||
RocketSilo.events[defines.events.on_player_mined_entity] = on_silo_mined
|
||||
|
||||
|
||||
return RocketSilo
|
||||
Loading…
Add table
Add a link
Reference in a new issue