1
0
mirror of https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git synced 2024-12-04 09:43:00 +02:00

Renaming startup setting for enabling secondary spawns. Adding some helper commands. Fixing more migration issues.

This commit is contained in:
Oarcinae 2024-11-11 12:00:10 -05:00
parent 9b9993f25d
commit a4c4a67d32
12 changed files with 84 additions and 28 deletions

View File

@ -36,6 +36,7 @@ require("lib/sharing")
-- TODO: Possibly remove this later?
require("lib/oarc_tests")
require("lib/oarc_commands")
--------------------------------------------------------------------------------

View File

@ -158,10 +158,10 @@ OCFG = {
---@type OarcConfigGameplaySettings
gameplay = {
-- Default setting for enabling spawning on other surfaces other than the default_surface.
-- Default setting for if secondary spawns are enabled on other surfaces other than the default_surface.
-- This is a STARTUP setting, so it can't be changed in game!!
-- This is a STARTUP setting, so it can't be changed in game!!
default_allow_spawning_on_other_surfaces = false,
default_enable_secondary_spawns_on_other_surfaces = false,
-- The name of the main force.
-- This is a STARTUP setting, so it can't be changed in game!!
@ -451,7 +451,7 @@ OCFG = {
---@field discord_invite string Discord invite for easy copy paste.
---@class OarcConfigGameplaySettings
---@field default_allow_spawning_on_other_surfaces boolean Default setting for enabling spawning on other surfaces other than the default_surface. This is a STARTUP setting, so it can't be changed in game.
---@field default_enable_secondary_spawns_on_other_surfaces boolean Default setting for if secondary spawns are enabled on other surfaces other than the default_surface. This is a STARTUP setting, so it can't be changed in game.
---@field main_force_name string The name of the main force. This is a STARTUP setting, so it can't be changed in game.
---@field enable_main_team boolean Allows all players to join a primary force(team).
---@field enable_separate_teams boolean Allows players to create their own force(team).

View File

@ -16,7 +16,7 @@ OCFG_KEYS =
["gameplay_spawn_choices_SUBHEADER"] = {mod_key = "" , ocfg_keys = {""}, type = "subheader", text = {"oarc-settings-section-subheader-spawn-choices"}},
["gameplay.enable_main_team"] = {mod_key = "oarc-mod-enable-main-team" , ocfg_keys = {"gameplay", "enable_main_team"}, type = "boolean"},
["gameplay.enable_separate_teams"] = {mod_key = "oarc-mod-enable-separate-teams" , ocfg_keys = {"gameplay", "enable_separate_teams"}, type = "boolean"},
-- STARTUP ["gameplay.enable_spawning_on_other_surfaces"] = {mod_key = "oarc-mod-default-allow-spawning-on-other-surfaces" , ocfg_keys = {"gameplay", "enable_spawning_on_other_surfaces"}, type = "boolean"},
-- STARTUP ["gameplay.default_enable_secondary_spawns_on_other_surfaces"] = {mod_key = "oarc-mod-default-enable-secondary-spawns-on-other-surfaces" , ocfg_keys = {"gameplay", "default_enable_secondary_spawns_on_other_surfaces"}, type = "boolean"},
["gameplay.allow_moats_around_spawns"] = {mod_key = "oarc-mod-allow-moats-around-spawns" , ocfg_keys = {"gameplay", "allow_moats_around_spawns"}, type = "boolean"},
["gameplay.enable_moat_bridging"] = {mod_key = "oarc-mod-enable-moat-bridging" , ocfg_keys = {"gameplay", "enable_moat_bridging"}, type = "boolean"},
["gameplay.minimum_distance_to_existing_chunks"] = {mod_key = "oarc-mod-minimum-distance-to-existing-chunks" , ocfg_keys = {"gameplay", "minimum_distance_to_existing_chunks"}, type = "integer"},
@ -262,7 +262,7 @@ function CacheModSettings()
end
-- Special case for startup settings
storage.ocfg.gameplay.default_allow_spawning_on_other_surfaces = settings.startup["oarc-mod-default-allow-spawning-on-other-surfaces"].value --[[@as boolean]]
storage.ocfg.gameplay.default_enable_secondary_spawns_on_other_surfaces = settings.startup["oarc-mod-default-enable-secondary-spawns-on-other-surfaces"].value --[[@as boolean]]
storage.ocfg.gameplay.main_force_name = settings.startup["oarc-mod-main-force-name"].value --[[@as string]]
end

17
lib/oarc_commands.lua Normal file
View File

@ -0,0 +1,17 @@
-- Add a command to let people call droppods to themselves
commands.add_command("oarc-wheres-my-cargo-pod", {"oarc-command-dude-wheres-my-cargo-pod"}, function(command)
if command.player_index == nil then return end -- Ignore if it's not a player
DudeWheresMyCargoPod(game.players[command.player_index])
end)
-- Allow spawn rerolls
commands.add_command("oarc-reroll-spawn", {"oarc-command-reroll-spawn"}, function(command)
if command.player_index == nil then return end -- Ignore if it's not a player
RerollSpawn(game.players[command.player_index])
end)
-- Trigger immediate regrowth cleanups
commands.add_command("oarc-trigger-cleanup", {"oarc-command-trigger-cleanup"}, function(command)
if command.player_index ~= nil and not game.get_player(command.player_index).admin then return end -- Only admins can call this.
TriggerCleanup()
end)

View File

@ -203,7 +203,8 @@ end
---Searchs a 3x3 chunk around the map origin for "cargo-pod-container" entities and if they are on the same force
---as the player it will teleport the cargo pod to the player.
---as the player it will teleport the cargo pod to the player. This is meant to be a temporary work around since I don't
---know how to detect the cargo pod that is associated with the player or when it is sent/landed.
---@param player LuaPlayer
---@return nil
function DudeWheresMyCargoPod(player)
@ -219,17 +220,22 @@ function DudeWheresMyCargoPod(player)
local pods = surface.find_entities_filtered{area=search_area, name="cargo-pod-container", force=player.force}
if #pods == 0 then
player.print({ "oarc-no-cargo-pods" })
return
end
for _,cargo_pod in pairs(pods) do
local new_position = surface.find_non_colliding_position("cargo-pod-container", player.character.position, CHUNK_SIZE, 1)
if new_position == nil then
player.print({ "oarc-teleport-fail" })
player.print({ "oarc-teleport-cargo-pod-fail" })
return
end
cargo_pod.teleport(new_position)
player.print({ "oarc-teleport-success" })
player.print({ "oarc-teleport-cargo-pod-success" })
end
end
@ -253,6 +259,12 @@ function RerollSpawn(player)
return
end
-- If it is a buddy spawn, tell them we don't support this:
if (spawn_choices.buddy ~= nil) then
player.print({ "oarc-no-reroll-buddy-spawn" })
return
end
local surface = player.character.surface
local surface_name = surface.name
@ -291,6 +303,12 @@ function RerollSpawn(player)
-- Send them to the holding pen
SafeTeleport(player, game.surfaces[HOLDING_PEN_SURFACE_NAME], {x=0,y=0})
-- Queue joiners too!
for _,joiner in pairs(old_spawn_point.joiners) do
QueuePlayerForSpawn(joiner, delayed_spawn)
SafeTeleport(game.players[joiner], game.surfaces[HOLDING_PEN_SURFACE_NAME], {x=0,y=0})
end
-- Announce
SendBroadcastMsg({"", { "oarc-player-new-secondary", player.name, surface.name }, " ", GetGPStext(surface.name, spawn_position)})
SendBroadcastMsg({"", { "oarc-spawn-rerolled", player.name, surface.name }, " ", GetGPStext(surface.name, spawn_position)})
end

View File

@ -137,7 +137,7 @@ function SeparateSpawnsInitSurface(surface_name)
if storage.oarc_surfaces[surface_name] == nil then
-- Default surface is set to primary only, all others are secondary only if
-- default_allow_spawning_on_other_surfaces is set to true.
-- default_enable_secondary_spawns_on_other_surfaces is set to true.
if (surface_name == storage.ocfg.gameplay.default_surface) then
storage.oarc_surfaces[surface_name] = {
primary = true,
@ -146,7 +146,7 @@ function SeparateSpawnsInitSurface(surface_name)
else
storage.oarc_surfaces[surface_name] = {
primary = false,
secondary = storage.ocfg.gameplay.default_allow_spawning_on_other_surfaces
secondary = storage.ocfg.gameplay.default_enable_secondary_spawns_on_other_surfaces
}
end
end

View File

@ -2,7 +2,7 @@
oarc-mod=This is a multiplayer mod that allows every player to create their own spawn point when they join the game. There are a lot of helpful features to ensure that new players can join at anytime in the game or even join other player's spawn areas.\n\n[color=red][font=default-bold]Please check out the github page and discord for more information and support.[/font][/color]\n\n[font=default-small]This USED to be available as a scenario, but now is only provided as a mod. To start a new game with this mod, just use the default freeplay scenario. The scenario included in this mod only provides a template to overwrite the default freeplay scenario. It also provides a way for experienced server hosts to configure settings from a file instead of through the usual mod settings. Please read the control.lua file inside the scenario for notes.[/font]
[mod-setting-name]
oarc-mod-default-allow-spawning-on-other-surfaces=Default to allow spawns on other surfaces
oarc-mod-default-enable-secondary-spawns-on-other-surfaces=Enable secondary spawns by default
oarc-mod-linked-chest-size=Sharing chest capacity
oarc-mod-welcome-msg-title=Welcome message title
@ -64,7 +64,7 @@ oarc-mod-resource-placement-size-multiplier=Starting resource size multiplier
oarc-mod-resource-placement-amount-multiplier=Starting resource amount multiplier
[mod-setting-description]
oarc-mod-default-allow-spawning-on-other-surfaces=This controls the default starting setting for whether to allow spawning on other surfaces. If enabled, by default all other surfaces will be available for players to spawn on. [color=red]If you have other mods installed that add additional surfaces, I recommend leaving this disabled. Regardless of this setting, you can configure which surfaces allow spawning using the in game settings menu.[/color]
oarc-mod-default-enable-secondary-spawns-on-other-surfaces=This controls the default behavior for whether other planets/surfaces allow secondary spawns. If enabled, by default all other surfaces will generate secondary spawns when players land on them. Secondary spawns mean that every player who starts their own base, gets their own landing site on the other planets/surfaces. [color=red]If you have other mods installed that add additional surfaces, I recommend leaving this disabled. Regardless of this setting, you can configure which surfaces allow spawning using the in game settings menu.[/color]
oarc-mod-linked-chest-size=This is the size of the shared chest that players can use to share items with other players. This is only meaningful if the shared chest feature is enabled.
oarc-mod-welcome-msg-title=This is the title of the welcome message that will be displayed to players when they join the game.

View File

@ -241,7 +241,7 @@ oarc-settings-tab-description=This tab contains the same mod settings in the mod
oarc-settings-tab-text-field-enter-tooltip=[color=red]You must press ENTER after typing in a text field to save the value![/color]
oarc-settings-tab-title-surface=Enable or Disable Surface Features
oarc-settings-tab-surface-checkbox-tooltip=Enabling this will allow custom spawn areas (the main feature of this mod) on this surface. You need at least one of these enabled for the mod to work.
oarc-settings-tab-surface-secondary-checkbox-tooltip=Enabling this will give players custom secondary spawns when they first travel to this surface. [color=red]This feature is currently a work in progress.[/color]
oarc-settings-tab-surface-secondary-checkbox-tooltip=Enabling this will give players custom secondary spawns when they first travel to this surface. [color=red]This feature is currently a work in progress. If you enable this AFTER landing on a new planet, the next time you travel in a rocket you will be sent to a new spawn![/color]
oarc-settings-tab-surface-regrowth-checkbox-tooltip=Enabling this will allow the regrowth and world eater features to work on this surface, if those are enabled.
oarc-settings-tab-surface-column-header=Surface
oarc-settings-tab-surface-spawning-enabled=Home
@ -370,8 +370,9 @@ oarc-coins-available=Coins Available: __1__ [item=coin]
oarc-broke-message=You're broke! Go kill some enemies or beg for change...
oarc-character-invalid=Your character needs to be valid to use this! Make sure you are not inside a vehicle or dead!
oarc-teleport-fail=Could not find a safe place to teleport the cargo pod!
oarc-teleport-success=Teleported cargo pod to you!
oarc-teleport-cargo-pod-fail=Could not find a safe place to teleport the cargo pod near you!
oarc-teleport-cargo-pod-success=Teleported cargo pod to you!
oarc-no-cargo-pods=No cargo pods found!
oarc-cleanup-30sec-warning=Map cleanup in 30 seconds... Unused and old map chunks will be deleted!
oarc-cleanup-force-30sec-warning=Map cleanup (forced) in 30 seconds... Unused and old map chunks will be deleted!
@ -395,6 +396,11 @@ oarc-default-surface-invalid-msg=Invalid setting! Default surface does not exist
oarc-research-finished=Team __1__ has finished researching __2__!
oarc-command-dude-wheres-my-cargo-pod=This will attempt to teleport any cargo-pods from the map center to you if they are on the same force as you. This is meant to be a temporary workaround until I find a way to send cargo pods directly to a new spawn.
oarc-command-reroll-spawn=This will reroll your spawn (on whichever surface you are currently on). This is useful if you are stuck in a bad spot or want to try a different location. [color=red]Spam this at your own peril![/color]
oarc-no-reroll-buddy-spawn=I haven't implemethed spawn rerolls for buddy spawns yet! You can try leaving and rejoining the game to get a new buddy spawn.
oarc-spawn-rerolled=__1__ has rerolled their spawn point!
[entity-name]
oarc-linked-chest=OARC Linked Chest
oarc-linked-power=OARC Linked Power

View File

@ -2,7 +2,7 @@
oarc-mod=这是一个多人模组,允许每个玩家在加入游戏时创建自己的出生岛。这个模组提供了许多实用功能,确保新玩家可以随时加入游戏,甚至可以加入其他玩家的出生区域。\n\n[color=red][font=default-bold]请查看GitHub页面和Discord、群 289362487 获取更多信息和支持。[/font][/color]\n\n[font=default-small]这个模组曾经以场景的形式提供,现在仅作为模组提供。要使用此模组开始新游戏,只需使用标准模式即可。模组中包含的场景仅提供一个覆盖默认自由游戏场景的模板。它还为经验丰富的服务器老司机管理员提供了通过文件而非常规模组设置来配置设置的方法。请阅读场景中的control.lua文件以获取更多说明。[/font]
[mod-setting-name]
oarc-mod-default-allow-spawning-on-other-surfaces=默认允许在其他空间(星球)出生
oarc-mod-default-enable-secondary-spawns-on-other-surfaces=默认允许在其他空间(星球)出生
oarc-mod-linked-chest-size=共享箱子容量
oarc-mod-welcome-msg-title=欢迎消息标题
@ -64,7 +64,7 @@ oarc-mod-resource-placement-size-multiplier=起始资源大小倍数
oarc-mod-resource-placement-amount-multiplier=起始资源数量倍数
[mod-setting-description]
oarc-mod-default-allow-spawning-on-other-surfaces=这控制了是否允许在其他空间(星球)出生的默认起始设置。如果启用,默认情况下所有其他空间(星球)都将可供玩家出生。[color=red]如果您安装了添加额外空间(星球)的其他模组,我建议禁用此选项。无论此设置如何,您都可以通过游戏内设置菜单配置哪些空间(星球)允许出生。[/color]
oarc-mod-default-enable-secondary-spawns-on-other-surfaces=这控制了是否允许在其他空间(星球)出生的默认起始设置。如果启用,默认情况下所有其他空间(星球)都将可供玩家出生。[color=red]如果您安装了添加额外空间(星球)的其他模组,我建议禁用此选项。无论此设置如何,您都可以通过游戏内设置菜单配置哪些空间(星球)允许出生。[/color]
oarc-mod-linked-chest-size=这是玩家可用于与其他玩家共享物品的共享箱子大小。仅在启用共享箱子功能时有意义。
oarc-mod-welcome-msg-title=这是玩家加入游戏时将显示的欢迎消息标题。
oarc-mod-welcome-msg=这是玩家加入游戏时和信息面板中将显示的欢迎消息。[color=red]留一个空格以禁用。[/color]

View File

@ -372,8 +372,8 @@ oarc-coins-available=可用金币:__1__ [item=coin]
oarc-broke-message=你破产了!去杀些敌人或讨些零钱吧……
oarc-character-invalid=要使用此功能,您的角色必须有效!确保您不在任何载具内或处于死亡状态!
oarc-teleport-fail=找不到安全的地方来传送货舱!
oarc-teleport-success=货舱已传送到您身边!
oarc-teleport-cargo-pod-fail=找不到安全的地方来传送货舱!
oarc-teleport-cargo-pod-success=货舱已传送到您身边!
oarc-cleanup-30sec-warning=地图清理将在30秒后开始... 未使用和过期的地图区块将被删除!
oarc-cleanup-force-30sec-warning=地图强制清理将在30秒后开始... 未使用和过期的地图区块将被删除!

View File

@ -5,13 +5,15 @@ if storage.ocfg.spawn_general.force_tiles == nil then
end
-- Init OCFG surfaces for other planets if they don't exist.
if (storage.ocfg.surfaces_config["fulgora"] == nil) or
(storage.ocfg.surfaces_config["fulgora"].spawn_config.fill_tile == nil) then
storage.ocfg.surfaces_config["fulgora"] =
{
spawn_config = FULGORA_SPAWN_CONFIG,
starting_items = FULGORA_STARTER_ITEMS
}
if script.active_mods["space-age"] ~= nil then
if (storage.ocfg.surfaces_config["fulgora"] == nil) or
(storage.ocfg.surfaces_config["fulgora"].spawn_config.fill_tile == nil) then
storage.ocfg.surfaces_config["fulgora"] =
{
spawn_config = FULGORA_SPAWN_CONFIG,
starting_items = FULGORA_STARTER_ITEMS
}
end
end
-- Refresh the Nauvis config if it is missing the new settings:
@ -22,6 +24,11 @@ if storage.ocfg.surfaces_config["nauvis"].spawn_config.fill_tile == nil then
}
end
-- New startup setting that is also cached in storage.
if storage.ocfg.gameplay.default_enable_secondary_spawns_on_other_surfaces == nil then
storage.ocfg.gameplay.default_enable_secondary_spawns_on_other_surfaces = false
end
--Make sure new planets get init'd. No harm in running this multiple times.
SeparateSpawnsInitPlanets()
@ -40,4 +47,11 @@ for surface_index, spawns in pairs(storage.unique_spawns) do
spawn.generated = true
end
end
end
-- Make sure any existing players current surface is tracked
for _, player in pairs(game.players) do
if player.character then
storage.player_surfaces[player.name] = player.character.surface.name
end
end

View File

@ -1,7 +1,7 @@
data:extend({
{
type = "bool-setting",
name = "oarc-mod-default-allow-spawning-on-other-surfaces",
name = "oarc-mod-default-enable-secondary-spawns-on-other-surfaces",
setting_type = "startup",
default_value = false,
order = "a1"