forked from cacklingfiend/lignumis
		
	Improve transition to Nauvis
This commit is contained in:
		
							parent
							
								
									6fc153f3bd
								
							
						
					
					
						commit
						07df28273d
					
				
					 3 changed files with 54 additions and 19 deletions
				
			
		| 
						 | 
					@ -134,7 +134,6 @@ data.raw["string-setting"]["lignumis-second-planet"].default_value = "gleba"
 | 
				
			||||||
- Fix pipe graphics on desiccation furnace and quality assembler
 | 
					- Fix pipe graphics on desiccation furnace and quality assembler
 | 
				
			||||||
- Trees must not die when absorbing noise
 | 
					- Trees must not die when absorbing noise
 | 
				
			||||||
    - https://lua-api.factorio.com/latest/types/TreeVariation.html
 | 
					    - https://lua-api.factorio.com/latest/types/TreeVariation.html
 | 
				
			||||||
- Improve transition to Nauvis a bit more
 | 
					 | 
				
			||||||
- Add information in Factoriopedia
 | 
					- Add information in Factoriopedia
 | 
				
			||||||
- Compatibility with [On Wayward Seas](https://mods.factorio.com/mod/wayward-seas)
 | 
					- Compatibility with [On Wayward Seas](https://mods.factorio.com/mod/wayward-seas)
 | 
				
			||||||
- Compatibility with [Exotic Space Industries](https://mods.factorio.com/mod/exotic-space-industries)
 | 
					- Compatibility with [Exotic Space Industries](https://mods.factorio.com/mod/exotic-space-industries)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,7 @@ end
 | 
				
			||||||
local function teleport_player(player)
 | 
					local function teleport_player(player)
 | 
				
			||||||
    local nauvis = game.planets[storage.target_planet].surface
 | 
					    local nauvis = game.planets[storage.target_planet].surface
 | 
				
			||||||
    if player.surface.name == "lignumis" then
 | 
					    if player.surface.name == "lignumis" then
 | 
				
			||||||
        local position = nauvis.find_non_colliding_position("character", { 0, 0 }, 100, 1) or { 0, 0 }
 | 
					        local position = nauvis.find_non_colliding_position("character", { 2, 2 }, 100, 1) or { 0, 0 }
 | 
				
			||||||
        player.teleport(position, storage.target_planet)
 | 
					        player.teleport(position, storage.target_planet)
 | 
				
			||||||
        chart_starting_area(nauvis, player)
 | 
					        chart_starting_area(nauvis, player)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					@ -57,35 +57,69 @@ local function init_freeplay()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ToNauvis.events[defines.events.on_rocket_launched] = function(event)
 | 
					local function transit_player(player_index)
 | 
				
			||||||
    if not event.rocket_silo or event.rocket_silo.name ~= "provisional-rocket-silo" then return end
 | 
					    local player = game.get_player(player_index)
 | 
				
			||||||
 | 
					    local transition = storage.transitions[player_index]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local rocket_entry
 | 
					    transition.rocket_entry.cargo_pod.set_passenger(nil)
 | 
				
			||||||
    local rocket_entry_index
 | 
					    transition.rocket_entry.cargo_pod.destroy()
 | 
				
			||||||
    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 = entry.player and game.get_player(entry.player) or game.players[1]
 | 
					 | 
				
			||||||
            break
 | 
					 | 
				
			||||||
        end
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    init_nauvis()
 | 
					    init_nauvis()
 | 
				
			||||||
    teleport_player(player)
 | 
					    teleport_player(player)
 | 
				
			||||||
    init_freeplay()
 | 
					    init_freeplay()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- Give the player the content of the rocket
 | 
					    -- Give the player the content of the rocket
 | 
				
			||||||
    if rocket_entry.rocket_content then
 | 
					    if transition.rocket_entry.rocket_content then
 | 
				
			||||||
        local inventory = player.get_main_inventory()
 | 
					        local inventory = player.get_main_inventory()
 | 
				
			||||||
        for _, item in pairs(rocket_entry.rocket_content) do
 | 
					        for _, item in pairs(transition.rocket_entry.rocket_content) do
 | 
				
			||||||
            inventory.insert(item)
 | 
					            inventory.insert(item)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
        inventory.sort_and_merge()
 | 
					        inventory.sort_and_merge()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    table.remove(storage.rocket_silos, rocket_entry_index)
 | 
					    table.remove(storage.rocket_silos, transition.rocket_entry_index)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function explode_silo(silo)
 | 
				
			||||||
 | 
					    silo.die()
 | 
				
			||||||
 | 
					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 transit_tick = game.tick + (26 * 59)
 | 
				
			||||||
 | 
					    local explode_tick = game.tick + (31 * 59)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    script.on_nth_tick(explode_tick, function()
 | 
				
			||||||
 | 
					        explode_silo(event.rocket_silo)
 | 
				
			||||||
 | 
					        script.on_nth_tick(explode_tick, nil)
 | 
				
			||||||
 | 
					    end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    script.on_nth_tick(transit_tick, function()
 | 
				
			||||||
 | 
					        transit_player(player.index)
 | 
				
			||||||
 | 
					        script.on_nth_tick(transit_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
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return ToNauvis
 | 
					return ToNauvis
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,8 +92,10 @@ local function launch(event)
 | 
				
			||||||
        if entry.fake_silo == fake_silo then
 | 
					        if entry.fake_silo == fake_silo then
 | 
				
			||||||
            entry.player = event.player_index
 | 
					            entry.player = event.player_index
 | 
				
			||||||
            entry.rocket_content = rocket_content
 | 
					            entry.rocket_content = rocket_content
 | 
				
			||||||
 | 
					            entry.cargo_pod = entry.real_silo.rocket.attached_cargo_pod
 | 
				
			||||||
            fake_silo.destroy()
 | 
					            fake_silo.destroy()
 | 
				
			||||||
            entry.real_silo.launch_rocket()
 | 
					            entry.real_silo.launch_rocket()
 | 
				
			||||||
 | 
					            entry.cargo_pod.set_passenger(player)
 | 
				
			||||||
            break
 | 
					            break
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue