Skip to content

Commit

Permalink
Merge pull request #275 from Oarcinae/dev_2.1.14
Browse files Browse the repository at this point in the history
Dev 2.1.14
  • Loading branch information
Oarcinae authored Nov 22, 2024
2 parents 3e35474 + f453597 commit 032d173
Show file tree
Hide file tree
Showing 16 changed files with 227 additions and 140 deletions.
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
---------------------------------------------------------------------------------------------------
Version: 2.1.14
Date: 2024-11-21
Info:
- Update CN locale. (Thanks plexpt!)
- Many non-localized planet names localized and started using the icons where possible too.
- Make use of new set_driving() function. Won't affect gameplay, but I no longer have to do an extra teleport as a workaround.
- Add mod compatibility for "Better Chatting" mod. (Thanks PennyJim!)
---------------------------------------------------------------------------------------------------
Version: 2.1.13
Date: 2024-11-20
Major Features:
Expand Down
18 changes: 9 additions & 9 deletions control.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- Sep 2024
-- ____ _____ _____
-- ____ _____ _____
-- / __ \ /\ | __ \ / ____|
-- | | | | / \ | |__) | |
-- | | | |/ /\ \ | _ /| |
-- | |__| / ____ \| | \ \| |____
-- | | | | / \ | |__) | |
-- | | | |/ /\ \ | _ /| |
-- | |__| / ____ \| | \ \| |____
-- \____/_/ \_\_| \_\\_____|

-- Oarc's Separated Spawn MOD V2
Expand Down Expand Up @@ -150,7 +150,7 @@ end)
script.on_event(defines.events.on_research_finished, function(event)
local research = event.research
-- TODO: Add a non-mod setting to disable this.
SendBroadcastMsg({"oarc-research-finished", research.force.name, research.localised_name})
SendBroadcastMsg({"oarc-research-finished", research.force.name, research.name})
end)

----------------------------------------
Expand Down Expand Up @@ -192,7 +192,7 @@ end)
---@field new_surface_name string
script.on_event("oarc-mod-character-surface-changed", function(event)
log("EVENT - oarc-mod-character-surface-changed:" .. serpent.block(event --[[@as OarcModCharacterSurfaceChangedEvent]]))

--This is just here so I don't get lua warnings about unused variables.
---@type OarcModCharacterSurfaceChangedEvent
local custom_event = event --[[@as OarcModCharacterSurfaceChangedEvent]]
Expand Down Expand Up @@ -250,7 +250,7 @@ script.on_event(defines.events.on_chunk_generated, function(event)
if storage.ocfg.regrowth.enable_regrowth then
RegrowthChunkGenerate(event)
end

CreateHoldingPenChunks(event)

if storage.ocfg.gameplay.modified_enemy_spawning then
Expand All @@ -264,7 +264,7 @@ end)
----------------------------------------
-- Radar Scanning
----------------------------------------
script.on_event(defines.events.on_sector_scanned, function (event)
script.on_event(defines.events.on_sector_scanned, function (event)
if storage.ocfg.regrowth.enable_regrowth then
RegrowthSectorScan(event)
end
Expand Down Expand Up @@ -455,4 +455,4 @@ local oarc_mod_interface =
end
}

remote.add_interface("oarc_mod", oarc_mod_interface)
remote.add_interface("oarc_mod", oarc_mod_interface)
5 changes: 3 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "oarc-mod",
"version": "2.1.13",
"version": "2.1.14",
"factorio_version": "2.0",
"title": "Oarc Multiplayer Spawn",
"author": "Oarcinae",
"contact": "Mod Discussion Page, [email protected], Discord:oarc",
"homepage": "https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn",
"description": "[[Description is in locale file!]]",
"dependencies": [
"base >= 2.0.0",
"base >= 2.0.17",
"? space-age",
"(?) dangOreus" ,
"(?) Milestones",
Expand All @@ -18,6 +18,7 @@
"(?) helmod",
"(?) blueprint-sandboxes",
"(?) factorissimo-2-notnotmelon",
"(?) better-chat",
"! rso-mod"
]
}
2 changes: 1 addition & 1 deletion lib/gui_tabs/item_shop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function OarcItemShopGuiClick(event)
button.parent.parent.player_store_wallet_lbl.caption = { "oarc-coins-available", wallet }
end
else
player.print({ "oarc-broke-message" })
CompatSend(player, { "oarc-broke-message" })
end
end
end
Expand Down
35 changes: 29 additions & 6 deletions lib/gui_tabs/player_list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ function AddPlayerRow(table, player_name, online)
else
local spawn = FindPlayerHomeSpawn(player.name)
if (spawn) then
AddLabel(table, nil, spawn.surface_name, my_label_style)
if game.planets[spawn.surface_name] ~= nil then
AddLabel(table, nil, {"", "[planet=", spawn.surface_name, "] ", {"space-location-name."..spawn.surface_name}}, my_label_style)
else
AddLabel(table, nil, game.surfaces[spawn.surface_name].localised_name, my_label_style)
end
else
AddLabel(table, nil, "Unknown?", my_label_style) -- Shouldn't happen
end
Expand All @@ -76,7 +80,7 @@ function AddPlayerRow(table, player_name, online)
AddLabel(table, nil, FormatTimeHoursSecs(player.online_time), my_label_style)

CreatePlayerGPSButton(table, player.name)

if online then
local label = AddLabel(table, nil, {"oarc-player-online"}, my_player_list_style)
label.style.font_color = {r=0.1, g=1, b=0.1}
Expand All @@ -92,7 +96,13 @@ end
---@param player_name string
---@return nil
function CreatePlayerGPSButton(container, player_name)
local gps_button = container.add {
local flow = container.add {
type = "flow",
direction = "horizontal",
}
flow.style.vertical_align = "center"

local gps_button = flow.add {
type = "sprite-button",
sprite = "utility/gps_map_icon",
tags = {
Expand All @@ -101,10 +111,23 @@ function CreatePlayerGPSButton(container, player_name)
player_name = player_name,
},
style = "slot_button",
tooltip = {"", {"oarc-player-list-tab-location-button-tooltip"}, " (", game.players[player_name].surface.name, ")"},
tooltip = {"oarc-player-list-tab-location-button-tooltip"},
}
gps_button.style.width = 28
gps_button.style.height = 28

local surface_name
if game.players[player_name].character ~= nil then
surface_name = game.players[player_name].character.surface.name
else
surface_name = game.players[player_name].surface.name
end

if game.planets[surface_name] ~= nil then
AddLabel(flow, nil, {"", "[planet=", surface_name, "] ", {"space-location-name."..surface_name}}, my_label_style)
else
AddLabel(flow, nil, game.surfaces[surface_name].localised_name, my_label_style)
end
end

---Handle the gui click of the player list tab in the Oarc GUI.
Expand All @@ -125,7 +148,7 @@ function PlayerListTabGuiClick(event)
local target_player = game.players[player_name]

if (target_player == nil) then
player.print({"oarc-player-not-found", player_name})
CompatSend(player, {"oarc-player-not-found", player_name})
return
end

Expand All @@ -138,6 +161,6 @@ function PlayerListTabGuiClick(event)
surface = target_player.surface
end
player.set_controller{type = defines.controllers.remote, position = position, surface = surface}
player.print({"", target_player.name, ": ", GetGPStext(surface.name, position)})
CompatSend(player, {"", target_player.name, ": ", GetGPStext(surface.name, position)})
end
end
6 changes: 3 additions & 3 deletions lib/gui_tabs/settings_controls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function CreateSurfaceSettingsSection(container, player)

--- Add the rows
for name, allowed in pairs(storage.oarc_surfaces) do
AddLabel(surface_table, nil, name, my_label_style)
AddLabel(surface_table, nil, {"", "[planet=", name, "] ", {"space-location-name."..name}}, my_label_style)
AddSurfaceCheckboxSetting(surface_table, name, "spawn_enabled", allowed.primary, player.admin,
{ "oarc-settings-tab-surface-checkbox-tooltip" })
AddSurfaceCheckboxSetting(surface_table, name, "secondary_enabled", allowed.secondary, player.admin,
Expand Down Expand Up @@ -590,13 +590,13 @@ function SettingsSurfaceControlsTabGuiClick(event)
local ok, copy = serpent.load(import_text)
if (not ok) or (type(copy) ~= "table") or (next(copy) == nil) then
log("Error importing settings!")
player.print("Error importing settings!")
CompatSend(player, "Error importing settings!")
else
storage.ocfg = table.deepcopy(copy)
ValidateSettings() -- Some basic validation, not 100% foolproof
SyncModSettingsToOCFG() -- Sync the mod settings.
log("Imported settings!")
player.print("Imported settings!")
CompatSend(player, "Imported settings!")
OarcGuiRefreshContent(player)
end
end
Expand Down
40 changes: 20 additions & 20 deletions lib/gui_tabs/spawn_controls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ function CreatePrimarySpawnInfo(player, container)
local horizontal_flow = container.add { type = "flow", direction = "horizontal"}
horizontal_flow.style.vertical_align = "center"
AddLabel(horizontal_flow, nil, { "oarc-primary-spawn-info-surface-label",
primary_spawn.surface_name,
primary_spawn.position.x,
primary_spawn.position.y}, my_label_style)
{"", "[planet=", primary_spawn.surface_name, "] ", {"space-location-name."..primary_spawn.surface_name}},
primary_spawn.position.x,
primary_spawn.position.y}, my_label_style)

--Add empty widget
local dragger = horizontal_flow.add {
Expand Down Expand Up @@ -79,9 +79,9 @@ function CreateSecondarySpawnInfo(player, container)
local horizontal_flow = container.add { type = "flow", direction = "horizontal"}
horizontal_flow.style.vertical_align = "center"
AddLabel(horizontal_flow, nil, { "oarc-secondary-spawn-info-surface-label",
secondary_spawn.surface_name,
secondary_spawn.position.x,
secondary_spawn.position.y}, my_label_style)
{"", "[planet=", secondary_spawn.surface_name, "] ", {"space-location-name."..secondary_spawn.surface_name}},
secondary_spawn.position.x,
secondary_spawn.position.y}, my_label_style)

