forked from cacklingfiend/lignumis
Add compatibility for "Any planet start" (Vulcanus)
This commit is contained in:
parent
d15f877fe1
commit
c5d94ec0b9
13 changed files with 89 additions and 40 deletions
|
|
@ -6,6 +6,12 @@ local InitExisting = {}
|
|||
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
|
||||
|
|
|
|||
|
|
@ -63,6 +63,13 @@ 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()
|
||||
|
|
|
|||
|
|
@ -7,19 +7,6 @@ local Init = {
|
|||
events = {}
|
||||
}
|
||||
|
||||
local target_planet = settings.global["lignumis-second-planet"].value or "nauvis"
|
||||
|
||||
|
||||
-- Migrate storage init as it was just a boolean before not supporting multiple players
|
||||
local function migrate_0_9_6(event)
|
||||
if storage.init and type(storage.init) == "boolean" then
|
||||
storage.init = {
|
||||
[event.player_index] = true
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Initialize the player
|
||||
-- Teleport to Lignumis and give some starting items
|
||||
local function init_player(event)
|
||||
|
|
@ -74,7 +61,6 @@ end
|
|||
|
||||
|
||||
Init.events[defines.events.on_player_created] = function(event)
|
||||
migrate_0_9_6(event)
|
||||
storage.init = storage.init or {}
|
||||
|
||||
if storage.init[event.player_index] then return end
|
||||
|
|
@ -85,8 +71,10 @@ Init.events[defines.events.on_player_created] = function(event)
|
|||
game.print("While Alien Biomes is playable with Lignumis, it is not recommended as it prevents trees from being generated on Lignumis.")
|
||||
end
|
||||
|
||||
init_player(event)
|
||||
init_freeplay(event)
|
||||
if not script.active_mods["any-planet-start"] then
|
||||
init_player(event)
|
||||
init_freeplay(event)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -96,7 +84,7 @@ Init.events[defines.events.on_player_changed_surface] = function(event)
|
|||
|
||||
if player.controller_type ~= defines.controllers.character then return end
|
||||
|
||||
if player and player.surface.name == target_planet then
|
||||
if player and player.surface.name == storage.target_planet then
|
||||
storage.nauvis_visited = true
|
||||
end
|
||||
|
||||
|
|
@ -153,4 +141,12 @@ Init.events[defines.events.on_cutscene_cancelled] = function(event)
|
|||
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
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ local ToNauvis = {
|
|||
events = {}
|
||||
}
|
||||
|
||||
local target_planet = settings.global["lignumis-second-planet"].value or "nauvis"
|
||||
|
||||
-- Chart the starting area for the player
|
||||
local function chart_starting_area(surface, player)
|
||||
local r = 200
|
||||
|
|
@ -20,7 +18,7 @@ end
|
|||
-- Initialize Nauvis
|
||||
local function init_nauvis()
|
||||
if storage.nauvis_visited then return end
|
||||
local nauvis = game.planets[target_planet].create_surface()
|
||||
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
|
||||
|
|
@ -29,12 +27,11 @@ end
|
|||
|
||||
-- Teleport player to Nauvis and show welcome message
|
||||
local function teleport_player(player)
|
||||
local nauvis = game.planets[target_planet].surface
|
||||
local nauvis = game.planets[storage.target_planet].surface
|
||||
if player.surface.name == "lignumis" then
|
||||
local position = nauvis.find_non_colliding_position("character", { 0, 0 }, 100, 1) or { 0, 0 }
|
||||
player.teleport(position, target_planet)
|
||||
player.teleport(position, storage.target_planet)
|
||||
chart_starting_area(nauvis, player)
|
||||
player.print("Oh no, not again. But... Welcome to Nauvis!")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -45,7 +42,7 @@ local function init_freeplay()
|
|||
if not remote.interfaces.freeplay then return end
|
||||
|
||||
storage.crashed_ship_nauvis = true
|
||||
local nauvis = game.planets[target_planet].surface
|
||||
local nauvis = game.planets[storage.target_planet].surface
|
||||
local ship_items = {
|
||||
["burner-mining-drill"] = 2,
|
||||
["stone-furnace"] = 2,
|
||||
|
|
|
|||
|
|
@ -12,16 +12,17 @@ local function build_gui(player, rocket_silo)
|
|||
position = defines.relative_gui_position.right
|
||||
}
|
||||
|
||||
local launch_button = { type = "button", name = "provisional-rocket-silo-launch-button", caption = { "lignumis.provisional-rocket-silo-button" } }
|
||||
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-nauvis"].researched
|
||||
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-nauvis" }
|
||||
launch_button.tooltip = { "lignumis.provisional-rocket-silo-button-tooltip-target" }
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ local function build_gui(player, rocket_silo)
|
|||
direction = "vertical",
|
||||
anchor = anchor,
|
||||
children = {
|
||||
{ type = "label", style = "frame_title", caption = { "lignumis.provisional-rocket-silo-button" }, ignored_by_interaction = true },
|
||||
{ type = "label", style = "frame_title", caption = { "lignumis.provisional-rocket-silo-button", target_planet_name }, ignored_by_interaction = true },
|
||||
{
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
|
|
@ -46,7 +47,7 @@ local function build_gui(player, rocket_silo)
|
|||
direction = "vertical",
|
||||
style = "inset_frame_container_vertical_flow",
|
||||
children = {
|
||||
{ type = "label", caption = { "lignumis.provisional-rocket-silo-description" } },
|
||||
{ type = "label", caption = { "lignumis.provisional-rocket-silo-description", target_planet_name } },
|
||||
launch_button
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue