forked from cacklingfiend/lignumis
		
	Add ready rocket silo with custom GUI
This commit is contained in:
		
							parent
							
								
									0a795f5668
								
							
						
					
					
						commit
						51a61cd2e0
					
				
					 11 changed files with 441 additions and 98 deletions
				
			
		
							
								
								
									
										26
									
								
								lignumis/_migrations/lignumis-0.9.9.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								lignumis/_migrations/lignumis-0.9.9.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
local RocketSilo = require("scripts/wooden-rocket-silo")
 | 
			
		||||
 | 
			
		||||
if not storage.rocket_silos then
 | 
			
		||||
    storage.rocket_silos = {}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if not game.planets["lignumis"] then return end
 | 
			
		||||
 | 
			
		||||
local lignumis = game.planets["lignumis"].surface
 | 
			
		||||
 | 
			
		||||
for _, silo in pairs(lignumis.find_entities_filtered { name = "provisional-rocket-silo" }) do
 | 
			
		||||
    local found = false
 | 
			
		||||
    for _, entry in pairs(storage.rocket_silos) do
 | 
			
		||||
        if entry.real_silo == silo then
 | 
			
		||||
            found = true
 | 
			
		||||
            break
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    if not found then
 | 
			
		||||
        RocketSilo.events[defines.events.on_script_trigger_effect]({
 | 
			
		||||
            effect_id = "provisional-rocket-ready",
 | 
			
		||||
            surface_index = lignumis.index,
 | 
			
		||||
            cause_entity = silo
 | 
			
		||||
        })
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -1,10 +1,12 @@
 | 
			
		|||
local handler = require("event_handler")
 | 
			
		||||
gui = require("__flib__/gui")
 | 
			
		||||
 | 
			
		||||