--Add empty widget
local dragger = horizontal_flow.add {
Expand Down Expand Up @@ -162,9 +162,9 @@ function CreateSetRespawnLocationButton(player, container)
local horizontal_flow = container.add { type = "flow", direction = "horizontal"}
horizontal_flow.style.vertical_align = "center"
AddLabel(horizontal_flow, nil, { "oarc-set-respawn-loc-info-surface-label",
respawn_surface_name,
respawn_position.x,
respawn_position.y }, my_label_style)
{"", "[planet=", respawn_surface_name, "] ", {"space-location-name."..respawn_surface_name}},
respawn_position.x,
respawn_position.y }, my_label_style)

--Add empty widget
local dragger = horizontal_flow.add {
Expand Down Expand Up @@ -408,34 +408,34 @@ function SpawnCtrlTabGuiClick(event)

-- Check if player has a valid character
if (player.character == nil) then
player.print({ "oarc-no-valid-player-character" })
CompatSend(player, { "oarc-no-valid-player-character" })
return
end

-- Check if player is in a vehicle
if player.driving then
player.print({ "oarc-player-character-in-vehicle" })
CompatSend(player, { "oarc-player-character-in-vehicle" })
return
end

-- Check if the surface is blacklisted
local surface_name = player.character.surface.name
if IsSurfaceBlacklisted(surface_name) then
player.print({"oarc-no-respawn-this-surface"})
CompatSend(player, {"oarc-no-respawn-this-surface"})
return
end

SetPlayerRespawn(player.name, surface_name, player.character.position, true)
OarcGuiRefreshContent(player)
player.print({ "oarc-spawn-point-updated" })
CompatSend(player, { "oarc-spawn-point-updated" })

-- Shows the spawn location on the map
elseif (tags.setting == "show_location") then
local surface_name = tags.surface --[[@as string]]
local position = tags.position --[[@as MapPosition]]

player.set_controller{type = defines.controllers.remote, position = position, surface = surface_name}
player.print({"", { "oarc-spawn-gps-location" }, " ", GetGPStext(surface_name, position)})
CompatSend(player, {"", { "oarc-spawn-gps-location" }, " ", GetGPStext(surface_name, position)})

-- Teleports the player to their home base
elseif (tags.setting == "teleport_home") then
Expand All @@ -444,13 +444,13 @@ function SpawnCtrlTabGuiClick(event)

-- Check if player has a valid character
if (player.character == nil) then
player.print({ "oarc-no-valid-player-character" })
CompatSend(player, { "oarc-no-valid-player-character" })
return
end

-- Check if player is in a vehicle
if player.driving then
player.print({ "oarc-player-character-in-vehicle" })
CompatSend(player, { "oarc-player-character-in-vehicle" })
return
end

Expand Down Expand Up @@ -478,7 +478,7 @@ function SpawnCtrlTabGuiClick(event)

if ((event.element.parent.join_queue_dropdown == nil) or
(event.element.parent.join_queue_dropdown.selected_index == 0)) then
player.print({ "oarc-selected-player-not-valid" })
CompatSend(player, { "oarc-selected-player-not-valid" })
OarcGuiRefreshContent(player)
return
end
Expand All @@ -488,7 +488,7 @@ function SpawnCtrlTabGuiClick(event)

-- Shouldn't be able to hit this since we force a GUI refresh when they leave?
if ((game.players[join_queue_player_choice] == nil) or (not game.players[join_queue_player_choice].connected)) then
player.print({ "oarc-selected-player-not-wait" })
CompatSend(player, { "oarc-selected-player-not-wait" })
OarcGuiRefreshContent(player)
return
end
Expand All @@ -500,7 +500,7 @@ function SpawnCtrlTabGuiClick(event)
RemovePlayerFromJoinQueue(join_queue_player_choice) -- This also refreshes the host gui

-- Inform the host that the player was rejected
player.print({ "oarc-reject-joiner", join_queue_player_choice })
CompatSend(player, { "oarc-reject-joiner", join_queue_player_choice })
-- Inform the player that their request was rejected
SendMsg(join_queue_player_choice, { "oarc-your-request-rejected" })

Expand All @@ -514,7 +514,7 @@ function SpawnCtrlTabGuiClick(event)

-- Check if there is space first
if (table_size(primary_spawn.joiners) >= storage.ocfg.gameplay.number_of_players_per_shared_spawn - 1) then
player.print({ "oarc-shared-spawn-full" })
CompatSend(player, { "oarc-shared-spawn-full" })
return
end

Expand Down
Loading

0 comments on commit 032d173

Please sign in to comment.