mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-17 21:08:08 +02:00
Merge branch 'dev_dimentions' into develop
This commit is contained in:
commit
182a166474
@ -23,8 +23,8 @@ local function invoke(cmd)
|
||||
player_print("Unknown player.")
|
||||
return
|
||||
end
|
||||
local pos = game.surfaces[1].find_non_colliding_position("player", game.player.position, 0, 1)
|
||||
game.players[target].teleport({pos.x, pos.y})
|
||||
local pos = game.player.surface.find_non_colliding_position("player", game.player.position, 0, 1)
|
||||
game.players[target].teleport({pos.x, pos.y}, game.player.surface)
|
||||
game.print(target .. ", get your ass over here!")
|
||||
end
|
||||
|
||||
@ -38,8 +38,9 @@ local function teleport_player(cmd)
|
||||
player_print("Unknown player.")
|
||||
return
|
||||
end
|
||||
local pos = game.surfaces[1].find_non_colliding_position("player", game.players[target].position, 0, 1)
|
||||
game.player.teleport({pos.x, pos.y})
|
||||
local surface = game.players[target].surface
|
||||
local pos = surface.find_non_colliding_position("player", game.players[target].position, 0, 1)
|
||||
game.player.teleport(pos, surface)
|
||||
game.print(target .. "! watcha doin'?!")
|
||||
end
|
||||
|
||||
@ -52,8 +53,8 @@ local function teleport_location(cmd)
|
||||
player_print("Nothing selected.")
|
||||
return
|
||||
end
|
||||
local pos = game.surfaces[1].find_non_colliding_position("player", game.player.selected.position, 0, 1)
|
||||
game.player.teleport({pos.x, pos.y})
|
||||
local pos = game.player.surface.find_non_colliding_position("player", game.player.selected.position, 0, 1)
|
||||
game.player.teleport(pos)
|
||||
end
|
||||
|
||||
local function detrain(param)
|
||||
@ -137,7 +138,6 @@ local function walkabout(cmd)
|
||||
return
|
||||
end
|
||||
global.walking[player_name:lower()] = true
|
||||
local surface = game.surfaces[1]
|
||||
local distance_max = distance * 1.05
|
||||
local distance_min = distance * 0.95
|
||||
distance_max = round(distance_max, 0)
|
||||
@ -426,7 +426,7 @@ local function get_group()
|
||||
for i=2,174 do
|
||||
group.set_allows_action(i, false)
|
||||
end
|
||||
else
|
||||
else
|
||||
game.print("This would have nearly crashed the server, please consult the next best scenario dev (valansch or TWLtriston).")
|
||||
end
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ function spawn_market(cmd)
|
||||
return
|
||||
end
|
||||
local radius = 10
|
||||
local surface = game.surfaces[1]
|
||||
local surface = game.player.surface
|
||||
-- clear trees and landfill in start area
|
||||
local start_area = {left_top = {-20, -20}, right_bottom = {20, 20}}
|
||||
for _, e in pairs(surface.find_entities_filtered{area=start_area, type="tree"}) do
|
||||
@ -192,7 +192,7 @@ function pet(player, entity_name)
|
||||
end
|
||||
if not global.player_pets then global.player_pets = {} end
|
||||
|
||||
local surface = game.surfaces[1]
|
||||
local surface = game.player.surface
|
||||
|
||||
local pos = player.position
|
||||
pos.y = pos.y + 1
|
||||
@ -320,7 +320,7 @@ function fish_market_on_180_ticks()
|
||||
local player = game.players[pets.owner]
|
||||
if pcall(function () local x = pets.entity.name end) then
|
||||
if global.pet_command_rotation % 15 == 0 then
|
||||
local surface = game.surfaces[1]
|
||||
local surface = player.surface
|
||||
local pet_pos = pets.entity.position
|
||||
local pet_name = pets.entity.name
|
||||
local pet_direction = pets.entity.direction
|
||||
|
161
locale/gen_combined/dimentions.lua
Normal file
161
locale/gen_combined/dimentions.lua
Normal file
@ -0,0 +1,161 @@
|
||||
--Author: Valansch
|
||||
|
||||
local wrech_items_module = require "locale.gen_misc.wreck_items"
|
||||
|
||||
local resource_types = {"copper-ore", "iron-ore", "coal", "stone", "uranium-ore", "crude-oil"}
|
||||
|
||||
global.current_portal_index = 1
|
||||
global.portals = {}
|
||||
--Sample Portal:
|
||||
--{position : LuaPosition, source: LuaSurface, target : LuaPosition, target_surface : LuaSurface}
|
||||
|
||||
global.current_magic_chest_index = 1
|
||||
global.magic_chests = {}
|
||||
--{entity : LuaEntity, target : LuaEntity}
|
||||
|
||||
|
||||
global.last_tp = {}
|
||||
global.teleport_cooldown = 3
|
||||
global.portal_radius = 2
|
||||
|
||||
|
||||
local function get_nice_surface_name(name)
|
||||
name = name:gsub("-ore", ""):gsub("-oil", " Oil")
|
||||
return name:sub(1,1):upper() .. name:sub(2)
|
||||
end
|
||||
|
||||
--Creates autoplace_controls with only one resource type enabled
|
||||
local function create_resource_setting(resource)
|
||||
local settings = game.surfaces[1].map_gen_settings
|
||||
for _,type in pairs(resource_types) do
|
||||
settings.autoplace_controls[type] = {frequency = "none", size = "none", richness = "none"}
|
||||
end
|
||||
settings.autoplace_controls[resource] = {frequency = "normal", size = "big", richness = "good"}
|
||||
return settings
|
||||
end
|
||||
local function init()
|
||||
if not game.surfaces[2] then
|
||||
for _,type in pairs(resource_types) do
|
||||
game.create_surface(get_nice_surface_name(type), create_resource_setting(type))
|
||||
end
|
||||
local enemy_settings = create_resource_setting("enemy-base")
|
||||
enemy_settings.autoplace_controls["enemy-base"] = {frequency = "very-high", size = "very-big", richness = "very-good"}
|
||||
game.create_surface("Zerus", enemy_settings)
|
||||
game.create_surface("Nihil", create_resource_setting("copper-ore"))
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_nihil(event)
|
||||
for _,e in pairs(event.surface.find_entities_filtered{}) do
|
||||
if e.type ~= "player" then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
local tiles = {}
|
||||
for x = event.area.left_top.x, event.area.right_bottom.x do
|
||||
for y = event.area.left_top.y, event.area.right_bottom.y do
|
||||
table.insert(tiles,{name="lab-dark-1", position = {x,y}})
|
||||
end
|
||||
end
|
||||
event.surface.set_tiles(tiles)
|
||||
end
|
||||
|
||||
function run_combined_module(event)
|
||||
init()
|
||||
if event.surface.name == "Zerus" then
|
||||
wrech_items_module.on_chunk_generated(event)
|
||||
elseif event.surface.name == "Nihil" then
|
||||
generate_nihil(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function teleport_nearby_players(portal)
|
||||
for _, player_character in pairs(portal.source.find_entities_filtered{area = {{portal.position.x - global.portal_radius,portal.position.y - global.portal_radius},{portal.position.x + global.portal_radius,portal.position.y + global.portal_radius}}, name = "player", type = "player"}) do
|
||||
local player = player_character.player
|
||||
if not global.last_tp[player.name] or global.last_tp[player.name] + global.teleport_cooldown * 60 < game.tick then
|
||||
player.teleport(portal.target, portal.target_surface)
|
||||
global.last_tp[player.name] = game.tick
|
||||
player.print("Wooosh! You are now in the " .. portal.target_surface.name .. " dimention.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function teleport_players()
|
||||
local num_portals = #global.portals
|
||||
if num_portals > 0 then
|
||||
local portal = global.portals[global.current_portal_index]
|
||||
if portal.target then
|
||||
teleport_nearby_players(portal)
|
||||
end
|
||||
global.current_portal_index = (global.current_portal_index) % num_portals + 1 --Next portal
|
||||
end
|
||||
end
|
||||
|
||||
local function teleport_stuff()
|
||||
local num_chests = #global.magic_chests
|
||||
if num_chests > 0 then
|
||||
local chest = global.magic_chests[global.current_magic_chest_index]
|
||||
if chest.entity and chest.target and chest.entity.valid and chest.target.valid then
|
||||
local inv = chest.entity.get_inventory(defines.inventory.chest)
|
||||
local target_inv = chest.target.get_inventory(defines.inventory.chest)
|
||||
if inv and target_inv then
|
||||
for item, count in pairs(inv.get_contents()) do
|
||||
local n_inserted = target_inv.insert{name = item, count = count}
|
||||
if n_inserted > 0 then
|
||||
inv.remove{name = item, count = n_inserted}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
global.current_magic_chest_index = (global.current_magic_chest_index) % num_chests + 1 --Next magic chest
|
||||
end
|
||||
end
|
||||
|
||||
local function dim_on_tick(event)
|
||||
if game.tick % 2 == 0 then
|
||||
teleport_stuff()
|
||||
else
|
||||
teleport_players()
|
||||
end
|
||||
end
|
||||
|
||||
global.chest_selected = false
|
||||
local function linkchests()
|
||||
if game.player and game.player.admin and game.player.selected and (game.player.selected.type == "logistic-container" or game.player.selected.type == "container") then
|
||||
game.player.selected.destructible = false
|
||||
game.player.selected.minable = false
|
||||
if global.chest_selected then
|
||||
global.magic_chests[#global.magic_chests].target = game.player.selected
|
||||
game.print("Link established.")
|
||||
else
|
||||
table.insert(global.magic_chests, {entity = game.player.selected})
|
||||
game.print("Selected first chest.")
|
||||
end
|
||||
global.chest_selected = not global.chest_selected
|
||||
else
|
||||
game.print("failed.")
|
||||
end
|
||||
end
|
||||
|
||||
global.portal_selected = false
|
||||
local function linkportals()
|
||||
if game.player and game.player.admin then
|
||||
if global.portal_selected then
|
||||
global.portals[#global.portals].target = game.player.position
|
||||
global.portals[#global.portals].target_surface = game.player.surface
|
||||
--Way back home:
|
||||
table.insert(global.portals, {position = game.player.position, target = global.portals[#global.portals].position, source = game.player.surface, target_surface = global.portals[#global.portals].source})
|
||||
game.print("Portal link established.")
|
||||
else
|
||||
table.insert(global.portals, {position = game.player.position, source = game.player.surface})
|
||||
game.print("Selected first portal.")
|
||||
end
|
||||
global.portal_selected = not global.portal_selected
|
||||
else
|
||||
game.print("failed.")
|
||||
end
|
||||
end
|
||||
|
||||
commands.add_command("linkchests", "Select a chest to link to another. Run this command again to select the other one.", linkchests)
|
||||
commands.add_command("linkportals", "Select a portal to link to another. Run this command again to select the other one.", linkportals)
|
||||
Event.register(defines.events.on_tick, dim_on_tick)
|
@ -3,7 +3,7 @@
|
||||
-- adds some wrecked items around the map, good for MP, reduces total resources pulled from factory, and adds incentive to push out
|
||||
|
||||
wreck_item_pool = {}
|
||||
wreck_item_pool = {{name="iron-gear-wheel", count=32},{name="iron-plate", count=64},{name="rocket-control-unit", count=1},{name="rocket-fuel", count=7} ,{name="coal", count=8},{name="rocket-launcher", count=1},{name="rocket", count=32},{name="copper-cable", count=128},{name="land-mine", count=64},{name="railgun", count=1},{name="railgun-dart", count=128},{name="fast-inserter", count=8},{name="stack-filter-inserter", count=2},{name="belt-immunity-equipment", count=1},{name="fusion-reactor-equipment", count=1},{name="electric-engine-unit", count=8},{name="exoskeleton-equipment", count=1},{name="rocket-fuel", count=10},{name="used-up-uranium-fuel-cell", count=3},{name="uranium-fuel-cell", count=2},{name="power-armor", count=1},{name="modular-armor", count=1},{name="water-barrel", count=4},{name="sulfuric-acid-barrel", count=6},{name="crude-oil-barrel", count=8},{name="energy-shield-equipment", count=1},{name="explosive-rocket", count=32}}
|
||||
wreck_item_pool = {{name="iron-gear-wheel", count=32},{name="iron-plate", count=64},{name="rocket-control-unit", count=1},{name = "atomic-bomb", count = 1},{name="rocket-fuel", count=7} ,{name="coal", count=8},{name="rocket-launcher", count=1},{name="rocket", count=32},{name="copper-cable", count=128},{name="land-mine", count=64},{name="railgun", count=1},{name="railgun-dart", count=128},{name="fast-inserter", count=8},{name="stack-filter-inserter", count=2},{name="belt-immunity-equipment", count=1},{name="fusion-reactor-equipment", count=1},{name="electric-engine-unit", count=8},{name="exoskeleton-equipment", count=1},{name="rocket-fuel", count=10},{name="used-up-uranium-fuel-cell", count=3},{name="uranium-fuel-cell", count=2},{name="power-armor", count=1},{name="modular-armor", count=1},{name="water-barrel", count=4},{name="sulfuric-acid-barrel", count=6},{name="crude-oil-barrel", count=8},{name="energy-shield-equipment", count=1},{name="explosive-rocket", count=32}}
|
||||
|
||||
local function place_entities(surface, entity_list)
|
||||
local directions = {defines.direction.north, defines.direction.east, defines.direction.south, defines.direction.west}
|
||||
|
@ -10,6 +10,7 @@ in this file and your run_*type*_module(event) function will be called.
|
||||
--require "locale.gen_combined.island_resort"
|
||||
--require "locale.gen_combined.red_planet_v2"
|
||||
--require "locale.gen_combined.borg_planet_v2"
|
||||
--require "locale.gen_combined.dimentions"
|
||||
|
||||
--grilledham's maps
|
||||
--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.mobius_strip"
|
||||
|
@ -29,20 +29,37 @@ local function on_player_deconstructed_area(event)
|
||||
end
|
||||
end
|
||||
|
||||
local init = true
|
||||
local function log_on_player_mined_entity(str, event)
|
||||
game.write_file("on_player_mined_entity_debug", game.tick .. " (" .. game.players[event.player_index].name .. ") " .. str .. "\n", true, 0)
|
||||
end
|
||||
|
||||
global.on_player_mined_item_enabled = true
|
||||
global.on_player_mined_item_init = true
|
||||
|
||||
local function on_player_mined_item(event)
|
||||
if init then
|
||||
game.forces.enemy.research_all_technologies() --avoids losing logstics slot configuration on force toggle
|
||||
init = false
|
||||
end
|
||||
if event.entity.force.name ~= "enemy" and event.entity.force.name ~= "neutral" and event.entity.name ~= "entity-ghost" then
|
||||
local entity_name = event.entity.name
|
||||
if entity_name == "pipe-to-ground" then entity_name = "pipe" end
|
||||
local ghost = game.surfaces[1].create_entity{name = "entity-ghost", position = event.entity.position, inner_name = entity_name, expires = false, force = "enemy", direction = event.entity.direction}
|
||||
ghost.last_user = event.player_index
|
||||
log_on_player_mined_entity("nuke_control.on_player_mined_item: entry", event)
|
||||
if global.on_player_mined_item_enabled then
|
||||
log_on_player_mined_entity("nuke_control.on_player_mined_item: enabled", event)
|
||||
if global.on_player_mined_item_init then
|
||||
log_on_player_mined_entity("nuke_control.on_player_mined_item: init", event)
|
||||
game.forces.enemy.research_all_technologies() --avoids losing logstics slot configuration on force toggle
|
||||
global.on_player_mined_item_init = false
|
||||
end
|
||||
local entity = event.entity
|
||||
if entity.force.name ~= "enemy" and entity.force.name ~= "neutral" and entity.name ~= "entity-ghost" and entity.type ~= "logistic-robot" and entity.type ~= "construction-robot" then
|
||||
log_on_player_mined_entity("nuke_control.on_player_mined_item: in body", event)
|
||||
local entity_name = entity.name
|
||||
if entity_name == "pipe-to-ground" then entity_name = "pipe" end
|
||||
log_on_player_mined_entity("nuke_control.on_player_mined_item: before ghost placement", event)
|
||||
local ghost = event.entity.surface.create_entity{name = "entity-ghost", position = event.entity.position, inner_name = entity_name, expires = false, force = "enemy", direction = event.entity.direction}
|
||||
log_on_player_mined_entity("nuke_control.on_player_mined_item: ghost placed", event)
|
||||
ghost.last_user = event.player_index
|
||||
log_on_player_mined_entity("nuke_control.on_player_mined_item: last user set", event)
|
||||
end
|
||||
end
|
||||
log_on_player_mined_entity("nuke_control.on_player_mined_item: exit", event)
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_player_ammo_inventory_changed, ammo_changed)
|
||||
Event.register(defines.events.on_player_deconstructed_area, on_player_deconstructed_area)
|
||||
--Event.register(defines.events.on_player_mined_entity, on_player_mined_item)
|
||||
Event.register(defines.events.on_player_mined_entity, on_player_mined_item)
|
||||
|
@ -399,12 +399,23 @@ function player_list_on_12_seconds()
|
||||
end
|
||||
end
|
||||
|
||||
local function player_list_on_player_died( event_player, cause )
|
||||
player = game.players[event_player.player_index]
|
||||
local function log_on_player_died_debug(str, event)
|
||||
local cause = event.cause or {name = "no cause"}
|
||||
game.write_file("on_player_died_debug", game.tick .. " (" .. game.players[event.player_index].name .. ", cause: " .. cause.name .. ") " .. str .. "\n", true, 0)
|
||||
end
|
||||
|
||||
local function player_list_on_player_died(event)
|
||||
log_on_player_died_debug("entry", event)
|
||||
local player = game.players[event.player_index]
|
||||
log_on_player_died_debug("player", event)
|
||||
if not global.scenario.variables.player_deaths[player.name] then
|
||||
log_on_player_died_debug("if", event)
|
||||
global.scenario.variables.player_deaths[player.name] = 0
|
||||
log_on_player_died_debug("deaths zero", event)
|
||||
end
|
||||
log_on_player_died_debug("deaths ++", event)
|
||||
global.scenario.variables.player_deaths[player.name] = global.scenario.variables.player_deaths[player.name] + 1
|
||||
log_on_player_died_debug("exit", event)
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user