handler.add_libraries({
 | 
			
		||||
    require("script/init-existing"),
 | 
			
		||||
    require("script/init-new"),
 | 
			
		||||
    require("script/init"),
 | 
			
		||||
    require("script/to-nauvis")
 | 
			
		||||
    require("scripts/init-existing"),
 | 
			
		||||
    require("scripts/init-new"),
 | 
			
		||||
    require("scripts/init"),
 | 
			
		||||
    require("scripts/to-nauvis"),
 | 
			
		||||
    require("scripts/wooden-rocket-silo")
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,7 @@
 | 
			
		|||
    "dependencies": [
 | 
			
		||||
        "base",
 | 
			
		||||
        "space-age >= 2.0.28",
 | 
			
		||||
        "flib",
 | 
			
		||||
        "PlanetsLib >= 1.1.26",
 | 
			
		||||
        "astroponics >= 1.2.0",
 | 
			
		||||
        "cf-lib >= 0.0.2",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,6 +31,7 @@ gold-storage-tank=Gold storage tank
 | 
			
		|||
desiccation-furnace=Desiccation furnace
 | 
			
		||||
steam-assembling-machine=Steam assembling machine
 | 
			
		||||
provisional-rocket-silo=Provisional rocket silo
 | 
			
		||||
provisional-rocket-silo-ready=Provisional rocket silo (ready)
 | 
			
		||||
basic-gun-turret=Basic gun turret
 | 
			
		||||
basic-construction-robot-gold=Basic construction robot (gold)
 | 
			
		||||
basic-construction-robot-copper=Basic construction robot (copper)
 | 
			
		||||
| 
						 | 
				
			
			@ -167,3 +168,6 @@ quality-catalyst=Quality catalyst
 | 
			
		|||
 | 
			
		||||
[lignumis]
 | 
			
		||||
start-new-game=Lignumis is meant to be played in a fresh game as it extends the early game before Nauvis.
 | 
			
		||||
provisional-rocket-silo-button=Escape to Nauvis
 | 
			
		||||
provisional-rocket-silo-button-tooltip=Your personal inventory must be empty!
 | 
			
		||||
provisional-rocket-silo-description=Fill the rocket inventory and launch the rocket to escape to Nauvis.\nBe sure to take material to jumpstart your iron, copper and wood production.
 | 
			
		||||
| 
						 | 
				
			
			@ -32,10 +32,6 @@ data:extend({
 | 
			
		|||
                space_location = "nauvis",
 | 
			
		||||
                use_icon_overlay_constant = true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                type = "unlock-recipe",
 | 
			
		||||
                recipe = "destination-nauvis"
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                type = "unlock-space-platforms",
 | 
			
		||||
                modifier = true,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ local silo = table.deepcopy(data.raw["rocket-silo"]["rocket-silo"])
 | 
			
		|||
silo.name = "provisional-rocket-silo"
 | 
			
		||||
silo.icon = "__lignumis__/graphics/icons/provisional-rocket-silo.png"
 | 
			
		||||
silo.module_slots = 0
 | 
			
		||||
silo.allowed_effects = { "consumption", "pollution" }
 | 
			
		||||
silo.allowed_effects = { "consumption", "pollution", "speed" }
 | 
			
		||||
silo.minable = { mining_time = 1, result = "provisional-rocket-silo" }
 | 
			
		||||
silo.max_health = 1000
 | 
			
		||||
silo.energy_source = {
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ silo.emissions_per_second = { noise = 1000 / 60 }
 | 
			
		|||
silo.energy_usage = "1MW"
 | 
			
		||||
silo.rocket_entity = "provisional-rocket"
 | 
			
		||||
silo.fixed_recipe = "provisional-rocket-part"
 | 
			
		||||
silo.door_opening_speed = 1 / (20 * 60)
 | 
			
		||||
--silo.door_opening_speed = 1 / (20 * 60)
 | 
			
		||||
silo.base_day_sprite.filename = "__lignumis__/graphics/entity/wooden-rocket-silo/06-rocket-silo.png"
 | 
			
		||||
silo.base_front_sprite.filename = "__lignumis__/graphics/entity/wooden-rocket-silo/14-rocket-silo-front.png"
 | 
			
		||||
silo.fluid_boxes = {
 | 
			
		||||
| 
						 | 
				
			
			@ -45,8 +45,13 @@ silo.fluid_boxes = {
 | 
			
		|||
}
 | 
			
		||||
silo.fluid_boxes_off_when_no_fluid_recipe = true
 | 
			
		||||
silo.launch_to_space_platforms = false
 | 
			
		||||
silo.rocket_parts_storage_cap = 50
 | 
			
		||||
silo.to_be_inserted_to_rocket_inventory_size = 20
 | 
			
		||||
silo.rocket_parts_required = 1
 | 
			
		||||
silo.rocket_parts_storage_cap = 1
 | 
			
		||||
silo.to_be_inserted_to_rocket_inventory_size = 1
 | 
			
		||||
silo.clamps_on_trigger = {
 | 
			
		||||
    type = "script",
 | 
			
		||||
    effect_id = "provisional-rocket-ready"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local silo_item = table.deepcopy(data.raw["item"]["rocket-silo"])
 | 
			
		||||
silo_item.name = "provisional-rocket-silo"
 | 
			
		||||
| 
						 | 
				
			
			@ -67,10 +72,11 @@ silo_recipe.ingredients = {
 | 
			
		|||
 | 
			
		||||
local rocket = table.deepcopy(data.raw["rocket-silo-rocket"]["rocket-silo-rocket"])
 | 
			
		||||
rocket.name = "provisional-rocket"
 | 
			
		||||
rocket.rising_speed = 1 / (14 * 60)
 | 
			
		||||
rocket.engine_starting_speed = 1 / (11 * 60)
 | 
			
		||||
rocket.flying_speed = 1 / (4000 * 60)
 | 
			
		||||
rocket.flying_acceleration = 0.005
 | 
			
		||||
rocket.inventory_size = 40
 | 
			
		||||
--rocket.rising_speed = 1 / (14 * 60)
 | 
			
		||||
--rocket.engine_starting_speed = 1 / (11 * 60)
 | 
			
		||||
--rocket.flying_speed = 1 / (4000 * 60)
 | 
			
		||||
--rocket.flying_acceleration = 0.005
 | 
			
		||||
rocket.rocket_sprite.layers[1].filename = "__lignumis__/graphics/entity/wooden-rocket-silo/rocket-static-pod.png"
 | 
			
		||||
 | 
			
		||||
local rocket_part_recipe = {
 | 
			
		||||
| 
						 | 
				
			
			@ -92,28 +98,198 @@ local rocket_part_recipe = {
 | 
			
		|||
    allow_productivity = true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local nauvis_item = {
 | 
			
		||||
    type = "item",
 | 
			
		||||
    name = "destination-nauvis",
 | 
			
		||||
    icon = "__base__/graphics/icons/nauvis.png",
 | 
			
		||||
    subgroup = "space-related",
 | 
			
		||||
    order = "z[destination-nauvis]",
 | 
			
		||||
    inventory_move_sound = item_sounds.mechanical_inventory_move,
 | 
			
		||||
    pick_sound = item_sounds.mechanical_inventory_pickup,
 | 
			
		||||
    drop_sound = item_sounds.mechanical_inventory_move,
 | 
			
		||||
    stack_size = 1,
 | 
			
		||||
    weight = 1 * tons,
 | 
			
		||||
    send_to_orbit_mode = "automated",
 | 
			
		||||
    spoil_ticks = 60 * 60 * 10
 | 
			
		||||
local silo_ready = {
 | 
			
		||||
    type = "container",
 | 
			
		||||
    name = "provisional-rocket-silo-ready",
 | 
			
		||||
    icon = silo.icon,
 | 
			
		||||
    minable = { mining_time = 1, result = nil },
 | 
			
		||||
    deconstruction_alternative = "provisional-rocket-silo",
 | 
			
		||||
    inventory_size = 40,
 | 
			
		||||
    inventory_type = "normal",
 | 
			
		||||
    quality_affects_inventory_size = false,
 | 
			
		||||
    placeable_by = { item = "provisional-rocket-silo", count = 1 },
 | 
			
		||||
    health = 1000,
 | 
			
		||||
    surface_conditions = {
 | 
			
		||||
        {
 | 
			
		||||
            property = "pressure",
 | 
			
		||||
            min = 1
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    flags = { "not-on-map", "not-blueprintable", "not-deconstructable", "not-flammable", "not-repairable", "not-upgradable", "no-automated-item-insertion", "no-automated-item-removal", "not-in-kill-statistics" },
 | 
			
		||||
    allow_copy_paste = false,
 | 
			
		||||
    additional_pastable_entities = { "provisional-rocket-silo" },
 | 
			
		||||
    --picture = {
 | 
			
		||||
    --    layers = {
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/01-rocket-silo-hole.png",
 | 
			
		||||
    --            width = 400,
 | 
			
		||||
    --            height = 270,
 | 
			
		||||
    --            shift = util.by_pixel(-5, 16),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/00-rocket-silo-shadow.png",
 | 
			
		||||
    --            priority = "medium",
 | 
			
		||||
    --            width = 612,
 | 
			
		||||
    --            height = 578,
 | 
			
		||||
    --            draw_as_shadow = true,
 | 
			
		||||
    --            dice = 2,
 | 
			
		||||
    --            shift = util.by_pixel(7, 2),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        --{
 | 
			
		||||
    --        --    filename = "__base__/graphics/entity/rocket-silo/04-door-back.png",
 | 
			
		||||
    --        --    width = 312,
 | 
			
		||||
    --        --    height = 286,
 | 
			
		||||
    --        --    shift = util.by_pixel(37, 12),
 | 
			
		||||
    --        --    scale = 0.5
 | 
			
		||||
    --        --},
 | 
			
		||||
    --        --{
 | 
			
		||||
    --        --    filename = "__base__/graphics/entity/rocket-silo/05-door-front.png",
 | 
			
		||||
    --        --    width = 332,
 | 
			
		||||
    --        --    height = 300,
 | 
			
		||||
    --        --    shift = util.by_pixel(-28, 33),
 | 
			
		||||
    --        --    scale = 0.5
 | 
			
		||||
    --        --},
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__lignumis__/graphics/entity/wooden-rocket-silo/06-rocket-silo.png",
 | 
			
		||||
    --            dice_y = 3,
 | 
			
		||||
    --            width = 608,
 | 
			
		||||
    --            height = 596,
 | 
			
		||||
    --            shift = util.by_pixel(3, -1),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/07-red-lights-back/red-light.png",
 | 
			
		||||
    --            width = 32,
 | 
			
		||||
    --            height = 32,
 | 
			
		||||
    --            shift = { 1.34375, 0.28125 - 1.375 },
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/07-red-lights-back/red-light.png",
 | 
			
		||||
    --            width = 32,
 | 
			
		||||
    --            height = 32,
 | 
			
		||||
    --            shift = { 2.3125, 0.9375 - 1.375 },
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/07-red-lights-back/red-light.png",
 | 
			
		||||
    --            width = 32,
 | 
			
		||||
    --            height = 32,
 | 
			
		||||
    --            shift = { 2.65625, 1.90625 - 1.375 },
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/07-red-lights-back/red-light.png",
 | 
			
		||||
    --            width = 32,
 | 
			
		||||
    --            height = 32,
 | 
			
		||||
    --            shift = { -2.65625, 1.90625 - 1.375 },
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/07-red-lights-back/red-light.png",
 | 
			
		||||
    --            width = 32,
 | 
			
		||||
    --            height = 32,
 | 
			
		||||
    --            shift = { -2.3125, 0.9375 - 1.375 },
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/07-red-lights-back/red-light.png",
 | 
			
		||||
    --            width = 32,
 | 
			
		||||
    --            height = 32,
 | 
			
		||||
    --            shift = { -1.34375, 0.28125 - 1.375 },
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/07-red-lights-back/red-light.png",
 | 
			
		||||
    --            width = 32,
 | 
			
		||||
    --            height = 32,
 | 
			
		||||
    --            shift = { 0, 0 - 1.375 },
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/08-rocket-silo-arms-back.png",
 | 
			
		||||
    --            priority = "medium",
 | 
			
		||||
    --            width = 128,
 | 
			
		||||
    --            height = 150,
 | 
			
		||||
    --            x = 3968,
 | 
			
		||||
    --            animation_speed = 0.3,
 | 
			
		||||
    --            shift = util.by_pixel(-53, -84),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/08-rocket-silo-arms-right.png",
 | 
			
		||||
    --            priority = "medium",
 | 
			
		||||
    --            width = 182,
 | 
			
		||||
    --            height = 188,
 | 
			
		||||
    --            x = 5642,
 | 
			
		||||
    --            animation_speed = 0.3,
 | 
			
		||||
    --            shift = util.by_pixel(101, -38),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/rocket-static-pod-shadow.png",
 | 
			
		||||
    --            priority = "medium",
 | 
			
		||||
    --            width = 738,
 | 
			
		||||
    --            height = 214,
 | 
			
		||||
    --            shift = util.by_pixel(160.5, 23.5),
 | 
			
		||||
    --            draw_as_shadow = true,
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__lignumis__/graphics/entity/wooden-rocket-silo/rocket-static-pod.png",
 | 
			
		||||
    --            priority = "medium",
 | 
			
		||||
    --            width = 308,
 | 
			
		||||
    --            height = 602,
 | 
			
		||||
    --            shift = util.by_pixel(-4, -41.25),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/rocket-static-emission.png",
 | 
			
		||||
    --            width = 306,
 | 
			
		||||
    --            height = 518,
 | 
			
		||||
    --            shift = util.by_pixel(-4, -4.25),
 | 
			
		||||
    --            draw_as_glow = true,
 | 
			
		||||
    --            blend_mode = "additive",
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/03-rocket-over-shadow-over-rocket.png",
 | 
			
		||||
    --            width = 426,
 | 
			
		||||
    --            height = 288,
 | 
			
		||||
    --            shift = util.by_pixel(-2, 21),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__lignumis__/graphics/entity/wooden-rocket-silo/14-rocket-silo-front.png",
 | 
			
		||||
    --            width = 580,
 | 
			
		||||
    --            height = 262,
 | 
			
		||||
    --            shift = util.by_pixel(-1, 78),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        },
 | 
			
		||||
    --        {
 | 
			
		||||
    --            filename = "__base__/graphics/entity/rocket-silo/13-rocket-silo-arms-front.png",
 | 
			
		||||
    --            priority = "medium",
 | 
			
		||||
    --            width = 126,
 | 
			
		||||
    --            height = 228,
 | 
			
		||||
    --            x = 3906,
 | 
			
		||||
    --            animation_speed = 0.3,
 | 
			
		||||
    --            shift = util.by_pixel(-51, 16),
 | 
			
		||||
    --            scale = 0.5
 | 
			
		||||
    --        }
 | 
			
		||||
    --    }
 | 
			
		||||
    --},
 | 
			
		||||
    collision_mask = { layers = {} },
 | 
			
		||||
    collision_box = table.deepcopy(silo.collision_box),
 | 
			
		||||
    selection_box = table.deepcopy(silo.selection_box),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local nauvis_recipe = {
 | 
			
		||||
    type = "recipe",
 | 
			
		||||
    name = "destination-nauvis",
 | 
			
		||||
    enabled = false,
 | 
			
		||||
    ingredients = {},
 | 
			
		||||
    results = { { type = "item", name = "destination-nauvis", amount = 1 } }
 | 
			
		||||
}
 | 
			
		||||
local silo_ready_item = table.deepcopy(data.raw["item"]["rocket-silo"])
 | 
			
		||||
silo_ready_item.name = "provisional-rocket-silo-ready"
 | 
			
		||||
silo_ready_item.order = "0[provisional-rocket-silo-ready]"
 | 
			
		||||
silo_ready_item.place_result = "provisional-rocket-silo-ready"
 | 
			
		||||
silo_ready_item.icon = "__lignumis__/graphics/icons/provisional-rocket-silo.png"
 | 
			
		||||
 | 
			
		||||
data:extend({
 | 
			
		||||
    silo,
 | 
			
		||||
| 
						 | 
				
			
			@ -121,6 +297,6 @@ data:extend({
 | 
			
		|||
    silo_recipe,
 | 
			
		||||
    rocket,
 | 
			
		||||
    rocket_part_recipe,
 | 
			
		||||
    nauvis_item,
 | 
			
		||||
    nauvis_recipe
 | 
			
		||||
    silo_ready,
 | 
			
		||||
    silo_ready_item
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,9 +4,7 @@ local InitExisting = {}
 | 
			
		|||
-- Don't send players to Lignumis but instead print a warning
 | 
			
		||||
 | 
			
		||||
InitExisting.on_init = function()
 | 
			
		||||
    if game.tick == 0 then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    if game.tick == 0 then return end
 | 
			
		||||
 | 
			
		||||
    storage.init = {}
 | 
			
		||||
    for _, player in pairs(game.players) do
 | 
			
		||||
| 
						 | 
				
			
			@ -6,9 +6,7 @@ local InitNew = {}
 | 
			
		|||
 | 
			
		||||
-- Initialize the freeplay intro
 | 
			
		||||
local function init_intro()
 | 
			
		||||
    if not remote.interfaces.freeplay then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    if not remote.interfaces.freeplay then return end
 | 
			
		||||
 | 
			
		||||
    -- Disable Nauvis intro
 | 
			
		||||
    remote.call("freeplay", "set_disable_crashsite", true)
 | 
			
		||||
| 
						 | 
				
			
			@ -63,9 +61,7 @@ end
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
InitNew.on_init = function()
 | 
			
		||||
    if game.tick > 0 then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    if game.tick > 0 then return end
 | 
			
		||||
 | 
			
		||||
    init_intro()
 | 
			
		||||
    init_space_locations()
 | 
			
		||||
| 
						 | 
				
			
			@ -23,9 +23,7 @@ end
 | 
			
		|||
local function init_player(event)
 | 
			
		||||
    local player = game.get_player(event.player_index)
 | 
			
		||||
 | 
			
		||||
    if not player.character then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    if not player.character then return end
 | 
			
		||||
 | 
			
		||||
    local surface = storage.surface or game.planets["lignumis"].surface
 | 
			
		||||
    player.teleport(surface.find_non_colliding_position("character", { 0, 0 }, 0, 1), "lignumis")
 | 
			
		||||
| 
						 | 
				
			
			@ -41,9 +39,7 @@ end
 | 
			
		|||
local function init_freeplay(event)
 | 
			
		||||
    local player = game.get_player(event.player_index)
 | 
			
		||||
 | 
			
		||||
    if not player or not remote.interfaces.freeplay then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    if not player or not remote.interfaces.freeplay then return end
 | 
			
		||||
 | 
			
		||||
    local surface = storage.surface or game.planets["lignumis"].surface
 | 
			
		||||
    storage.crashed_ship_items = remote.call("freeplay", "get_ship_items")
 | 
			
		||||
| 
						 | 
				
			
			@ -75,9 +71,7 @@ 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
 | 
			
		||||
    if storage.init[event.player_index] then return end
 | 
			
		||||
 | 
			
		||||
    storage.init[event.player_index] = true
 | 
			
		||||
    init_player(event)
 | 
			
		||||
| 
						 | 
				
			
			@ -96,19 +90,13 @@ 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
 | 
			
		||||
    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
 | 
			
		||||
    if storage.skip_intro then return end
 | 
			
		||||
 | 
			
		||||
    local intro_message = storage.custom_intro_message or { "msg-intro-space-age" }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -122,12 +110,9 @@ 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
 | 
			
		||||
    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()
 | 
			
		||||
| 
						 | 
				
			
			@ -135,12 +120,9 @@ Init.events["crash-site-skip-cutscene"] = function(event)
 | 
			
		|||
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
 | 
			
		||||
    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
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
local crash_site = require("crash-site")
 | 
			
		||||
local util = require("util")
 | 
			
		||||
 | 
			
		||||
-- Transition from Lignumis to Nauvis with the provisional rocket silo
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +18,7 @@ end
 | 
			
		|||
 | 
			
		||||
-- Initialize Nauvis
 | 
			
		||||
local function init_nauvis()
 | 
			
		||||
    if storage.nauvis_visited then return end
 | 
			
		||||
    local nauvis = game.planets["nauvis"].create_surface()
 | 
			
		||||
    nauvis.request_to_generate_chunks({ 0, 0 }, 3)
 | 
			
		||||
    nauvis.force_generate_chunk_requests()
 | 
			
		||||
| 
						 | 
				
			
			@ -26,32 +26,28 @@ local function init_nauvis()
 | 
			
		|||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Teleport all players to Nauvis and show welcoe message
 | 
			
		||||
local function teleport_players()
 | 
			
		||||
-- Teleport player to Nauvis and show welcome message
 | 
			
		||||
local function teleport_player(player)
 | 
			
		||||
    local nauvis = game.planets["nauvis"].surface
 | 
			
		||||
    for _, player in pairs(game.players) do
 | 
			
		||||
    if player.surface.name == "lignumis" then
 | 
			
		||||
        player.teleport(nauvis.find_non_colliding_position("character", { 0, 0 }, 0, 1), "nauvis")
 | 
			
		||||
        chart_starting_area(nauvis, player)
 | 
			
		||||
        player.print("Oh no, not again. But... Welcome to Nauvis!")
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Initialize the Nauvis freeplay scenario
 | 
			
		||||
local function init_freeplay()
 | 
			
		||||
    if not remote.interfaces.freeplay then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    if not remote.interfaces.freeplay then return end
 | 
			
		||||
 | 
			
		||||
    local nauvis = game.planets["nauvis"].surface
 | 
			
		||||
    local ship_items = {
 | 
			
		||||
        ["burner-mining-drill"] = 5,
 | 
			
		||||
        ["stone-furnace"] = 5,
 | 
			
		||||
        ["burner-mining-drill"] = 2,
 | 
			
		||||
        ["stone-furnace"] = 2,
 | 
			
		||||
        ["burner-assembling-machine"] = 2,
 | 
			
		||||
        ["burner-agricultural-tower"] = 4,
 | 
			
		||||
        ["wood-lab"] = 4
 | 
			
		||||
        ["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")
 | 
			
		||||
| 
						 | 
				
			
			@ -61,13 +57,32 @@ end
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
ToNauvis.events[defines.events.on_rocket_launched] = function(event)
 | 
			
		||||
    if not event.rocket_silo.name == "provisional-rocket-silo" then
 | 
			
		||||
        return
 | 
			
		||||
    if not event.rocket_silo.name == "provisional-rocket-silo" then return end
 | 
			
		||||
 | 
			
		||||
    local rocket_entry
 | 
			
		||||
    local rocket_entry_index
 | 
			
		||||
    local player
 | 
			
		||||
 | 
			
		||||
    for i, entry in pairs(storage.rocket_silos) do
 | 
			
		||||
        if entry.real_silo == event.rocket_silo then
 | 
			
		||||
            rocket_entry = entry
 | 
			
		||||
            rocket_entry_index = i
 | 
			
		||||
            player = game.get_player(entry.player)
 | 
			
		||||
            break
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    init_nauvis()
 | 
			
		||||
    teleport_players()
 | 
			
		||||
    teleport_player(player)
 | 
			
		||||
    init_freeplay()
 | 
			
		||||
 | 
			
		||||
    -- Give the player the content of the rocket
 | 
			
		||||
    local inventory = player.get_main_inventory()
 | 
			
		||||
    for _, item in pairs(rocket_entry.rocket_content) do
 | 
			
		||||
        inventory.insert(item)
 | 
			
		||||
    end
 | 
			
		||||
    inventory.sort_and_merge()
 | 
			
		||||
    table.remove(storage.rocket_silos, rocket_entry_index)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return ToNauvis
 | 
			
		||||
							
								
								
									
										147
									
								
								lignumis/scripts/wooden-rocket-silo.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								lignumis/scripts/wooden-rocket-silo.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,147 @@
 | 
			
		|||
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 launch_button = { type = "button", name = "provisional-rocket-silo-launch-button", caption = { "lignumis.provisional-rocket-silo-button" } }
 | 
			
		||||
 | 
			
		||||
    local inventory = player.get_main_inventory()
 | 
			
		||||
    launch_button.enabled = inventory.is_empty()
 | 
			
		||||
    if not launch_button.enabled then
 | 
			
		||||
        launch_button.tooltip = { "lignumis.provisional-rocket-silo-button-tooltip" }
 | 
			
		||||
    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" }, 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" } },
 | 
			
		||||
                                    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
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
            fake_silo.destroy()
 | 
			
		||||
            entry.real_silo.launch_rocket()
 | 
			
		||||
            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
 | 
			
		||||
            player.mine_entity(entry.real_silo, true)
 | 
			
		||||
            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