mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-01-20 02:59:53 +02:00
Working on new GUI improvements and converting regrowth into a mod.
This commit is contained in:
parent
b593d8a7e8
commit
c94bef3e77
102
control.lua
102
control.lua
@ -30,7 +30,6 @@ require("lib/oarc_utils")
|
||||
require("lib/frontier_silo")
|
||||
require("lib/tag")
|
||||
require("lib/game_opts")
|
||||
require("lib/regrowth_map")
|
||||
require("lib/player_list")
|
||||
require("lib/rocket_launch")
|
||||
require("lib/admin_commands")
|
||||
@ -72,9 +71,6 @@ script.on_init(function(event)
|
||||
-- MUST be before other stuff, but after surface creation.
|
||||
InitSpawnGlobalsAndForces()
|
||||
|
||||
-- Regardless of whether it's enabled or not, it's good to have this init.
|
||||
OarcRegrowthInit()
|
||||
|
||||
-- Frontier Silo Area Generation
|
||||
if (global.ocfg.frontier_rocket_silo) then
|
||||
SpawnSilosAndGenerateSiloAreas()
|
||||
@ -103,10 +99,6 @@ end)
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.on_chunk_generated, function(event)
|
||||
|
||||
if global.ocfg.enable_regrowth then
|
||||
OarcRegrowthChunkGenerate(event.area.left_top)
|
||||
end
|
||||
|
||||
if global.ocfg.enable_undecorator then
|
||||
UndecorateOnChunkGenerate(event)
|
||||
end
|
||||
@ -125,6 +117,10 @@ end)
|
||||
-- Gui Click
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.on_gui_click, function(event)
|
||||
|
||||
-- Don't interfere with other mod related stuff.
|
||||
if (event.element.get_mod() ~= nil) then return end
|
||||
|
||||
if global.ocfg.enable_tags then
|
||||
TagGuiClick(event)
|
||||
end
|
||||
@ -142,8 +138,9 @@ script.on_event(defines.events.on_gui_click, function(event)
|
||||
BuddySpawnRequestMenuClick(event)
|
||||
SharedSpawnJoinWaitMenuClick(event)
|
||||
|
||||
ClickOarcGuiButton(event)
|
||||
|
||||
GameOptionsGuiClick(event)
|
||||
RocketGuiClick(event)
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_gui_checked_state_changed, function (event)
|
||||
@ -151,42 +148,42 @@ script.on_event(defines.events.on_gui_checked_state_changed, function (event)
|
||||
SpawnCtrlGuiOptionsSelect(event)
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_gui_selected_tab_changed, function (event)
|
||||
TabChangeOarcGui(event)
|
||||
end)
|
||||
|
||||
----------------------------------------
|
||||
-- Player Events
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.on_player_joined_game, function(event)
|
||||
|
||||
CreateGameOptionsGui(event)
|
||||
|
||||
PlayerJoinedMessages(event)
|
||||
|
||||
if global.ocfg.enable_player_list then
|
||||
CreatePlayerListGui(event)
|
||||
end
|
||||
|
||||
if global.ocfg.enable_tags then
|
||||
CreateTagGui(event)
|
||||
end
|
||||
|
||||
if global.satellite_sent then
|
||||
CreateRocketGui(game.players[event.player_index])
|
||||
end
|
||||
|
||||
ServerWriteFile("player_events", game.players[event.player_index].name .. " joined the game." .. "\n")
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_created, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
-- Move the player to the game surface immediately.
|
||||
-- May change this to Lobby in the future.
|
||||
game.players[event.player_index].teleport({x=0,y=0}, GAME_SURFACE_NAME)
|
||||
player.teleport({x=0,y=0}, GAME_SURFACE_NAME)
|
||||
|
||||
if global.ocfg.enable_long_reach then
|
||||
GivePlayerLongReach(game.players[event.player_index])
|
||||
GivePlayerLongReach(player)
|
||||
end
|
||||
|
||||
SeparateSpawnsPlayerCreated(event.player_index)
|
||||
|
||||
-- GUI w/ Tabs
|
||||
CreateOarcGuiButton(player)
|
||||
AddOarcGuiTab(player, "Server Info", CreateGameOptionsTab)
|
||||
if global.ocfg.enable_tags then
|
||||
AddOarcGuiTab(player, "Name Tags", CreateTagGuiTab)
|
||||
end
|
||||
if global.ocfg.enable_player_list then
|
||||
AddOarcGuiTab(player, "Players", CreatePlayerListGuiTab)
|
||||
end
|
||||
if global.satellite_sent then
|
||||
AddOarcGuiTab(player, "Rockets", CreateRocketGuiTab)
|
||||
end
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_respawned, function(event)
|
||||
@ -212,10 +209,6 @@ script.on_event(defines.events.on_built_entity, function(event)
|
||||
Autofill(event)
|
||||
end
|
||||
|
||||
if global.ocfg.enable_regrowth then
|
||||
OarcRegrowthOffLimits(event.created_entity.position, 2)
|
||||
end
|
||||
|
||||
if ENABLE_ANTI_GRIEFING then
|
||||
SetItemBlueprintTimeToLive(event)
|
||||
end
|
||||
@ -232,25 +225,16 @@ end)
|
||||
-- place items that don't count as player_built and robot_built.
|
||||
-- Specifically FARL.
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.script_raised_built, function(event)
|
||||
if global.ocfg.enable_regrowth then
|
||||
OarcRegrowthOffLimits(event.entity.position, 2)
|
||||
end
|
||||
end)
|
||||
-- script.on_event(defines.events.script_raised_built, function(event)
|
||||
|
||||
-- end)
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- On tick events. Stuff that needs to happen at regular intervals.
|
||||
-- Delayed events, delayed spawns, regrowth logic...
|
||||
-- Delayed events, delayed spawns, ...
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.on_tick, function(event)
|
||||
if global.ocfg.enable_regrowth then
|
||||
OarcRegrowthOnTick()
|
||||
end
|
||||
|
||||
if global.ocfg.enable_abandoned_base_removal then
|
||||
OarcRegrowthForceRemovalOnTick()
|
||||
end
|
||||
|
||||
DelayedSpawnOnTick()
|
||||
|
||||
@ -261,39 +245,19 @@ script.on_event(defines.events.on_tick, function(event)
|
||||
end)
|
||||
|
||||
|
||||
script.on_event(defines.events.on_sector_scanned, function (event)
|
||||
if global.ocfg.enable_regrowth then
|
||||
OarcRegrowthSectorScan(event)
|
||||
end
|
||||
end)
|
||||
-- script.on_event(defines.events.on_sector_scanned, function (event)
|
||||
|
||||
-- end)
|
||||
|
||||
----------------------------------------
|
||||
-- Refreshes regrowth timers around an active timer
|
||||
-- Refresh areas where stuff is built, and mark any chunks with player
|
||||
-- built stuff as permanent.
|
||||
--
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.on_robot_built_entity, function (event)
|
||||
if global.ocfg.enable_regrowth then
|
||||
OarcRegrowthOffLimits(event.created_entity.position, 2)
|
||||
end
|
||||
|
||||
if global.ocfg.frontier_rocket_silo then
|
||||
BuildSiloAttempt(event)
|
||||
end
|
||||
end)
|
||||
|
||||
-- I disabled this because it's too much overhead for too little gain!
|
||||
-- script.on_event(defines.events.on_player_mined_entity, function(event)
|
||||
-- if global.ocfg.enable_regrowth then
|
||||
-- OarcRegrowthCheckChunkEmpty(event)
|
||||
-- end
|
||||
-- end)
|
||||
-- script.on_event(defines.events.on_robot_mined_entity, function(event)
|
||||
-- if global.ocfg.enable_regrowth then
|
||||
-- OarcRegrowthCheckChunkEmpty(event)
|
||||
-- end
|
||||
-- end)
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Shared chat, so you don't have to type /s
|
||||
|
@ -1,7 +1,7 @@
|
||||
-- example-config.lua (Rename this file to config.lua to use it)
|
||||
-- Apr 2019
|
||||
-- July 24 2019 (updated on)
|
||||
-- Configuration Options
|
||||
--
|
||||
--
|
||||
-- You should be able to leave most of the settings here as defaults.
|
||||
-- The only thing you definitely want to change are the welcome messages.
|
||||
|
||||
@ -63,7 +63,7 @@ ENABLE_LONGREACH = true
|
||||
ENABLE_AUTOFILL = true
|
||||
|
||||
-- Enable vanilla loaders
|
||||
ENABLE_LOADERS = true
|
||||
ENABLE_LOADERS = false
|
||||
|
||||
-- Enable Playerlist
|
||||
ENABLE_PLAYER_LIST = true
|
||||
@ -72,15 +72,8 @@ PLAYER_LIST_OFFLINE_PLAYERS = true -- List offline players as well.
|
||||
-- Enable shared vision between teams (all teams are COOP regardless)
|
||||
ENABLE_SHARED_TEAM_VISION = true
|
||||
|
||||
-- Enable map regrowth, see regrowth_map.lua for more info.
|
||||
-- Eseentially clears up map area that was explored but not used every hour.
|
||||
-- Helps reduce save file size.
|
||||
ENABLE_REGROWTH = false
|
||||
|
||||
-- If you have regrowth enabled, this should also be enabled.
|
||||
-- It removes bases for players that join and leave the game quickly.
|
||||
-- This can also be used without enabling regrowth.
|
||||
ENABLE_ABANDONED_BASE_REMOVAL = true
|
||||
-- Only works if you have the Unused Chunk Removal mod installed.
|
||||
ENABLE_ABANDONED_BASE_REMOVAL = false
|
||||
|
||||
-- Enable the new 0.17 research queue by default for all forces.
|
||||
ENABLE_RESEARCH_QUEUE = true
|
||||
@ -92,7 +85,7 @@ LOCK_GOODIES_UNTIL_ROCKET_LAUNCH = false
|
||||
--------------------------------------------------------------------------------
|
||||
-- MAP CONFIGURATION OPTIONS
|
||||
-- In past versions I had a way to config map settings here to be used for cmd
|
||||
-- line launching, but now you should just be using --map-gen-settings and
|
||||
-- line launching, but now you should just be using --map-gen-settings and
|
||||
-- --map-settings option since it works with --start-server-load-scenario
|
||||
-- Read the README.md file for instructions.
|
||||
--------------------------------------------------------------------------------
|
||||
@ -107,10 +100,6 @@ LOCK_GOODIES_UNTIL_ROCKET_LAUNCH = false
|
||||
-- If you're trying out the vanilla spawning, you might want to disable this.
|
||||
OARC_MODIFIED_ENEMY_SPAWNING = true
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Spawn Options
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
---------------------------------------
|
||||
-- Starting Items
|
||||
---------------------------------------
|
||||
@ -147,7 +136,7 @@ PLAYER_RESPAWN_START_ITEMS = {
|
||||
|
||||
-- This is the radius, in chunks, that a spawn area is from any other generated
|
||||
-- chunks. It ensures the spawn area isn't too near generated/explored/existing
|
||||
-- area. The larger you make this, the further away players will spawn from
|
||||
-- area. The larger you make this, the further away players will spawn from
|
||||
-- generated map area (even if it is not visible on the map!).
|
||||
CHECK_SPAWN_UNGENERATED_CHUNKS_RADIUS = 10
|
||||
|
||||
@ -187,7 +176,7 @@ OARC_CFG = {
|
||||
|
||||
-- Misc spawn related config.
|
||||
gen_settings = {
|
||||
|
||||
|
||||
-- THIS IS WHAT SETS THE SPAWN CIRCLE SIZE!
|
||||
-- Create a circle of land area for the spawn
|
||||
-- If you make this much bigger than a few chunks, good luck.
|
||||
@ -262,35 +251,35 @@ OARC_CFG = {
|
||||
-- If you are running with mods like bobs/angels, you'll want to customize this.
|
||||
resource_tiles =
|
||||
{
|
||||
["iron-ore"] =
|
||||
["iron-ore"] =
|
||||
{
|
||||
amount = 1500,
|
||||
size = 16,
|
||||
x_offset = -29,
|
||||
y_offset = 16
|
||||
},
|
||||
["copper-ore"] =
|
||||
["copper-ore"] =
|
||||
{
|
||||
amount = 1500,
|
||||
size = 14,
|
||||
x_offset = -28,
|
||||
y_offset = -3
|
||||
},
|
||||
["stone"] =
|
||||
["stone"] =
|
||||
{
|
||||
amount = 1000,
|
||||
size = 12,
|
||||
x_offset = -27,
|
||||
y_offset = -34
|
||||
},
|
||||
["coal"] =
|
||||
["coal"] =
|
||||
{
|
||||
amount = 1500,
|
||||
size = 12,
|
||||
x_offset = -27,
|
||||
y_offset = -20
|
||||
}--,
|
||||
-- ["uranium-ore"] =
|
||||
-- ["uranium-ore"] =
|
||||
-- {
|
||||
-- amount = 0,
|
||||
-- size = 0,
|
||||
@ -317,14 +306,14 @@ OARC_CFG = {
|
||||
-- See https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn/issues/11#issuecomment-479724909
|
||||
-- for full examples.
|
||||
},
|
||||
|
||||
|
||||
-- Special resource patches like oil
|
||||
resource_patches =
|
||||
{
|
||||
["crude-oil"] =
|
||||
["crude-oil"] =
|
||||
{
|
||||
num_patches = 2,
|
||||
amount = 3000000,
|
||||
amount = 900000,
|
||||
x_offset_start = -3,
|
||||
y_offset_start = 48,
|
||||
x_offset_next = 6,
|
||||
@ -421,3 +410,10 @@ ENABLE_ANTI_GRIEFING = true
|
||||
|
||||
-- Makes blueprint ghosts dissapear if they have been placed longer than this
|
||||
GHOST_TIME_TO_LIVE = 0 * TICKS_PER_MINUTE -- set to 0 for infinite ghost life
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- This turns on writing chat and certain events to specific files so that I can
|
||||
-- use that for discord integration. I suggest you leave this off unless you
|
||||
-- know what you are doing.
|
||||
--------------------------------------------------------------------------------
|
||||
ENABLE_SERVER_WRITE_FILES = false
|
@ -96,15 +96,20 @@ local function CreateRocketSilo(surface, siloPosition, force)
|
||||
|
||||
-- Set tiles below the silo
|
||||
tiles = {}
|
||||
i = 1
|
||||
for dx = -6,6 do
|
||||
for dy = -6,6 do
|
||||
if ((dx % 2 == 0) or (dx % 2 == 0)) then
|
||||
tiles[i] = {name = "concrete", position = {siloPosition.x+dx, siloPosition.y+dy}}
|
||||
for dx = -10,10 do
|
||||
for dy = -10,10 do
|
||||
if (game.active_mods["oarc-restricted-build"]) then
|
||||
table.insert(tiles, {name = global.ocfg.locked_build_area_tile,
|
||||
position = {siloPosition.x+dx, siloPosition.y+dy}})
|
||||
else
|
||||
tiles[i] = {name = "hazard-concrete-left", position = {siloPosition.x+dx, siloPosition.y+dy}}
|
||||
if ((dx % 2 == 0) or (dx % 2 == 0)) then
|
||||
table.insert(tiles, {name = "concrete",
|
||||
position = {siloPosition.x+dx, siloPosition.y+dy}})
|
||||
else
|
||||
table.insert(tiles, {name = "hazard-concrete-left",
|
||||
position = {siloPosition.x+dx, siloPosition.y+dy}})
|
||||
end
|
||||
end
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, true)
|
||||
@ -121,11 +126,14 @@ local function CreateRocketSilo(surface, siloPosition, force)
|
||||
{position=siloPosition, text="Rocket Silo",
|
||||
icon={type="item",name="rocket-silo"}})
|
||||
|
||||
-- Make silo safe from being removed by regrowth
|
||||
-- if global.ocfg.enable_regrowth then
|
||||
OarcRegrowthOffLimits(siloPosition, 5)
|
||||
-- end
|
||||
|
||||
-- Make silo safe from being removed.
|
||||
if (game.active_mods["unused-chunk-removal"]) then
|
||||
remote.call("oarc_regrowth",
|
||||
"area_offlimits_tilepos",
|
||||
surface.index,
|
||||
siloPosition,
|
||||
5)
|
||||
end
|
||||
|
||||
if ENABLE_SILO_BEACONS then
|
||||
PhilipsBeacons(surface, siloPosition, game.forces[global.ocfg.main_force])
|
||||
|
@ -7,136 +7,11 @@ require("config")
|
||||
require("lib/oarc_utils")
|
||||
require("lib/separate_spawns")
|
||||
|
||||
function CreateGameOptionsGui(event)
|
||||
local player = game.players[event.player_index]
|
||||
if mod_gui.get_button_flow(player).game_options == nil then
|
||||
mod_gui.get_button_flow(player).add{name="game_options", type="button", caption="Info", style=mod_gui.button_style}
|
||||
end
|
||||
end
|
||||
|
||||
local function ExpandGameOptionsGui(player)
|
||||
local frame = mod_gui.get_frame_flow(player)["game_options_panel"]
|
||||
if (frame) then
|
||||
frame.destroy()
|
||||
else
|
||||
local frame = mod_gui.get_frame_flow(player).add{type="frame",
|
||||
name="game_options_panel",
|
||||
caption="Server Info:",
|
||||
direction="vertical"}
|
||||
|
||||
-- General Server Info:
|
||||
AddLabel(frame, "info_1", global.ocfg.welcome_msg, my_longer_label_style)
|
||||
AddLabel(frame, "info_2", global.ocfg.server_rules, my_longer_label_style)
|
||||
AddLabel(frame, "info_3", global.ocfg.server_contact, my_longer_label_style)
|
||||
AddSpacer(frame, "info_spacer1")
|
||||
|
||||
-- Enemy Settings:
|
||||
local enemy_expansion_txt = "disabled"
|
||||
if game.map_settings.enemy_expansion.enabled then enemy_expansion_txt = "enabled" end
|
||||
|
||||
local enemy_text="Server Run Time: " .. formattime_hours_mins(game.tick) .. "\n" ..
|
||||
"Current Evolution: " .. string.format("%.4f", game.forces["enemy"].evolution_factor) .. "\n" ..
|
||||
"Enemy evolution time factor: " .. game.map_settings.enemy_evolution.time_factor .. "\n" ..
|
||||
"Enemy evolution pollution factor: " .. game.map_settings.enemy_evolution.pollution_factor .. "\n" ..
|
||||
"Enemy evolution destroy factor: " .. game.map_settings.enemy_evolution.destroy_factor .. "\n" ..
|
||||
"Enemy expansion is " .. enemy_expansion_txt
|
||||
|
||||
AddLabel(frame, "enemy_info", enemy_text, my_longer_label_style)
|
||||
AddSpacer(frame, "enemy_info_spacer1")
|
||||
|
||||
-- Game Mode:
|
||||
AddLabel(frame, "core_mod_en", "Core game mode (separate spawns) is enabled.", my_longer_label_style)
|
||||
|
||||
-- Soft Mods:
|
||||
local soft_mods_string = "Oarc Core"
|
||||
if (global.ocfg.enable_undecorator) then
|
||||
soft_mods_string = soft_mods_string .. ", Undecorator"
|
||||
end
|
||||
if (global.ocfg.enable_tags) then
|
||||
soft_mods_string = soft_mods_string .. ", Tags"
|
||||
end
|
||||
if (global.ocfg.enable_long_reach) then
|
||||
soft_mods_string = soft_mods_string .. ", Long Reach"
|
||||
end
|
||||
if (global.ocfg.enable_autofill) then
|
||||
soft_mods_string = soft_mods_string .. ", Auto Fill"
|
||||
end
|
||||
if (global.ocfg.enable_player_list) then
|
||||
soft_mods_string = soft_mods_string .. ", Player List"
|
||||
end
|
||||
|
||||
local game_info_str = "Soft Mods Enabled: " .. soft_mods_string
|
||||
|
||||
-- Spawn options:
|
||||
if (global.ocfg.enable_separate_teams) then
|
||||
game_info_str = game_info_str.."\n".."You are allowed to spawn on your own team (have your own research tree). All teams are friendly!"
|
||||
end
|
||||
if (global.ocfg.enable_vanilla_spawns) then
|
||||
game_info_str = game_info_str.."\n".."You are spawned in a default style starting area."
|
||||
else
|
||||
game_info_str = game_info_str.."\n".."You are spawned with a fix set of starting resources."
|
||||
if (global.ocfg.enable_buddy_spawn) then
|
||||
game_info_str = game_info_str.."\n".."You can chose to spawn alongside a buddy if you spawn together at the same time."
|
||||
end
|
||||
end
|
||||
if (global.ocfg.enable_shared_spawns) then
|
||||
game_info_str = game_info_str.."\n".."Spawn hosts may choose to share their spawn and allow other players to join them."
|
||||
end
|
||||
if (global.ocfg.enable_separate_teams and global.ocfg.enable_shared_team_vision) then
|
||||
game_info_str = game_info_str.."\n".."Everyone (all teams) have shared vision."
|
||||
end
|
||||
if (global.ocfg.frontier_rocket_silo) then
|
||||
game_info_str = game_info_str.."\n".."Silos are only placeable in certain areas on the map!"
|
||||
end
|
||||
if (global.ocfg.enable_regrowth) then
|
||||
game_info_str = game_info_str.."\n".."Old parts of the map will slowly be deleted over time (chunks without any player buildings)."
|
||||
end
|
||||
if (ENABLE_POWER_ARMOR_QUICK_START) then
|
||||
game_info_str = game_info_str.."\n".."Power armor quick start enabled."
|
||||
end
|
||||
if (global.ocfg.lock_goodies_rocket_launch) then
|
||||
game_info_str = game_info_str.."\n".."Artillery/Nukes/ArmorMK2 tech and Prod/Speed 3 module recipes are locked until you launch a rocket!"
|
||||
end
|
||||
|
||||
|
||||
|
||||
AddLabel(frame, "game_info_label", game_info_str, my_longer_label_style)
|
||||
|
||||
if (global.ocfg.enable_abandoned_base_removal) then
|
||||
AddLabel(frame, "leave_warning_msg", "If you leave within " .. global.ocfg.minimum_online_time .. " minutes of joining, your base and character will be deleted.", my_longer_label_style)
|
||||
frame.leave_warning_msg.style.font_color=my_color_red
|
||||
end
|
||||
|
||||
-- Ending Spacer
|
||||
AddSpacer(frame, "end_spacer")
|
||||
|
||||
-- ADMIN CONTROLS
|
||||
if (player.admin) then
|
||||
player_list = {}
|
||||
for _,player in pairs(game.connected_players) do
|
||||
table.insert(player_list, player.name)
|
||||
end
|
||||
frame.add{name = "ban_players_dropdown",
|
||||
type = "drop-down",
|
||||
items = player_list}
|
||||
frame.add{name="ban_player", type="button", caption="Ban Player"}
|
||||
frame.add{name="restart_player", type="button", caption="Restart Player"}
|
||||
|
||||
-- AddLabel(frame, "restart_warning_msg", "You might CRASH the scenario by using Restart Player. Not 100% tested yet. Will not work if player has any center gui visible.", my_longer_label_style)
|
||||
-- frame.restart_warning_msg.style.font_color=my_color_red
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function GameOptionsGuiClick(event)
|
||||
function GameOptionsGuiClick(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name == "game_options") then
|
||||
ExpandGameOptionsGui(player)
|
||||
end
|
||||
|
||||
if (name == "ban_player") then
|
||||
local pIndex = event.element.parent.ban_players_dropdown.selected_index
|
||||
|
||||
@ -161,3 +36,106 @@ function GameOptionsGuiClick(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Used by AddOarcGuiTab
|
||||
function CreateGameOptionsTab(tab_container, player)
|
||||
|
||||
-- General Server Info:
|
||||
AddLabel(tab_container, "info_1", global.ocfg.welcome_msg, my_longer_label_style)
|
||||
AddLabel(tab_container, "info_2", global.ocfg.server_rules, my_longer_label_style)
|
||||
AddLabel(tab_container, "info_3", global.ocfg.server_contact, my_longer_label_style)
|
||||
AddSpacerLine(tab_container)
|
||||
|
||||
-- Enemy Settings:
|
||||
local enemy_expansion_txt = "disabled"
|
||||
if game.map_settings.enemy_expansion.enabled then enemy_expansion_txt = "enabled" end
|
||||
|
||||
local enemy_text="Server Run Time: " .. formattime_hours_mins(game.tick) .. "\n" ..
|
||||
"Current Evolution: " .. string.format("%.4f", game.forces["enemy"].evolution_factor) .. "\n" ..
|
||||
"Enemy evolution time factor: " .. game.map_settings.enemy_evolution.time_factor .. "\n" ..
|
||||
"Enemy evolution pollution factor: " .. game.map_settings.enemy_evolution.pollution_factor .. "\n" ..
|
||||
"Enemy evolution destroy factor: " .. game.map_settings.enemy_evolution.destroy_factor .. "\n" ..
|
||||
"Enemy expansion is " .. enemy_expansion_txt
|
||||
|
||||
AddLabel(tab_container, "enemy_info", enemy_text, my_longer_label_style)
|
||||
AddSpacerLine(tab_container)
|
||||
|
||||
-- Game Mode:
|
||||
AddLabel(tab_container, "core_mod_en", "Core game mode (separate spawns) is enabled.", my_longer_label_style)
|
||||
|
||||
-- Soft Mods:
|
||||
local soft_mods_string = "Oarc Core"
|
||||
if (global.ocfg.enable_undecorator) then
|
||||
soft_mods_string = soft_mods_string .. ", Undecorator"
|
||||
end
|
||||
if (global.ocfg.enable_tags) then
|
||||
soft_mods_string = soft_mods_string .. ", Tags"
|
||||
end
|
||||
if (global.ocfg.enable_long_reach) then
|
||||
soft_mods_string = soft_mods_string .. ", Long Reach"
|
||||
end
|
||||
if (global.ocfg.enable_autofill) then
|
||||
soft_mods_string = soft_mods_string .. ", Auto Fill"
|
||||
end
|
||||
if (global.ocfg.enable_player_list) then
|
||||
soft_mods_string = soft_mods_string .. ", Player List"
|
||||
end
|
||||
|
||||
local game_info_str = "Soft Mods Enabled: " .. soft_mods_string
|
||||
|
||||
-- Spawn options:
|
||||
if (global.ocfg.enable_separate_teams) then
|
||||
game_info_str = game_info_str.."\n".."You are allowed to spawn on your own team (have your own research tree). All teams are friendly!"
|
||||
end
|
||||
if (global.ocfg.enable_vanilla_spawns) then
|
||||
game_info_str = game_info_str.."\n".."You are spawned in a default style starting area."
|
||||
else
|
||||
game_info_str = game_info_str.."\n".."You are spawned with a fix set of starting resources."
|
||||
if (global.ocfg.enable_buddy_spawn) then
|
||||
game_info_str = game_info_str.."\n".."You can chose to spawn alongside a buddy if you spawn together at the same time."
|
||||
end
|
||||
end
|
||||
if (global.ocfg.enable_shared_spawns) then
|
||||
game_info_str = game_info_str.."\n".."Spawn hosts may choose to share their spawn and allow other players to join them."
|
||||
end
|
||||
if (global.ocfg.enable_separate_teams and global.ocfg.enable_shared_team_vision) then
|
||||
game_info_str = game_info_str.."\n".."Everyone (all teams) have shared vision."
|
||||
end
|
||||
if (global.ocfg.frontier_rocket_silo) then
|
||||
game_info_str = game_info_str.."\n".."Silos are only placeable in certain areas on the map!"
|
||||
end
|
||||
if (game.active_mods["unused-chunk-removal"]) then
|
||||
game_info_str = game_info_str.."\n".."Old parts of the map will slowly be deleted over time (chunks without any player buildings)."
|
||||
end
|
||||
if (ENABLE_POWER_ARMOR_QUICK_START) then
|
||||
game_info_str = game_info_str.."\n".."Power armor quick start enabled."
|
||||
end
|
||||
if (global.ocfg.lock_goodies_rocket_launch) then
|
||||
game_info_str = game_info_str.."\n".."Artillery/Nukes/ArmorMK2 tech and Prod/Speed 3 module recipes are locked until you launch a rocket!"
|
||||
end
|
||||
|
||||
|
||||
|
||||
AddLabel(tab_container, "game_info_label", game_info_str, my_longer_label_style)
|
||||
|
||||
if (global.ocfg.enable_abandoned_base_removal) then
|
||||
AddLabel(tab_container, "leave_warning_msg", "If you leave within " .. global.ocfg.minimum_online_time .. " minutes of joining, your base and character will be deleted.", my_longer_label_style)
|
||||
tab_container.leave_warning_msg.style.font_color=my_color_red
|
||||
end
|
||||
|
||||
-- Ending Spacer
|
||||
AddSpacerLine(tab_container)
|
||||
|
||||
-- ADMIN CONTROLS
|
||||
if (player.admin) then
|
||||
player_list = {}
|
||||
for _,player in pairs(game.connected_players) do
|
||||
table.insert(player_list, player.name)
|
||||
end
|
||||
tab_container.add{name = "ban_players_dropdown",
|
||||
type = "drop-down",
|
||||
items = player_list}
|
||||
tab_container.add{name="ban_player", type="button", caption="Ban Player"}
|
||||
tab_container.add{name="restart_player", type="button", caption="Restart Player"}
|
||||
end
|
||||
end
|
@ -11,27 +11,16 @@
|
||||
-- That's a LOT of settings.
|
||||
function InitOarcConfig()
|
||||
|
||||
-- Short and sweet.
|
||||
global.ocfg = {}
|
||||
|
||||
local clean_tile_mod = false
|
||||
|
||||
local is_mod = false
|
||||
for name, version in pairs(game.active_mods) do
|
||||
if (name == "oarc-mod") then
|
||||
is_mod = true
|
||||
log("Oarc MOD! Version: " .. version)
|
||||
end
|
||||
if (name == "clean-tutorial-grid") then
|
||||
clean_tile_mod = true
|
||||
end
|
||||
if (name == "oarc-restricted-build") then
|
||||
global.ocfg.locked_build_areas = true
|
||||
end
|
||||
if (game.active_mods["clean-tutorial-grid"]) then
|
||||
global.ocfg.locked_build_area_tile = "clean-tutorial-grid"
|
||||
else
|
||||
global.ocfg.locked_build_area_tile = "tutorial-grid"
|
||||
end
|
||||
|
||||
-- SCENARIO VERSION
|
||||
if (not is_mod) then
|
||||
if (not game.active_mods["oarc-mod"]) then
|
||||
global.ocfg.welcome_title = WELCOME_MSG_TITLE
|
||||
global.ocfg.welcome_msg = WELCOME_MSG
|
||||
global.ocfg.server_rules = SERVER_MSG
|
||||
@ -49,7 +38,6 @@ function InitOarcConfig()
|
||||
global.ocfg.enable_player_list = ENABLE_PLAYER_LIST
|
||||
global.ocfg.list_offline_players = PLAYER_LIST_OFFLINE_PLAYERS
|
||||
global.ocfg.enable_shared_team_vision = ENABLE_SHARED_TEAM_VISION
|
||||
global.ocfg.enable_regrowth = ENABLE_REGROWTH
|
||||
global.ocfg.enable_abandoned_base_removal = ENABLE_ABANDONED_BASE_REMOVAL
|
||||
global.ocfg.enable_research_queue = ENABLE_RESEARCH_QUEUE
|
||||
global.ocfg.lock_goodies_rocket_launch = LOCK_GOODIES_UNTIL_ROCKET_LAUNCH
|
||||
@ -77,8 +65,12 @@ function InitOarcConfig()
|
||||
global.ocfg.frontier_silo_vision = ENABLE_SILO_VISION
|
||||
global.ocfg.frontier_allow_build = ENABLE_SILO_PLAYER_BUILD
|
||||
|
||||
global.ocfg.enable_server_write_files = ENABLE_SERVER_WRITE_FILES
|
||||
|
||||
-- MOD VERSION
|
||||
else
|
||||
log("Oarc MOD! Version: " .. game.active_mods["oarc-mod"].version)
|
||||
|
||||
global.ocfg.welcome_title = settings.global["oarc-welcome-title"].value
|
||||
global.ocfg.welcome_msg = settings.global["oarc-welcome-msg"].value
|
||||
global.ocfg.server_rules = settings.global["oarc-server-rules"].value
|
||||
@ -96,7 +88,6 @@ function InitOarcConfig()
|
||||
global.ocfg.list_offline_players = settings.global["oarc-list-offline-players"].value
|
||||
global.ocfg.enable_shared_team_vision = settings.global["oarc-enable-shared-team-vision"].value
|
||||
global.ocfg.enable_regrowth = settings.global["oarc-enable-regrowth"].value
|
||||
global.ocfg.enable_abandoned_base_removal = settings.global["oarc-enable-abandoned-base-removal"].value
|
||||
global.ocfg.enable_research_queue = settings.global["oarc-enable-research-queue"].value
|
||||
global.ocfg.lock_goodies_rocket_launch = false
|
||||
global.ocfg.modified_enemy_spawning = settings.global["oarc-modified-enemy-spawning"].value
|
||||
@ -216,13 +207,4 @@ function InitOarcConfig()
|
||||
global.ocfg.enable_buddy_spawn = false
|
||||
end
|
||||
|
||||
-----------------------
|
||||
-- SPECIAL --
|
||||
-----------------------
|
||||
if (clean_tile_mod) then
|
||||
global.ocfg.locked_build_area_tile = "clean-tutorial-grid"
|
||||
else
|
||||
global.ocfg.locked_build_area_tile = "tutorial-grid"
|
||||
end
|
||||
|
||||
end
|
@ -19,6 +19,20 @@ my_label_style = {
|
||||
top_padding = 0,
|
||||
bottom_padding = 0
|
||||
}
|
||||
my_label_header_style = {
|
||||
single_line = false,
|
||||
font = "heading-1",
|
||||
font_color = {r=1,g=1,b=1},
|
||||
top_padding = 0,
|
||||
bottom_padding = 0
|
||||
}
|
||||
my_label_header_grey_style = {
|
||||
single_line = false,
|
||||
font = "heading-1",
|
||||
font_color = {r=0.6,g=0.6,b=0.6},
|
||||
top_padding = 0,
|
||||
bottom_padding = 0
|
||||
}
|
||||
my_note_style = {
|
||||
-- minimal_width = 450,
|
||||
single_line = false,
|
||||
@ -37,7 +51,6 @@ my_warning_style = {
|
||||
}
|
||||
my_spacer_style = {
|
||||
minimal_height = 10,
|
||||
font_color = {r=0,g=0,b=0},
|
||||
top_padding = 0,
|
||||
bottom_padding = 0
|
||||
}
|
||||
@ -100,26 +113,221 @@ my_longer_warning_style = {
|
||||
function ApplyStyle (guiIn, styleIn)
|
||||
for k,v in pairs(styleIn) do
|
||||
guiIn.style[k]=v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Shorter way to add a label with a style
|
||||
function AddLabel(guiIn, name, message, style)
|
||||
guiIn.add{name = name, type = "label",
|
||||
local g = guiIn.add{name = name, type = "label",
|
||||
caption=message}
|
||||
ApplyStyle(guiIn[name], style)
|
||||
if (type(style) == "table") then
|
||||
ApplyStyle(g, style)
|
||||
else
|
||||
g.style = style
|
||||
end
|
||||
end
|
||||
|
||||
-- Shorter way to add a spacer
|
||||
function AddSpacer(guiIn, name)
|
||||
guiIn.add{name = name, type = "label",
|
||||
caption=" "}
|
||||
ApplyStyle(guiIn[name], my_spacer_style)
|
||||
function AddSpacer(guiIn)
|
||||
ApplyStyle(guiIn.add{type = "label", caption=" "}, my_spacer_style)
|
||||
end
|
||||
|
||||
-- Shorter way to add a spacer with a decorative line
|
||||
function AddSpacerLine(guiIn, name)
|
||||
guiIn.add{name = name, type = "label",
|
||||
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
|
||||
ApplyStyle(guiIn[name], my_spacer_style)
|
||||
function AddSpacerLine(guiIn)
|
||||
ApplyStyle(guiIn.add{type = "line", direction="horizontal"}, my_spacer_style)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- GUI Tab Handler
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- NAME of the top level element (outer frame)
|
||||
local OARC_GUI = "oarc_gui"
|
||||
|
||||
function CreateOarcGuiButton(player)
|
||||
if (mod_gui.get_button_flow(player).oarc_button == nil) then
|
||||
local b = mod_gui.get_button_flow(player).add{name="oarc_button",
|
||||
type="sprite-button",
|
||||
sprite="utility/expand_dots",
|
||||
style=mod_gui.button_style}
|
||||
b.style.padding=2
|
||||
b.style.width=20
|
||||
end
|
||||
|
||||
if (global.oarc_gui_tabs == nil) then
|
||||
global.oarc_gui_tabs = {}
|
||||
end
|
||||
end
|
||||
|
||||
function DoesOarcGuiExist(player)
|
||||
return (mod_gui.get_frame_flow(player)[OARC_GUI] ~= nil)
|
||||
end
|
||||
|
||||
function ToggleOarcGuiVisible(player)
|
||||
local of = mod_gui.get_frame_flow(player)[OARC_GUI]
|
||||
if (of ~= nil) then
|
||||
of.visible = not of.visible
|
||||
end
|
||||
end
|
||||
|
||||
function GetOarcGuiTabsPane(player)
|
||||
if (mod_gui.get_frame_flow(player)[OARC_GUI] == nil) then
|
||||
return nil
|
||||
else
|
||||
return mod_gui.get_frame_flow(player)[OARC_GUI].oarc_if.oarc_tabs
|
||||
end
|
||||
end
|
||||
|
||||
function ClickOarcGuiButton(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name ~= "oarc_button") then return end
|
||||
if (not DoesOarcGuiExist(player)) then
|
||||
CreateOarcGuiTabsPane(player)
|
||||
else
|
||||
ToggleOarcGuiVisible(player)
|
||||
FakeTabChangeEventOarcGui(player)
|
||||
end
|
||||
end
|
||||
|
||||
function TabChangeOarcGui(event)
|
||||
if (event.element.name ~= "oarc_tabs") then return end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
local otabs = GetOarcGuiTabsPane(player)
|
||||
local selected_tab_name = otabs.tabs[otabs.selected_tab_index].tab.name
|
||||
local container = global.oarc_gui_tabs[selected_tab_name].container
|
||||
local gui_function = global.oarc_gui_tabs[selected_tab_name].gui_tab_function
|
||||
|
||||
for i,t in pairs(otabs.tabs) do
|
||||
if (i ~= otabs.selected_tab_index) then
|
||||
local tname = otabs.tabs[i].tab.name
|
||||
global.oarc_gui_tabs[tname].container.clear()
|
||||
end
|
||||
end
|
||||
|
||||
container.clear()
|
||||
gui_function(container, player)
|
||||
end
|
||||
|
||||
function FakeTabChangeEventOarcGui(player)
|
||||
local event = {}
|
||||
event.element = {}
|
||||
event.element.name = "oarc_tabs"
|
||||
event.player_index = player.index
|
||||
TabChangeOarcGui(event)
|
||||
end
|
||||
|
||||
function CreateOarcGuiTabsPane(player)
|
||||
|
||||
if (mod_gui.get_frame_flow(player)[OARC_GUI] == nil) then
|
||||
|
||||
-- OUTER FRAME (TOP GUI ELEMENT)
|
||||
local frame = mod_gui.get_frame_flow(player).add{
|
||||
type = 'frame',
|
||||
name = OARC_GUI,
|
||||
direction = "vertical"}
|
||||
frame.style.padding = 5
|
||||
|
||||
-- INNER FRAME
|
||||
local inside_frame = frame.add{
|
||||
type = "frame",
|
||||
name = "oarc_if",
|
||||
style = "inside_deep_frame",
|
||||
direction = "vertical"
|
||||
}
|
||||
|
||||
-- SUB HEADING w/ LABEL
|
||||
local subhead = inside_frame.add{
|
||||
type="frame",
|
||||
name="sub_header",
|
||||
style = "changelog_subheader_frame"}
|
||||
AddLabel(subhead, "scen_info", "Scenario Info and Controls", "subheader_caption_label")
|
||||
|
||||
-- TABBED PANE
|
||||
local oarc_tabs = inside_frame.add{
|
||||
name="oarc_tabs",
|
||||
type="tabbed-pane",
|
||||
style="tabbed_pane"}
|
||||
oarc_tabs.style.top_padding = 8
|
||||
end
|
||||
|
||||
if (global.oarc_gui_tabs == nil) then
|
||||
global.oarc_gui_tabs = {}
|
||||
end
|
||||
end
|
||||
|
||||
-- Function creates a new tab.
|
||||
-- gui_tab_function is a function that takes (gui_element, player)
|
||||
-- It adds whatever it wants to the provided scroll-pane.
|
||||
function AddOarcGuiTab(player, tab_name, gui_tab_function)
|
||||
if (not DoesOarcGuiExist(player)) then
|
||||
CreateOarcGuiTabsPane(player)
|
||||
ToggleOarcGuiVisible(player)
|
||||
end
|
||||
|
||||
-- Destroy if it exists?
|
||||
RemoveOarcGuiTab(player, tab_name)
|
||||
|
||||
-- Get the tabbed pane
|
||||
local otabs = GetOarcGuiTabsPane(player)
|
||||
|
||||
local new_tab = otabs.add{
|
||||
type="tab",
|
||||
name=tab_name,
|
||||
caption=tab_name}
|
||||
|
||||
-- Create inside frame to hold content
|
||||
local tab_inside_frame = otabs.add{
|
||||
type="frame",
|
||||
style = "inside_deep_frame",
|
||||
direction="vertical"}
|
||||
tab_inside_frame.style.left_margin = 10
|
||||
tab_inside_frame.style.right_margin = 10
|
||||
tab_inside_frame.style.top_margin = 4
|
||||
tab_inside_frame.style.bottom_margin = 4
|
||||
tab_inside_frame.style.padding = 5
|
||||
tab_inside_frame.style.horizontally_stretchable = true
|
||||
-- tab_inside_frame.style.vertically_stretchable = true
|
||||
-- tab_inside_frame.style.horizontally_squashable = true
|
||||
-- tab_inside_frame.style.vertically_squashable = true
|
||||
|
||||
-- Add the whole thing to the tab now.
|
||||
otabs.add_tab(new_tab, tab_inside_frame)
|
||||
|
||||
-- If no other tabs are selected, select the first one.
|
||||
if (otabs.selected_tab_index == nil) then
|
||||
otabs.selected_tab_index = 1
|
||||
end
|
||||
|
||||
-- Add this tab and it's content creation function to a global table
|
||||
-- So that we can recall that function to refresh the table content.
|
||||
if (global.oarc_gui_tabs ~= nil) then
|
||||
global.oarc_gui_tabs[tab_name] = {
|
||||
container=tab_inside_frame,
|
||||
tab=new_tab,
|
||||
gui_tab_function=gui_tab_function}
|
||||
end
|
||||
|
||||
-- FakeTabChangeEventOarcGui(player)
|
||||
end
|
||||
|
||||
function RemoveOarcGuiTab(player, tab_name)
|
||||
if (not DoesOarcGuiExist(player)) then return end
|
||||
|
||||
-- Get the tabbed pane
|
||||
local otabs = GetOarcGuiTabsPane(player)
|
||||
|
||||
-- Destroy content and remove tab
|
||||
if (otabs[tab_name] ~= nil) then
|
||||
global.oarc_gui_tabs[tab_name].container.destroy()
|
||||
otabs.remove_tab(global.oarc_gui_tabs[tab_name].tab)
|
||||
global.oarc_gui_tabs[tab_name].tab.destroy()
|
||||
global.oarc_gui_tabs[tab_name] = nil
|
||||
|
||||
-- Hopefully we have a starting tab we can reset to.
|
||||
otabs.selected_tab_index = 1
|
||||
FakeTabChangeEventOarcGui(player)
|
||||
end
|
||||
end
|
@ -245,7 +245,7 @@ end
|
||||
|
||||
-- Undecorator
|
||||
function RemoveDecorationsArea(surface, area)
|
||||
surface.destroy_decoratives(area)
|
||||
surface.destroy_decoratives{area=area}
|
||||
end
|
||||
|
||||
-- Remove fish
|
||||
@ -435,9 +435,15 @@ function GetChunkTopLeft(pos)
|
||||
return {x=pos.x-(pos.x % 32), y=pos.y-(pos.y % 32)}
|
||||
end
|
||||
|
||||
-- Get area given chunk
|
||||
function GetAreaFromChunkPos(chunk_pos)
|
||||
return {left_top={x=chunk_pos.x*32, y=chunk_pos.y*32},
|
||||
right_bottom={x=chunk_pos.x*32+31, y=chunk_pos.y*32+31}}
|
||||
end
|
||||
|
||||
-- Removes the entity type from the area given
|
||||
function RemoveInArea(surface, area, type)
|
||||
for key, entity in pairs(surface.find_entities_filtered({area=area, type= type})) do
|
||||
for key, entity in pairs(surface.find_entities_filtered{area=area, type= type}) do
|
||||
if entity.valid and entity and entity.position then
|
||||
entity.destroy()
|
||||
end
|
||||
@ -447,7 +453,7 @@ end
|
||||
-- Removes the entity type from the area given
|
||||
-- Only if it is within given distance from given position.
|
||||
function RemoveInCircle(surface, area, type, pos, dist)
|
||||
for key, entity in pairs(surface.find_entities_filtered({area=area, type= type})) do
|
||||
for key, entity in pairs(surface.find_entities_filtered{area=area, type= type}) do
|
||||
if entity.valid and entity and entity.position then
|
||||
if ((pos.x - entity.position.x)^2 + (pos.y - entity.position.y)^2 < dist^2) then
|
||||
entity.destroy()
|
||||
@ -472,7 +478,11 @@ function CreateGameSurface()
|
||||
end
|
||||
|
||||
-- Create new game surface
|
||||
game.create_surface(GAME_SURFACE_NAME, nauvis_settings)
|
||||
local s = game.create_surface(GAME_SURFACE_NAME, nauvis_settings)
|
||||
|
||||
if (game.active_mods["unused-chunk-removal"]) then
|
||||
remote.call("oarc_regrowth", "add_surface", s.index)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -836,7 +846,7 @@ function CreateCropCircle(surface, centerPos, chunkArea, tileRadius, fillTile)
|
||||
if (distVar < tileRadSqr) then
|
||||
if (surface.get_tile(i,j).collides_with("water-tile") or
|
||||
global.ocfg.spawn_config.gen_settings.force_grass or
|
||||
global.ocfg.locked_build_areas) then
|
||||
(game.active_mods["oarc-restricted-build"])) then
|
||||
table.insert(dirtTiles, {name = fillTile, position ={i,j}})
|
||||
end
|
||||
end
|
||||
@ -869,7 +879,7 @@ function CreateCropOctagon(surface, centerPos, chunkArea, tileRadius, fillTile)
|
||||
if (distVar < tileRadius+2) then
|
||||
if (surface.get_tile(i,j).collides_with("water-tile") or
|
||||
global.ocfg.spawn_config.gen_settings.force_grass or
|
||||
global.ocfg.locked_build_areas) then
|
||||
(game.active_mods["oarc-restricted-build"])) then
|
||||
table.insert(dirtTiles, {name = fillTile, position ={i,j}})
|
||||
end
|
||||
end
|
||||
|
@ -4,57 +4,43 @@
|
||||
--------------------------------------------------------------------------------
|
||||
-- Player List GUI - My own version
|
||||
--------------------------------------------------------------------------------
|
||||
function CreatePlayerListGui(event)
|
||||
local player = game.players[event.player_index]
|
||||
if mod_gui.get_button_flow(player).playerList == nil then
|
||||
mod_gui.get_button_flow(player).add{name="playerList", type="button", caption="Player List", style=mod_gui.button_style}
|
||||
end
|
||||
end
|
||||
function CreatePlayerListGuiTab(tab_container, player)
|
||||
local scrollFrame = tab_container.add{type="scroll-pane",
|
||||
name="playerList-panel",
|
||||
direction = "vertical"}
|
||||
ApplyStyle(scrollFrame, my_player_list_fixed_width_style)
|
||||
scrollFrame.horizontal_scroll_policy = "never"
|
||||
|
||||
local function ExpandPlayerListGui(player)
|
||||
local frame = mod_gui.get_frame_flow(player)["playerList-panel"]
|
||||
if (frame) then
|
||||
frame.destroy()
|
||||
else
|
||||
local frame = mod_gui.get_frame_flow(player).add{type="frame",
|
||||
name="playerList-panel",
|
||||
caption="Online:"}
|
||||
local scrollFrame = frame.add{type="scroll-pane",
|
||||
name="playerList-panel",
|
||||
direction = "vertical"}
|
||||
ApplyStyle(scrollFrame, my_player_list_fixed_width_style)
|
||||
scrollFrame.horizontal_scroll_policy = "never"
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local caption_str = player.name.." ["..player.force.name.."]".." ("..formattime_hours_mins(player.online_time)..")"
|
||||
if (player.admin) then
|
||||
AddLabel(scrollFrame, player.name.."_plist", caption_str, my_player_list_admin_style)
|
||||
else
|
||||
AddLabel(scrollFrame, player.name.."_plist", caption_str, my_player_list_style)
|
||||
AddLabel(scrollFrame, "online_title_msg", "Online Players:", my_label_header_style)
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local caption_str = player.name.." ["..player.force.name.."]".." ("..formattime_hours_mins(player.online_time)..")"
|
||||
if (player.admin) then
|
||||
AddLabel(scrollFrame, player.name.."_plist", caption_str, my_player_list_admin_style)
|
||||
else
|
||||
AddLabel(scrollFrame, player.name.."_plist", caption_str, my_player_list_style)
|
||||
end
|
||||
end
|
||||
|
||||
-- List offline players
|
||||
if (global.ocfg.list_offline_players) then
|
||||
AddSpacerLine(scrollFrame)
|
||||
AddLabel(scrollFrame, "offline_title_msg", "Offline Players:", my_label_header_grey_style)
|
||||
for _,player in pairs(game.players) do
|
||||
if (not player.connected) then
|
||||
local caption_str = player.name.." ["..player.force.name.."]".." ("..formattime_hours_mins(player.online_time)..")"
|
||||
local text = scrollFrame.add{type="label", caption=caption_str, name=player.name.."_plist"}
|
||||
ApplyStyle(text, my_player_list_offline_style)
|
||||
end
|
||||
end
|
||||
|
||||
-- List offline players
|
||||
if (global.ocfg.list_offline_players) then
|
||||
AddLabel(scrollFrame, "offline_title_msg", "Offline Players:", my_label_style)
|
||||
for _,player in pairs(game.players) do
|
||||
if (not player.connected) then
|
||||
local caption_str = player.name.." ["..player.force.name.."]".." ("..formattime_hours_mins(player.online_time)..")"
|
||||
local text = scrollFrame.add{type="label", caption=caption_str, name=player.name.."_plist"}
|
||||
ApplyStyle(text, my_player_list_offline_style)
|
||||
end
|
||||
end
|
||||
end
|
||||
local spacer = scrollFrame.add{type="label", caption=" ", name="plist_spacer_plist"}
|
||||
ApplyStyle(spacer, my_player_list_style_spacer)
|
||||
end
|
||||
end
|
||||
|
||||
function PlayerListGuiClick(event)
|
||||
function PlayerListGuiClick(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name == "playerList") then
|
||||
ExpandPlayerListGui(player)
|
||||
ExpandPlayerListGui(player)
|
||||
end
|
||||
end
|
||||
|
@ -1,358 +0,0 @@
|
||||
-- regrowth_map.lua
|
||||
-- July 2017
|
||||
--
|
||||
-- Code tracks all chunks generated and allows for deleting inactive chunks
|
||||
-- Relies on some changes to RSO to provide random resource locations the next
|
||||
-- time the land is regenerated. -- (THIS IS CURRENTLY NOT WORKING IN 0.16,
|
||||
-- resources always how up in the same spot!)
|
||||
--
|
||||
-- Basic rules of regrowth:
|
||||
-- 1. Area around player is safe for quite a large distance.
|
||||
-- 2. Rocket silo won't be deleted. - PERMANENT
|
||||
-- 3. Chunks with pollution won't be deleted.
|
||||
-- 4. Chunks with railways won't be deleted.
|
||||
-- 5. Anything within radar range won't be deleted, but radar MUST be active.
|
||||
-- -- This works by refreshing all chunk timers within radar range using
|
||||
-- the on_sector_scanned event.
|
||||
-- 6. Chunks timeout after 1 hour-ish, configurable
|
||||
-- 7. For now, oarc spawns are deletion safe as well, but only immediate area.
|
||||
|
||||
-- Generic Utility Includes
|
||||
require("lib/oarc_utils")
|
||||
require("config")
|
||||
|
||||
|
||||
-- Default timeout of generated chunks
|
||||
REGROWTH_TIMEOUT_TICKS = TICKS_PER_HOUR
|
||||
|
||||
-- We can't delete chunks regularly without causing lag.
|
||||
-- So we should save them up to delete them.
|
||||
REGROWTH_CLEANING_INTERVAL_TICKS = REGROWTH_TIMEOUT_TICKS
|
||||
|
||||
-- Not used right now.
|
||||
-- It takes a radar 7 hours and 20 minutes to scan it's whole area completely
|
||||
-- So I will bump the refresh time of blocks up by 8 hours
|
||||
-- RADAR_COMPLETE_SCAN_TICKS = TICKS_PER_HOUR*8
|
||||
-- Additional bonus time for certain things:
|
||||
-- REFRESH_BONUS_RADAR = RADAR_COMPLETE_SCAN_TICKS
|
||||
|
||||
|
||||
-- Init globals and set player join area to be off limits.
|
||||
function OarcRegrowthInit()
|
||||
global.chunk_regrow = {}
|
||||
global.chunk_regrow.map = {}
|
||||
global.chunk_regrow.removal_list = {}
|
||||
global.chunk_regrow.player_refresh_index = 1
|
||||
global.chunk_regrow.min_x = 0
|
||||
global.chunk_regrow.max_x = 0
|
||||
global.chunk_regrow.x_index = 0
|
||||
global.chunk_regrow.min_y = 0
|
||||
global.chunk_regrow.max_y = 0
|
||||
global.chunk_regrow.y_index = 0
|
||||
global.chunk_regrow.force_removal_flag = -1000
|
||||
|
||||
OarcRegrowthOffLimits({x=0,y=0}, 10)
|
||||
end
|
||||
|
||||
-- This complicated function checks that if a chunk
|
||||
function CheckChunkEmpty(pos)
|
||||
chunkPos = GetChunkPosFromTilePos(pos)
|
||||
search_top_left = {x=chunkPos.x*32, y=chunkPos.y*32}
|
||||
search_area = {search_top_left, {x=search_top_left.x+32,y=search_top_left.y+32}}
|
||||
total = 0
|
||||
for f,_ in pairs(game.forces) do
|
||||
if f ~= "neutral" and f ~= "enemy" then
|
||||
entities = game.surfaces[GAME_SURFACE_NAME].find_entities_filtered{area = search_area, force=f}
|
||||
total = total + #entities
|
||||
if (#entities > 0) then
|
||||
|
||||
for _,e in pairs(entities) do
|
||||
if ((e.type == "player") or
|
||||
(e.type == "car") or
|
||||
(e.type == "logistic-robot") or
|
||||
(e.type == "construction-robot")) then
|
||||
total = total - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- A destroyed entity is still found during the event check.
|
||||
return (total == 1)
|
||||
end
|
||||
|
||||
-- game.surfaces[GAME_SURFACE_NAME].find_entities_filtered{area = {game.player.position, {game.player.position.x+32, game.player.position-`32}}, type= "resource"}
|
||||
|
||||
-- If an entity is mined or destroyed, then check if the chunk
|
||||
-- is empty. If it's empty, reset the refresh timer.
|
||||
function OarcRegrowthCheckChunkEmpty(event)
|
||||
if ((event.entity.force ~= nil) and (event.entity.force ~= "neutral") and (event.entity.force ~= "enemy")) then
|
||||
if CheckChunkEmpty(event.entity.position) then
|
||||
log("Resetting chunk timer."..event.entity.position.x.." "..event.entity.position.y)
|
||||
OarcRegrowthForceRefreshChunk(event.entity.position, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Adds new chunks to the global table to track them.
|
||||
-- This should always be called first in the chunk generate sequence
|
||||
-- (Compared to other RSO & Oarc related functions...)
|
||||
function OarcRegrowthChunkGenerate(pos)
|
||||
|
||||
c_pos = GetChunkPosFromTilePos(pos)
|
||||
|
||||
-- If this is the first chunk in that row:
|
||||
if (global.chunk_regrow.map[c_pos.x] == nil) then
|
||||
global.chunk_regrow.map[c_pos.x] = {}
|
||||
end
|
||||
|
||||
-- Confirm the chunk doesn't already have a value set:
|
||||
if (global.chunk_regrow.map[c_pos.x][c_pos.y] == nil) then
|
||||
global.chunk_regrow.map[c_pos.x][c_pos.y] = game.tick
|
||||
end
|
||||
|
||||
-- Store min/max values for x/y dimensions:
|
||||
if (c_pos.x < global.chunk_regrow.min_x) then
|
||||
global.chunk_regrow.min_x = c_pos.x
|
||||
end
|
||||
if (c_pos.x > global.chunk_regrow.max_x) then
|
||||
global.chunk_regrow.max_x = c_pos.x
|
||||
end
|
||||
if (c_pos.y < global.chunk_regrow.min_y) then
|
||||
global.chunk_regrow.min_y = c_pos.y
|
||||
end
|
||||
if (c_pos.y > global.chunk_regrow.max_y) then
|
||||
global.chunk_regrow.max_y = c_pos.y
|
||||
end
|
||||
end
|
||||
|
||||
-- Mark an area for immediate forced removal
|
||||
function OarcRegrowthMarkForRemoval(pos, chunk_radius)
|
||||
local c_pos = GetChunkPosFromTilePos(pos)
|
||||
for i=-chunk_radius,chunk_radius do
|
||||
for k=-chunk_radius,chunk_radius do
|
||||
local x = c_pos.x+i
|
||||
local y = c_pos.y+k
|
||||
|
||||
if (global.chunk_regrow.map[x] == nil) then
|
||||
global.chunk_regrow.map[x] = {}
|
||||
end
|
||||
global.chunk_regrow.map[x][y] = nil
|
||||
table.insert(global.chunk_regrow.removal_list, {pos={x=x,y=y},force=true})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Marks a chunk containing a position that won't ever be deleted.
|
||||
function OarcRegrowthOffLimitsChunkPos(pos)
|
||||
if (global.chunk_regrow.map[pos.x] == nil) then
|
||||
global.chunk_regrow.map[pos.x] = {}
|
||||
end
|
||||
global.chunk_regrow.map[pos.x][pos.y] = -1
|
||||
end
|
||||
|
||||
-- Marks a safe area around a position that won't ever be deleted.
|
||||
function OarcRegrowthOffLimits(pos, chunk_radius)
|
||||
local c_pos = GetChunkPosFromTilePos(pos)
|
||||
|
||||
for i=-chunk_radius,chunk_radius do
|
||||
for j=-chunk_radius,chunk_radius do
|
||||
OarcRegrowthOffLimitsChunkPos({x=c_pos.x+i,y=c_pos.y+j})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Refreshes timers on a chunk containing position
|
||||
function OarcRegrowthRefreshChunk(pos, bonus_time)
|
||||
local c_pos = GetChunkPosFromTilePos(pos)
|
||||
|
||||
if (global.chunk_regrow.map[c_pos.x] == nil) then
|
||||
global.chunk_regrow.map[c_pos.x] = {}
|
||||
end
|
||||
if (global.chunk_regrow.map[c_pos.x][c_pos.y] ~= -1) then
|
||||
global.chunk_regrow.map[c_pos.x][c_pos.y] = game.tick + bonus_time
|
||||
end
|
||||
end
|
||||
|
||||
-- Forcefully refreshes timers on a chunk containing position
|
||||
-- Will overwrite -1 flag.
|
||||
function OarcRegrowthForceRefreshChunk(pos, bonus_time)
|
||||
local c_pos = GetChunkPosFromTilePos(pos)
|
||||
|
||||
if (global.chunk_regrow.map[c_pos.x] == nil) then
|
||||
global.chunk_regrow.map[c_pos.x] = {}
|
||||
end
|
||||
global.chunk_regrow.map[c_pos.x][c_pos.y] = game.tick + bonus_time
|
||||
end
|
||||
|
||||
-- Refreshes timers on all chunks around a certain area
|
||||
function OarcRegrowthRefreshArea(pos, chunk_radius, bonus_time)
|
||||
local c_pos = GetChunkPosFromTilePos(pos)
|
||||
|
||||
for i=-chunk_radius,chunk_radius do
|
||||
for k=-chunk_radius,chunk_radius do
|
||||
local x = c_pos.x+i
|
||||
local y = c_pos.y+k
|
||||
|
||||
if (global.chunk_regrow.map[x] == nil) then
|
||||
global.chunk_regrow.map[x] = {}
|
||||
end
|
||||
if (global.chunk_regrow.map[x][y] ~= -1) then
|
||||
global.chunk_regrow.map[x][y] = game.tick + bonus_time
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Refreshes timers on all chunks near an ACTIVE radar
|
||||
function OarcRegrowthSectorScan(event)
|
||||
OarcRegrowthRefreshArea(event.radar.position, 14, 0)
|
||||
OarcRegrowthRefreshChunk(event.chunk_position, 0)
|
||||
end
|
||||
|
||||
-- Refresh all chunks near a single player. Cyles through all connected players.
|
||||
function OarcRegrowthRefreshPlayerArea()
|
||||
global.chunk_regrow.player_refresh_index = global.chunk_regrow.player_refresh_index + 1
|
||||
if (global.chunk_regrow.player_refresh_index > #game.connected_players) then
|
||||
global.chunk_regrow.player_refresh_index = 1
|
||||
end
|
||||
if (game.connected_players[global.chunk_regrow.player_refresh_index]) then
|
||||
OarcRegrowthRefreshArea(game.connected_players[global.chunk_regrow.player_refresh_index].position, 4, 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Check each chunk in the 2d array for a timeout value
|
||||
function OarcRegrowthCheckArray()
|
||||
|
||||
-- Increment X
|
||||
if (global.chunk_regrow.x_index > global.chunk_regrow.max_x) then
|
||||
global.chunk_regrow.x_index = global.chunk_regrow.min_x
|
||||
|
||||
-- Increment Y
|
||||
if (global.chunk_regrow.y_index > global.chunk_regrow.max_y) then
|
||||
global.chunk_regrow.y_index = global.chunk_regrow.min_y
|
||||
log("Finished checking regrowth array."..global.chunk_regrow.min_x.." "..global.chunk_regrow.max_x.." "..global.chunk_regrow.min_y.." "..global.chunk_regrow.max_y)
|
||||
else
|
||||
global.chunk_regrow.y_index = global.chunk_regrow.y_index + 1
|
||||
end
|
||||
else
|
||||
global.chunk_regrow.x_index = global.chunk_regrow.x_index + 1
|
||||
end
|
||||
|
||||
-- Check row exists, otherwise make one.
|
||||
if (global.chunk_regrow.map[global.chunk_regrow.x_index] == nil) then
|
||||
global.chunk_regrow.map[global.chunk_regrow.x_index] = {}
|
||||
end
|
||||
|
||||
-- If the chunk has timed out, add it to the removal list
|
||||
local c_timer = global.chunk_regrow.map[global.chunk_regrow.x_index][global.chunk_regrow.y_index]
|
||||
if ((c_timer ~= nil) and (c_timer ~= -1) and ((c_timer+REGROWTH_TIMEOUT_TICKS) < game.tick)) then
|
||||
|
||||
-- Check chunk actually exists
|
||||
if (game.surfaces[GAME_SURFACE_NAME].is_chunk_generated({x=(global.chunk_regrow.x_index),
|
||||
y=(global.chunk_regrow.y_index)})) then
|
||||
table.insert(global.chunk_regrow.removal_list, {pos={x=global.chunk_regrow.x_index,
|
||||
y=global.chunk_regrow.y_index},
|
||||
force=false})
|
||||
global.chunk_regrow.map[global.chunk_regrow.x_index][global.chunk_regrow.y_index] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove all chunks at same time to reduce impact to FPS/UPS
|
||||
function OarcRegrowthRemoveAllChunks()
|
||||
while (#global.chunk_regrow.removal_list > 0) do
|
||||
local c_remove = table.remove(global.chunk_regrow.removal_list)
|
||||
local c_pos = c_remove.pos
|
||||
local c_timer = global.chunk_regrow.map[c_pos.x][c_pos.y]
|
||||
|
||||
if (game.surfaces[GAME_SURFACE_NAME] == nil) then
|
||||
log("Error! game.surfaces[name] is nil?? WTF?")
|
||||
return
|
||||
end
|
||||
|
||||
-- Confirm chunk is still expired
|
||||
if (c_timer == nil) then
|
||||
|
||||
-- If it is FORCE removal, then remove it regardless of pollution.
|
||||
if (c_remove.force) then
|
||||
game.surfaces[GAME_SURFACE_NAME].delete_chunk(c_pos)
|
||||
global.chunk_regrow.map[c_pos.x][c_pos.y] = nil
|
||||
|
||||
-- If it is a normal timeout removal, don't do it if there is pollution in the chunk.
|
||||
elseif (game.surfaces[GAME_SURFACE_NAME].get_pollution({c_pos.x*32,c_pos.y*32}) > 0) then
|
||||
global.chunk_regrow.map[c_pos.x][c_pos.y] = game.tick
|
||||
|
||||
-- Else delete the chunk
|
||||
else
|
||||
game.surfaces[GAME_SURFACE_NAME].delete_chunk(c_pos)
|
||||
global.chunk_regrow.map[c_pos.x][c_pos.y] = nil
|
||||
end
|
||||
else
|
||||
|
||||
-- log("Chunk no longer expired?")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- This is the main work function, it checks a single chunk in the list
|
||||
-- per tick. It works according to the rules listed in the header of this
|
||||
-- file.
|
||||
function OarcRegrowthOnTick()
|
||||
|
||||
-- Every half a second, refresh all chunks near a single player
|
||||
-- Cyles through all players. Tick is offset by 2
|
||||
if ((game.tick % (30)) == 2) then
|
||||
OarcRegrowthRefreshPlayerArea()
|
||||
end
|
||||
|
||||
-- Every tick, check a few points in the 2d array
|
||||
-- According to /measured-command this shouldn't take more
|
||||
-- than 0.1ms on average
|
||||
for i=1,20 do
|
||||
OarcRegrowthCheckArray()
|
||||
end
|
||||
|
||||
-- Send a broadcast warning before it happens.
|
||||
if ((game.tick % REGROWTH_CLEANING_INTERVAL_TICKS) == REGROWTH_CLEANING_INTERVAL_TICKS-601) then
|
||||
if (#global.chunk_regrow.removal_list > 100) then
|
||||
if (global.ocfg.enable_regrowth) then
|
||||
SendBroadcastMsg("Map cleanup in 10 seconds... Unused and old map chunks will be deleted!")
|
||||
else
|
||||
SendBroadcastMsg("Map cleanup in 10 seconds. Cleaning up an abadoned base!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Delete all listed chunks
|
||||
if ((game.tick % REGROWTH_CLEANING_INTERVAL_TICKS) == REGROWTH_CLEANING_INTERVAL_TICKS-1) then
|
||||
if (#global.chunk_regrow.removal_list > 100) then
|
||||
OarcRegrowthRemoveAllChunks()
|
||||
SendBroadcastMsg("Map cleanup done, sorry for your loss.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- This function removes any chunks flagged but on demand.
|
||||
-- Controlled by the global.chunk_regrow.force_removal_flag
|
||||
-- This function may be used outside of the normal regrowth modse.
|
||||
function OarcRegrowthForceRemovalOnTick()
|
||||
-- Catch force remove flag
|
||||
if (game.tick == global.chunk_regrow.force_removal_flag+60) then
|
||||
if (global.ocfg.enable_regrowth) then
|
||||
SendBroadcastMsg("Map cleanup in 10 seconds... Unused and old map chunks will be deleted!")
|
||||
else
|
||||
SendBroadcastMsg("Map cleanup in 10 seconds. Cleaning up an abadoned base!")
|
||||
end
|
||||
end
|
||||
if (game.tick == global.chunk_regrow.force_removal_flag+660) then
|
||||
OarcRegrowthRemoveAllChunks()
|
||||
|
||||
if (global.ocfg.enable_regrowth) then
|
||||
SendBroadcastMsg("Map cleanup done, sorry for your loss.")
|
||||
else
|
||||
SendBroadcastMsg("Abandoned base cleanup complete.")
|
||||
end
|
||||
end
|
||||
end
|
@ -12,7 +12,7 @@ require("config")
|
||||
--------------------------------------------------------------------------------
|
||||
function RocketLaunchEvent(event)
|
||||
local force = event.rocket.force
|
||||
|
||||
|
||||
-- Notify players on force if rocket was launched without sat.
|
||||
if event.rocket.get_item_count("satellite") == 0 then
|
||||
for index, player in pairs(force.players) do
|
||||
@ -27,14 +27,14 @@ function RocketLaunchEvent(event)
|
||||
SendBroadcastMsg("Team " .. event.rocket.force.name .. " was the first to launch a rocket!")
|
||||
ServerWriteFile("rocket_events", "Team " .. event.rocket.force.name .. " was the first to launch a rocket!" .. "\n")
|
||||
|
||||
for name,player in pairs(game.connected_players) do
|
||||
CreateRocketGui(player)
|
||||
end
|
||||
for name,player in pairs(game.connected_players) do
|
||||
AddOarcGuiTab(player, "Rockets", CreateRocketGuiTab)
|
||||
end
|
||||
end
|
||||
|
||||
-- Track additional satellites launched by this force
|
||||
if global.satellite_sent[force.name] then
|
||||
global.satellite_sent[force.name] = global.satellite_sent[force.name] + 1
|
||||
global.satellite_sent[force.name] = global.satellite_sent[force.name] + 1
|
||||
SendBroadcastMsg("Team " .. event.rocket.force.name .. " launched another rocket. Total " .. global.satellite_sent[force.name])
|
||||
ServerWriteFile("rocket_events", "Team " .. event.rocket.force.name .. " launched another rocket. Total " .. global.satellite_sent[force.name] .. "\n")
|
||||
|
||||
@ -52,43 +52,29 @@ function RocketLaunchEvent(event)
|
||||
EnableTech(force, "artillery")
|
||||
|
||||
if (force.technologies["speed-module-3"].researched) then
|
||||
AddRecipe(force, "speed-module-3")
|
||||
end
|
||||
if (force.technologies["productivity-module-3"].researched) then
|
||||
AddRecipe(force, "productivity-module-3")
|
||||
end
|
||||
AddRecipe(force, "speed-module-3")
|
||||
end
|
||||
if (force.technologies["productivity-module-3"].researched) then
|
||||
AddRecipe(force, "productivity-module-3")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function CreateRocketGuiTab(tab_container, player)
|
||||
-- local frame = tab_container.add{type="frame", name="rocket-panel", caption="Satellites Launched:", direction = "vertical"}
|
||||
|
||||
function CreateRocketGui(player)
|
||||
if mod_gui.get_button_flow(player)["rocket-score"] == nil then
|
||||
mod_gui.get_button_flow(player).add{name="rocket-score", type="button", caption="Rockets", style=mod_gui.button_style}
|
||||
end
|
||||
end
|
||||
AddLabel(tab_container, nil, "Satellites Launched:", my_label_header_style)
|
||||
|
||||
|
||||
local function ExpandRocketGui(player)
|
||||
local frame = player.gui.left["rocket-panel"]
|
||||
if (frame) then
|
||||
frame.destroy()
|
||||
if (global.satellite_sent == nil) then
|
||||
AddLabel(tab_container, nil, "No launches yet.", my_label_style)
|
||||
else
|
||||
local frame = player.gui.left.add{type="frame", name="rocket-panel", caption="Satellites Launched:", direction = "vertical"}
|
||||
|
||||
for force_name,sat_count in pairs(global.satellite_sent) do
|
||||
frame.add{name="rc_"..force_name, type = "label",
|
||||
caption="Team " .. force_name .. ": " .. tostring(sat_count)}
|
||||
AddLabel(tab_container,
|
||||
"rc_"..force_name,
|
||||
"Team " .. force_name .. ": " .. tostring(sat_count),
|
||||
my_label_style)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function RocketGuiClick(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name == "rocket-score") then
|
||||
ExpandRocketGui(player)
|
||||
end
|
||||
end
|
||||
|
@ -17,6 +17,8 @@ require("config")
|
||||
function SeparateSpawnsPlayerCreated(player_index)
|
||||
local player = game.players[player_index]
|
||||
|
||||
RemoveOarcGuiTab(player, "Spawn Controls")
|
||||
|
||||
-- This checks if they have just joined the server.
|
||||
-- No assigned force yet.
|
||||
if (player.force.name ~= "player") then
|
||||
@ -114,7 +116,11 @@ function FindUnusedSpawns(player, remove_player)
|
||||
end
|
||||
end
|
||||
|
||||
if (global.ocfg.enable_abandoned_base_removal and not nearOtherSpawn) then
|
||||
-- Unused Chunk Removal mod (aka regrowth)
|
||||
if (global.ocfg.enable_abandoned_base_removal and
|
||||
(not nearOtherSpawn) and
|
||||
game.active_mods["unused-chunk-removal"]) then
|
||||
|
||||
if (global.uniqueSpawns[player.name].vanilla) then
|
||||
log("Returning a vanilla spawn back to available.")
|
||||
table.insert(global.vanillaSpawns, {x=spawnPos.x,y=spawnPos.y})
|
||||
@ -123,9 +129,15 @@ function FindUnusedSpawns(player, remove_player)
|
||||
global.uniqueSpawns[player.name] = nil
|
||||
|
||||
log("Removing base: " .. spawnPos.x .. "," .. spawnPos.y)
|
||||
OarcRegrowthMarkForRemoval(spawnPos, CHECK_SPAWN_UNGENERATED_CHUNKS_RADIUS+5)
|
||||
|
||||
remote.call("oarc_regrowth",
|
||||
"area_removal_tilepos",
|
||||
GAME_SURFACE_NAME,
|
||||
spawnPos,
|
||||
CHECK_SPAWN_UNGENERATED_CHUNKS_RADIUS+5)
|
||||
remote.call("oarc_regrowth",
|
||||
"trigger_immediate_cleanup")
|
||||
SendBroadcastMsg(player.name .. "'s base was marked for immediate clean up because they left within "..global.ocfg.minimum_online_time.." minutes of joining.")
|
||||
global.chunk_regrow.force_removal_flag = game.tick
|
||||
|
||||
else
|
||||
-- table.insert(global.unusedSpawns, global.uniqueSpawns[player.name]) -- Not used/implemented right now.
|
||||
@ -207,7 +219,7 @@ function SetupAndClearSpawnAreas(surface, chunkArea)
|
||||
RemoveDecorationsArea(surface, chunkArea)
|
||||
|
||||
local fill_tile = "grass-1"
|
||||
if (global.ocfg.locked_build_areas) then
|
||||
if (game.active_mods["oarc-restricted-build"]) then
|
||||
fill_tile = global.ocfg.locked_build_area_tile
|
||||
end
|
||||
|
||||
@ -245,7 +257,7 @@ function GetClosestUniqueSpawn(pos)
|
||||
end
|
||||
|
||||
if (closest_key == nil) then
|
||||
log("GetClosestUniqueSpawn ERROR - None found?")
|
||||
-- log("GetClosestUniqueSpawn ERROR - None found?")
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -269,7 +281,7 @@ function ModifyEnemySpawnsNearPlayerStartingAreas(event)
|
||||
local closest_spawn = GetClosestUniqueSpawn(enemy_pos)
|
||||
|
||||
if (closest_spawn == nil) then
|
||||
log("GetClosestUniqueSpawn ERROR - None found?")
|
||||
-- log("GetClosestUniqueSpawn ERROR - None found?")
|
||||
return
|
||||
end
|
||||
|
||||
@ -507,7 +519,6 @@ function InitSpawnGlobalsAndForces()
|
||||
main_force.set_spawn_position({x=0,y=0}, GAME_SURFACE_NAME)
|
||||
end
|
||||
|
||||
|
||||
function DoesPlayerHaveCustomSpawn(player)
|
||||
for name,spawnPos in pairs(global.playerSpawns) do
|
||||
if (player.name == name) then
|
||||
@ -592,8 +603,8 @@ function SendPlayerToNewSpawnAndCreateIt(delayedSpawn)
|
||||
-- Chart the area.
|
||||
ChartArea(player.force, delayedSpawn.pos, math.ceil(global.ocfg.spawn_config.gen_settings.land_area_tiles/CHUNK_SIZE), player.surface)
|
||||
|
||||
if (player.gui.center.wait_for_spawn_dialog ~= nil) then
|
||||
player.gui.center.wait_for_spawn_dialog.destroy()
|
||||
if (player.gui.screen.wait_for_spawn_dialog ~= nil) then
|
||||
player.gui.screen.wait_for_spawn_dialog.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -26,15 +26,23 @@ local SPAWN_GUI_MAX_HEIGHT = 1000
|
||||
-- A display gui message
|
||||
-- Meant to be display the first time a player joins.
|
||||
function DisplayWelcomeTextGui(player)
|
||||
if (TableLength(player.gui.center.children) > 0) then
|
||||
if ((player.gui.screen["welcome_msg"] ~= nil) or
|
||||
(player.gui.screen["spawn_opts"] ~= nil) or
|
||||
(player.gui.screen["shared_spawn_opts"] ~= nil) or
|
||||
(player.gui.screen["join_shared_spawn_wait_menu"] ~= nil) or
|
||||
(player.gui.screen["buddy_spawn_opts"] ~= nil) or
|
||||
(player.gui.screen["buddy_wait_menu"] ~= nil) or
|
||||
(player.gui.screen["buddy_request_menu"] ~= nil) or
|
||||
(player.gui.screen["wait_for_spawn_dialog"] ~= nil)) then
|
||||
log("DisplayWelcomeTextGui called while some other dialog is already displayed!")
|
||||
return
|
||||
return false
|
||||
end
|
||||
player.gui.center.add{name = "welcome_msg",
|
||||
|
||||
local wGui = player.gui.screen.add{name = "welcome_msg",
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
caption=global.ocfg.welcome_title}
|
||||
local wGui = player.gui.center.welcome_msg
|
||||
wGui.auto_center=true
|
||||
|
||||
wGui.style.maximal_width = SPAWN_GUI_MAX_WIDTH
|
||||
wGui.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
@ -42,14 +50,17 @@ function DisplayWelcomeTextGui(player)
|
||||
-- Start with server message.
|
||||
AddLabel(wGui, "server_msg_lbl1", global.ocfg.server_rules, my_label_style)
|
||||
AddLabel(wGui, "contact_info_msg_lbl1", global.ocfg.server_contact, my_label_style)
|
||||
AddSpacer(wGui, "server_msg_spacer1")
|
||||
AddSpacer(wGui)
|
||||
|
||||
-- Informational message about the scenario
|
||||
AddLabel(wGui, "scenario_info_msg_lbl1", SCENARIO_INFO_MSG, my_label_style)
|
||||
AddSpacer(wGui, "scenario_info_msg_spacer1")
|
||||
AddSpacer(wGui)
|
||||
|
||||
-- Warning about spawn creation time
|
||||
AddLabel(wGui, "spawn_time_msg_lbl1", {"oarc-spawn-time-warning-msg"}, my_warning_style)
|
||||
|
||||
-- Confirm button
|
||||
AddSpacerLine(wGui)
|
||||
local button_flow = wGui.add{type = "flow"}
|
||||
button_flow.style.horizontal_align = "right"
|
||||
button_flow.style.horizontally_stretchable = true
|
||||
@ -58,6 +69,7 @@ function DisplayWelcomeTextGui(player)
|
||||
caption={"oarc-i-understand"},
|
||||
style = "confirm_button"}
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@ -73,8 +85,8 @@ function WelcomeTextGuiClick(event)
|
||||
end
|
||||
|
||||
if (buttonClicked == "welcome_okay_btn") then
|
||||
if (player.gui.center.welcome_msg ~= nil) then
|
||||
player.gui.center.welcome_msg.destroy()
|
||||
if (player.gui.screen.welcome_msg ~= nil) then
|
||||
player.gui.screen.welcome_msg.destroy()
|
||||
end
|
||||
DisplaySpawnOptions(player)
|
||||
end
|
||||
@ -88,18 +100,18 @@ function DisplaySpawnOptions(player)
|
||||
return
|
||||
end
|
||||
|
||||
if (player.gui.center.spawn_opts ~= nil) then
|
||||
if (player.gui.screen.spawn_opts ~= nil) then
|
||||
log("Tried to display spawn options when it was already displayed!")
|
||||
return
|
||||
end
|
||||
player.gui.center.add{name = "spawn_opts",
|
||||
player.gui.screen.add{name = "spawn_opts",
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
caption={"oarc-spawn-options"}}
|
||||
local sGui = player.gui.center.spawn_opts
|
||||
local sGui = player.gui.screen.spawn_opts
|
||||
sGui.style.maximal_width = SPAWN_GUI_MAX_WIDTH
|
||||
sGui.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
|
||||
sGui.auto_center=true
|
||||
|
||||
-- Warnings and explanations...
|
||||
local warn_msg = {"oarc-click-info-btn-help"}
|
||||
@ -265,11 +277,11 @@ function SpawnOptsGuiClick(event)
|
||||
return
|
||||
end
|
||||
|
||||
if (player.gui.center.spawn_opts == nil) then
|
||||
if (player.gui.screen.spawn_opts == nil) then
|
||||
return -- Gui event unrelated to this gui.
|
||||
end
|
||||
|
||||
local pgcs = player.gui.center.spawn_opts
|
||||
local pgcs = player.gui.screen.spawn_opts
|
||||
|
||||
local joinMainTeamRadio, joinOwnTeamRadio, moatChoice, vanillaChoice = false
|
||||
|
||||
@ -310,7 +322,7 @@ function SpawnOptsGuiClick(event)
|
||||
SendBroadcastMsg({"oarc-player-is-joining-main-force", player.name})
|
||||
ChartArea(player.force, player.position, math.ceil(global.ocfg.spawn_config.gen_settings.land_area_tiles/CHUNK_SIZE), player.surface)
|
||||
-- Create the button at the top left for setting respawn point and sharing base.
|
||||
CreateSpawnCtrlGui(player)
|
||||
AddOarcGuiTab(player, "Spawn Controls", CreateSpawnCtrlGuiTab)
|
||||
|
||||
elseif ((elemName == "isolated_spawn_near") or (elemName == "isolated_spawn_far")) then
|
||||
|
||||
@ -362,7 +374,7 @@ function SpawnOptsGuiClick(event)
|
||||
end
|
||||
|
||||
-- Create the button at the top left for setting respawn point and sharing base.
|
||||
CreateSpawnCtrlGui(player)
|
||||
AddOarcGuiTab(player, "Spawn Controls", CreateSpawnCtrlGuiTab)
|
||||
|
||||
player.print({"oarc-please-wait"})
|
||||
player.print({"", {"oarc-please-wait"}, "!"})
|
||||
@ -388,12 +400,13 @@ end
|
||||
|
||||
-- Display the spawn options and explanation
|
||||
function DisplaySharedSpawnOptions(player)
|
||||
player.gui.center.add{name = "shared_spawn_opts",
|
||||
player.gui.screen.add{name = "shared_spawn_opts",
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
caption={"oarc-avail-bases-join"}}
|
||||
|
||||
local shGuiFrame = player.gui.center.shared_spawn_opts
|
||||
local shGuiFrame = player.gui.screen.shared_spawn_opts
|
||||
shGuiFrame.auto_center = true
|
||||
local shGui = shGuiFrame.add{type="scroll-pane", name="spawns_scroll_pane", caption=""}
|
||||
ApplyStyle(shGui, my_fixed_width_style)
|
||||
shGui.style.maximal_width = SPAWN_GUI_MAX_WIDTH
|
||||
@ -445,8 +458,8 @@ function SharedSpwnOptsGuiClick(event)
|
||||
-- Check for cancel button, return to spawn options
|
||||
if (buttonClicked == "shared_spawn_cancel") then
|
||||
DisplaySpawnOptions(player)
|
||||
if (player.gui.center.shared_spawn_opts ~= nil) then
|
||||
player.gui.center.shared_spawn_opts.destroy()
|
||||
if (player.gui.screen.shared_spawn_opts ~= nil) then
|
||||
player.gui.screen.shared_spawn_opts.destroy()
|
||||
end
|
||||
|
||||
-- Else check for which spawn was selected
|
||||
@ -464,8 +477,8 @@ function SharedSpwnOptsGuiClick(event)
|
||||
table.insert(global.sharedSpawns[spawnName].joinQueue, player.name)
|
||||
|
||||
-- Clear the shared spawn options gui.
|
||||
if (player.gui.center.shared_spawn_opts ~= nil) then
|
||||
player.gui.center.shared_spawn_opts.destroy()
|
||||
if (player.gui.screen.shared_spawn_opts ~= nil) then
|
||||
player.gui.screen.shared_spawn_opts.destroy()
|
||||
end
|
||||
|
||||
-- Display wait menu with cancel button.
|
||||
@ -481,11 +494,11 @@ end
|
||||
|
||||
function DisplaySharedSpawnJoinWaitMenu(player)
|
||||
|
||||
player.gui.center.add{name = "join_shared_spawn_wait_menu",
|
||||
local sGui = player.gui.screen.add{name = "join_shared_spawn_wait_menu",
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
caption={"oarc-waiting-for-spawn-owner"}}
|
||||
local sGui = player.gui.center.join_shared_spawn_wait_menu
|
||||
sGui.auto_center = true
|
||||
sGui.style.maximal_width = SPAWN_GUI_MAX_WIDTH
|
||||
sGui.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
|
||||
@ -509,13 +522,13 @@ function SharedSpawnJoinWaitMenuClick(event)
|
||||
return
|
||||
end
|
||||
|
||||
if (player.gui.center.join_shared_spawn_wait_menu == nil) then
|
||||
if (player.gui.screen.join_shared_spawn_wait_menu == nil) then
|
||||
return -- Gui event unrelated to this gui.
|
||||
end
|
||||
|
||||
-- Check if player is cancelling the request.
|
||||
if (elemName == "cancel_shared_spawn_wait_menu") then
|
||||
player.gui.center.join_shared_spawn_wait_menu.destroy()
|
||||
player.gui.screen.join_shared_spawn_wait_menu.destroy()
|
||||
DisplaySpawnOptions(player)
|
||||
|
||||
-- Find and remove the player from the joinQueue they were in.
|
||||
@ -535,14 +548,6 @@ function SharedSpawnJoinWaitMenuClick(event)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function CreateSpawnCtrlGui(player)
|
||||
if player and (mod_gui.get_button_flow(player).spwn_ctrls == nil) then
|
||||
mod_gui.get_button_flow(player).add{name="spwn_ctrls", type="button", caption={"oarc-spawn-ctrl"}, style=mod_gui.button_style}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function IsSharedSpawnActive(player)
|
||||
if ((global.sharedSpawns[player.name] == nil) or
|
||||
(global.sharedSpawns[player.name].openAccess == false)) then
|
||||
@ -570,70 +575,62 @@ function GetRandomSpawnPoint()
|
||||
return {x=0,y=0}
|
||||
end
|
||||
|
||||
|
||||
-- This is a toggle function, it either shows or hides the spawn controls
|
||||
function ExpandSpawnCtrlGui(player, tick)
|
||||
local spwnCtrlPanel = mod_gui.get_frame_flow(player)["spwn_ctrl_panel"]
|
||||
if (spwnCtrlPanel) then
|
||||
spwnCtrlPanel.destroy()
|
||||
else
|
||||
local spwnCtrlPanel = mod_gui.get_frame_flow(player).add{type="frame",
|
||||
name="spwn_ctrl_panel", caption={"oarc-spawn-controls"}}
|
||||
local spwnCtrls = spwnCtrlPanel.add{type="scroll-pane",
|
||||
name="spwn_ctrl_panel", caption=""}
|
||||
ApplyStyle(spwnCtrls, my_fixed_width_style)
|
||||
spwnCtrls.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
spwnCtrls.horizontal_scroll_policy = "never"
|
||||
function CreateSpawnCtrlGuiTab(tab_container, player)
|
||||
local spwnCtrls = tab_container.add{
|
||||
type="scroll-pane",
|
||||
name="spwn_ctrl_panel",
|
||||
caption=""}
|
||||
ApplyStyle(spwnCtrls, my_fixed_width_style)
|
||||
spwnCtrls.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
spwnCtrls.horizontal_scroll_policy = "never"
|
||||
|
||||
if global.ocfg.enable_shared_spawns then
|
||||
if (global.uniqueSpawns[player.name] ~= nil) then
|
||||
-- This checkbox allows people to join your base when they first
|
||||
-- start the game.
|
||||
spwnCtrls.add{type="checkbox", name="accessToggle",
|
||||
caption={"oarc-spawn-allow-joiners"},
|
||||
state=IsSharedSpawnActive(player)}
|
||||
ApplyStyle(spwnCtrls["accessToggle"], my_fixed_width_style)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Sets the player's custom spawn point to their current location
|
||||
if ((tick - global.playerCooldowns[player.name].setRespawn) >
|
||||
(global.ocfg.respawn_cooldown_min * TICKS_PER_MINUTE)) then
|
||||
spwnCtrls.add{type="button", name="setRespawnLocation", caption={"oarc-set-respawn-loc"}}
|
||||
spwnCtrls["setRespawnLocation"].style.font = "default-small-semibold"
|
||||
|
||||
else
|
||||
AddLabel(spwnCtrls,"respawn_cooldown_note1",
|
||||
{"oarc-set-respawn-loc-cooldown", formattime((global.ocfg.respawn_cooldown_min * TICKS_PER_MINUTE)-(tick - global.playerCooldowns[player.name].setRespawn))}, my_note_style)
|
||||
end
|
||||
AddLabel(spwnCtrls, "respawn_cooldown_note2", {"oarc-set-respawn-note"}, my_note_style)
|
||||
|
||||
-- Display a list of people in the join queue for your base.
|
||||
if (global.ocfg.enable_shared_spawns and IsSharedSpawnActive(player)) then
|
||||
if ((global.sharedSpawns[player.name].joinQueue ~= nil) and
|
||||
(#global.sharedSpawns[player.name].joinQueue > 0)) then
|
||||
|
||||
|
||||
AddLabel(spwnCtrls, "drop_down_msg_lbl1", {"oarc-select-player-join-queue"}, my_label_style)
|
||||
spwnCtrls.add{name = "join_queue_dropdown",
|
||||
type = "drop-down",
|
||||
items = global.sharedSpawns[player.name].joinQueue}
|
||||
spwnCtrls.add{name = "accept_player_request",
|
||||
type = "button",
|
||||
caption={"oarc-accept"}}
|
||||
spwnCtrls.add{name = "reject_player_request",
|
||||
type = "button",
|
||||
caption={"oarc-reject"}}
|
||||
else
|
||||
AddLabel(spwnCtrls, "empty_join_queue_note1", {"oarc-no-player-join-reqs"}, my_note_style)
|
||||
end
|
||||
spwnCtrls.add{name = "join_queue_spacer", type = "label",
|
||||
caption=" "}
|
||||
if global.ocfg.enable_shared_spawns then
|
||||
if (global.uniqueSpawns[player.name] ~= nil) then
|
||||
-- This checkbox allows people to join your base when they first
|
||||
-- start the game.
|
||||
spwnCtrls.add{type="checkbox", name="accessToggle",
|
||||
caption={"oarc-spawn-allow-joiners"},
|
||||
state=IsSharedSpawnActive(player)}
|
||||
ApplyStyle(spwnCtrls["accessToggle"], my_fixed_width_style)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Sets the player's custom spawn point to their current location
|
||||
if ((game.tick - global.playerCooldowns[player.name].setRespawn) >
|
||||
(global.ocfg.respawn_cooldown_min * TICKS_PER_MINUTE)) then
|
||||
spwnCtrls.add{type="button", name="setRespawnLocation", caption={"oarc-set-respawn-loc"}}
|
||||
spwnCtrls["setRespawnLocation"].style.font = "default-small-semibold"
|
||||
|
||||
else
|
||||
AddLabel(spwnCtrls,"respawn_cooldown_note1",
|
||||
{"oarc-set-respawn-loc-cooldown", formattime((global.ocfg.respawn_cooldown_min * TICKS_PER_MINUTE)-(game.tick - global.playerCooldowns[player.name].setRespawn))}, my_note_style)
|
||||
end
|
||||
AddLabel(spwnCtrls, "respawn_cooldown_note2", {"oarc-set-respawn-note"}, my_note_style)
|
||||
|
||||
-- Display a list of people in the join queue for your base.
|
||||
if (global.ocfg.enable_shared_spawns and IsSharedSpawnActive(player)) then
|
||||
if ((global.sharedSpawns[player.name].joinQueue ~= nil) and
|
||||
(#global.sharedSpawns[player.name].joinQueue > 0)) then
|
||||
|
||||
|
||||
AddLabel(spwnCtrls, "drop_down_msg_lbl1", {"oarc-select-player-join-queue"}, my_label_style)
|
||||
spwnCtrls.add{name = "join_queue_dropdown",
|
||||
type = "drop-down",
|
||||
items = global.sharedSpawns[player.name].joinQueue}
|
||||
spwnCtrls.add{name = "accept_player_request",
|
||||
type = "button",
|
||||
caption={"oarc-accept"}}
|
||||
spwnCtrls.add{name = "reject_player_request",
|
||||
type = "button",
|
||||
caption={"oarc-reject"}}
|
||||
else
|
||||
AddLabel(spwnCtrls, "empty_join_queue_note1", {"oarc-no-player-join-reqs"}, my_note_style)
|
||||
end
|
||||
spwnCtrls.add{name = "join_queue_spacer", type = "label",
|
||||
caption=" "}
|
||||
end
|
||||
end
|
||||
|
||||
function SpawnCtrlGuiOptionsSelect(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
@ -664,6 +661,7 @@ function SpawnCtrlGuiOptionsSelect(event)
|
||||
SendBroadcastMsg({"oarc-stop-shared-base", player.name})
|
||||
end
|
||||
end
|
||||
FakeTabChangeEventOarcGui(player)
|
||||
end
|
||||
end
|
||||
|
||||
@ -678,10 +676,6 @@ function SpawnCtrlGuiClick(event)
|
||||
return
|
||||
end
|
||||
|
||||
if (elemName == "spwn_ctrls") then
|
||||
ExpandSpawnCtrlGui(player, event.tick)
|
||||
end
|
||||
|
||||
if (event.element.parent) then
|
||||
if (event.element.parent.name ~= "spwn_ctrl_panel") then
|
||||
return
|
||||
@ -692,7 +686,7 @@ function SpawnCtrlGuiClick(event)
|
||||
if (elemName == "setRespawnLocation") then
|
||||
if DoesPlayerHaveCustomSpawn(player) then
|
||||
ChangePlayerSpawn(player, player.position)
|
||||
ExpandSpawnCtrlGui(player, event.tick)
|
||||
FakeTabChangeEventOarcGui(player)
|
||||
player.print({"oarc-spawn-point-updated"})
|
||||
end
|
||||
end
|
||||
@ -703,7 +697,7 @@ function SpawnCtrlGuiClick(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-wait"})
|
||||
ExpandSpawnCtrlGui(player, event.tick)
|
||||
FakeTabChangeEventOarcGui(player)
|
||||
return
|
||||
end
|
||||
|
||||
@ -713,18 +707,18 @@ function SpawnCtrlGuiClick(event)
|
||||
if ((game.players[joinQueuePlayerChoice] == nil) or
|
||||
(not game.players[joinQueuePlayerChoice].connected)) then
|
||||
player.print({"oarc-selected-player-not-wait"})
|
||||
ExpandSpawnCtrlGui(player, event.tick)
|
||||
FakeTabChangeEventOarcGui(player)
|
||||
return
|
||||
end
|
||||
|
||||
if (elemName == "reject_player_request") then
|
||||
player.print({"oarc-reject-joiner", joinQueuePlayerChoice})
|
||||
SendMsg(joinQueuePlayerChoice, {"oarc-your-request-rejected"})
|
||||
ExpandSpawnCtrlGui(player, event.tick)
|
||||
FakeTabChangeEventOarcGui(player)
|
||||
|
||||
-- Close the waiting players menu
|
||||
if (game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu) then
|
||||
game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu.destroy()
|
||||
if (game.players[joinQueuePlayerChoice].gui.screen.join_shared_spawn_wait_menu) then
|
||||
game.players[joinQueuePlayerChoice].gui.screen.join_shared_spawn_wait_menu.destroy()
|
||||
DisplaySpawnOptions(game.players[joinQueuePlayerChoice])
|
||||
end
|
||||
|
||||
@ -751,8 +745,8 @@ function SpawnCtrlGuiClick(event)
|
||||
SendBroadcastMsg({"oarc-player-joining-base", joinQueuePlayerChoice, player.name})
|
||||
|
||||
-- Close the waiting players menu
|
||||
if (game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu) then
|
||||
game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu.destroy()
|
||||
if (game.players[joinQueuePlayerChoice].gui.screen.join_shared_spawn_wait_menu) then
|
||||
game.players[joinQueuePlayerChoice].gui.screen.join_shared_spawn_wait_menu.destroy()
|
||||
end
|
||||
|
||||
-- Spawn the player
|
||||
@ -764,8 +758,7 @@ function SpawnCtrlGuiClick(event)
|
||||
joiningPlayer.force = game.players[player.name].force
|
||||
|
||||
-- Create the button at the top left for setting respawn point and sharing base.
|
||||
CreateSpawnCtrlGui(joiningPlayer)
|
||||
ExpandSpawnCtrlGui(player, event.tick)
|
||||
AddOarcGuiTab(joiningPlayer, "Spawn Controls", CreateSpawnCtrlGuiTab)
|
||||
else
|
||||
SendBroadcastMsg({"oarc-player-left-while-joining", joinQueuePlayerChoice})
|
||||
end
|
||||
@ -775,18 +768,24 @@ end
|
||||
|
||||
-- Display the buddy spawn menu
|
||||
function DisplayBuddySpawnOptions(player)
|
||||
player.gui.center.add{name = "buddy_spawn_opts",
|
||||
local buddyGui = player.gui.screen.add{name = "buddy_spawn_opts",
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
caption={"oarc-buddy-spawn-options"}}
|
||||
local buddyGui = player.gui.center.buddy_spawn_opts
|
||||
buddyGui.auto_center = true
|
||||
buddyGui.style.maximal_width = SPAWN_GUI_MAX_WIDTH
|
||||
buddyGui.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
|
||||
|
||||
-- Warnings and explanations...
|
||||
AddLabel(buddyGui, "buddy_info_msg", {"oarc-buddy-spawn-instructions"}, my_label_style)
|
||||
-- AddSpacerLine(buddyGui, "buddy_info_spacer")
|
||||
AddSpacer(buddyGui)
|
||||
|
||||
-- The buddy spawning options.
|
||||
local buddySpawnFlow = buddyGui.add{name = "spawn_buddy_flow",
|
||||
type = "frame",
|
||||
direction="vertical",
|
||||
style = "bordered_frame"}
|
||||
|
||||
buddyList = {}
|
||||
for _,buddyName in pairs(global.waitingBuddies) do
|
||||
@ -795,20 +794,14 @@ function DisplayBuddySpawnOptions(player)
|
||||
end
|
||||
end
|
||||
|
||||
AddLabel(buddyGui, "drop_down_msg_lbl1", {"oarc-buddy-select-info"}, my_label_style)
|
||||
buddyGui.add{name = "waiting_buddies_dropdown",
|
||||
AddLabel(buddySpawnFlow, "drop_down_msg_lbl1", {"oarc-buddy-select-info"}, my_label_style)
|
||||
buddySpawnFlow.add{name = "waiting_buddies_dropdown",
|
||||
type = "drop-down",
|
||||
items = buddyList}
|
||||
buddyGui.add{name = "refresh_buddy_list",
|
||||
buddySpawnFlow.add{name = "refresh_buddy_list",
|
||||
type = "button",
|
||||
caption={"oarc-buddy-refresh"}}
|
||||
-- AddSpacerLine(buddyGui, "waiting_buddies_spacer")
|
||||
|
||||
-- The buddy spawning options.
|
||||
local buddySpawnFlow = buddyGui.add{name = "spawn_buddy_flow",
|
||||
type = "flow",
|
||||
direction="vertical"}
|
||||
|
||||
-- AddSpacerLine(buddySpawnFlow)
|
||||
|
||||
-- Allow picking of teams
|
||||
if (global.ocfg.enable_separate_teams) then
|
||||
@ -832,7 +825,7 @@ function DisplayBuddySpawnOptions(player)
|
||||
state=false}
|
||||
end
|
||||
|
||||
AddSpacer(buddyGui, "buddy_options_spacer")
|
||||
-- AddSpacerLine(buddySpawnFlow)
|
||||
buddySpawnFlow.add{name = "buddy_spawn_request_near",
|
||||
type = "button",
|
||||
caption={"oarc-buddy-spawn-near"},
|
||||
@ -841,18 +834,15 @@ function DisplayBuddySpawnOptions(player)
|
||||
type = "button",
|
||||
caption={"oarc-buddy-spawn-far"},
|
||||
style = "confirm_button"}
|
||||
AddSpacerLine(buddyGui, "buddy_spawn_spacer")
|
||||
|
||||
|
||||
|
||||
AddSpacer(buddyGui)
|
||||
buddyGui.add{name = "buddy_spawn_cancel",
|
||||
type = "button",
|
||||
caption={"oarc-cancel-return-to-previous"},
|
||||
style = "back_button"}
|
||||
|
||||
-- Some final notes
|
||||
AddSpacerLine(buddyGui, "note_spacer1")
|
||||
|
||||
AddSpacerLine(buddyGui)
|
||||
if (global.ocfg.max_players_shared_spawn > 0) then
|
||||
AddLabel(buddyGui, "buddy_max_players_lbl1",
|
||||
{"oarc-max-players-shared-spawn", global.ocfg.max_players_shared_spawn-1},
|
||||
@ -875,17 +865,17 @@ function BuddySpawnOptsGuiClick(event)
|
||||
return
|
||||
end
|
||||
|
||||
if (player.gui.center.buddy_spawn_opts == nil) then
|
||||
if (player.gui.screen.buddy_spawn_opts == nil) then
|
||||
return -- Gui event unrelated to this gui.
|
||||
end
|
||||
|
||||
-- Just refresh the buddy list dropdown values only.
|
||||
if (elemName == "refresh_buddy_list") then
|
||||
player.gui.center.buddy_spawn_opts.waiting_buddies_dropdown.clear_items()
|
||||
player.gui.screen.buddy_spawn_opts.waiting_buddies_dropdown.clear_items()
|
||||
|
||||
for _,buddyName in pairs(global.waitingBuddies) do
|
||||
if (player.name ~= buddyName) then
|
||||
player.gui.center.buddy_spawn_opts.waiting_buddies_dropdown.add_item(buddyName)
|
||||
player.gui.screen.buddy_spawn_opts.waiting_buddies_dropdown.add_item(buddyName)
|
||||
end
|
||||
end
|
||||
return
|
||||
@ -893,7 +883,7 @@ function BuddySpawnOptsGuiClick(event)
|
||||
|
||||
-- Handle the cancel button to exit this menu
|
||||
if (elemName == "buddy_spawn_cancel") then
|
||||
player.gui.center.buddy_spawn_opts.destroy()
|
||||
player.gui.screen.buddy_spawn_opts.destroy()
|
||||
DisplaySpawnOptions(player)
|
||||
|
||||
-- Remove them from the buddy list when they cancel
|
||||
@ -912,7 +902,7 @@ function BuddySpawnOptsGuiClick(event)
|
||||
if ((elemName == "buddy_spawn_request_near") or
|
||||
(elemName == "buddy_spawn_request_far")) then
|
||||
|
||||
local buddySpawnGui = player.gui.center.buddy_spawn_opts
|
||||
local buddySpawnGui = player.gui.screen.buddy_spawn_opts
|
||||
|
||||
local dropDownIndex = buddySpawnGui.waiting_buddies_dropdown.selected_index
|
||||
if (dropDownIndex > 0) then
|
||||
@ -933,7 +923,7 @@ function BuddySpawnOptsGuiClick(event)
|
||||
end
|
||||
if (not buddyIsStillWaiting) then
|
||||
player.print({"oarc-buddy-not-avail"})
|
||||
player.gui.center.buddy_spawn_opts.destroy()
|
||||
player.gui.screen.buddy_spawn_opts.destroy()
|
||||
DisplayBuddySpawnOptions(player)
|
||||
return
|
||||
end
|
||||
@ -959,13 +949,13 @@ function BuddySpawnOptsGuiClick(event)
|
||||
buddyChoice=buddyChoice,
|
||||
distChoice=elemName}
|
||||
|
||||
player.gui.center.buddy_spawn_opts.destroy()
|
||||
player.gui.screen.buddy_spawn_opts.destroy()
|
||||
|
||||
-- Display prompts to the players
|
||||
DisplayBuddySpawnWaitMenu(player)
|
||||
DisplayBuddySpawnRequestMenu(game.players[buddyChoice], player.name)
|
||||
if (game.players[buddyChoice].gui.center.buddy_spawn_opts ~= nil) then
|
||||
game.players[buddyChoice].gui.center.buddy_spawn_opts.destroy()
|
||||
if (game.players[buddyChoice].gui.screen.buddy_spawn_opts ~= nil) then
|
||||
game.players[buddyChoice].gui.screen.buddy_spawn_opts.destroy()
|
||||
end
|
||||
|
||||
-- Remove them from the buddy list while they make up their minds.
|
||||
@ -984,18 +974,18 @@ end
|
||||
|
||||
function DisplayBuddySpawnWaitMenu(player)
|
||||
|
||||
player.gui.center.add{name = "buddy_wait_menu",
|
||||
local sGui = player.gui.screen.add{name = "buddy_wait_menu",
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
caption={"oarc-waiting-for-buddy"}}
|
||||
local sGui = player.gui.center.buddy_wait_menu
|
||||
sGui.auto_center = true
|
||||
sGui.style.maximal_width = SPAWN_GUI_MAX_WIDTH
|
||||
sGui.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
|
||||
|
||||
-- Warnings and explanations...
|
||||
AddLabel(sGui, "warning_lbl1", {"oarc-wait-buddy-select-yes"}, my_warning_style)
|
||||
AddSpacer(sGui, "warning_spacer")
|
||||
AddSpacer(sGui)
|
||||
sGui.add{name = "cancel_buddy_wait_menu",
|
||||
type = "button",
|
||||
caption={"oarc-cancel-return-to-previous"}}
|
||||
@ -1012,22 +1002,22 @@ function BuddySpawnWaitMenuClick(event)
|
||||
return
|
||||
end
|
||||
|
||||
if (player.gui.center.buddy_wait_menu == nil) then
|
||||
if (player.gui.screen.buddy_wait_menu == nil) then
|
||||
return -- Gui event unrelated to this gui.
|
||||
end
|
||||
|
||||
-- Check if player is cancelling the request.
|
||||
if (elemName == "cancel_buddy_wait_menu") then
|
||||
player.gui.center.buddy_wait_menu.destroy()
|
||||
player.gui.screen.buddy_wait_menu.destroy()
|
||||
DisplaySpawnOptions(player)
|
||||
|
||||
local buddy = game.players[global.buddySpawnOptions[player.name].buddyChoice]
|
||||
|
||||
if (buddy.gui.center.buddy_request_menu ~= nil) then
|
||||
buddy.gui.center.buddy_request_menu.destroy()
|
||||
if (buddy.gui.screen.buddy_request_menu ~= nil) then
|
||||
buddy.gui.screen.buddy_request_menu.destroy()
|
||||
end
|
||||
if (buddy.gui.center.buddy_spawn ~= nil) then
|
||||
buddy.gui.center.buddy_spawn_opts.destroy()
|
||||
if (buddy.gui.screen.buddy_spawn ~= nil) then
|
||||
buddy.gui.screen.buddy_spawn_opts.destroy()
|
||||
end
|
||||
DisplaySpawnOptions(buddy)
|
||||
|
||||
@ -1042,11 +1032,11 @@ function DisplayBuddySpawnRequestMenu(player, requestingBuddyName)
|
||||
return
|
||||
end
|
||||
|
||||
player.gui.center.add{name = "buddy_request_menu",
|
||||
local sGui = player.gui.screen.add{name = "buddy_request_menu",
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
caption="Buddy Request!"}
|
||||
local sGui = player.gui.center.buddy_request_menu
|
||||
sGui.auto_center = true
|
||||
sGui.style.maximal_width = SPAWN_GUI_MAX_WIDTH
|
||||
sGui.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
|
||||
@ -1078,7 +1068,7 @@ function DisplayBuddySpawnRequestMenu(player, requestingBuddyName)
|
||||
|
||||
local requestText = {"", requestingBuddyName, {"oarc-buddy-txt-would-like"}, teamText, {"oarc-buddy-txt-next-to-you"}, moatText, distText}
|
||||
AddLabel(sGui, "note_lbl1", requestText, my_warning_style)
|
||||
AddSpacer(sGui, "note_spacer1")
|
||||
AddSpacer(sGui)
|
||||
|
||||
|
||||
sGui.add{name = "accept_buddy_request",
|
||||
@ -1102,7 +1092,7 @@ function BuddySpawnRequestMenuClick(event)
|
||||
return
|
||||
end
|
||||
|
||||
if (player.gui.center.buddy_request_menu == nil) then
|
||||
if (player.gui.screen.buddy_request_menu == nil) then
|
||||
return -- Gui event unrelated to this gui.
|
||||
end
|
||||
|
||||
@ -1121,7 +1111,7 @@ function BuddySpawnRequestMenuClick(event)
|
||||
player.print("Error! Invalid buddy info...")
|
||||
log("Error! Invalid buddy info...")
|
||||
|
||||
player.gui.center.buddy_request_menu.destroy()
|
||||
player.gui.screen.buddy_request_menu.destroy()
|
||||
DisplaySpawnOptions(player)
|
||||
end
|
||||
else
|
||||
@ -1131,11 +1121,11 @@ function BuddySpawnRequestMenuClick(event)
|
||||
-- Handle player accepted
|
||||
if (elemName == "accept_buddy_request") then
|
||||
|
||||
if (game.players[requesterName].gui.center.buddy_wait_menu ~= nil) then
|
||||
game.players[requesterName].gui.center.buddy_wait_menu.destroy()
|
||||
if (game.players[requesterName].gui.screen.buddy_wait_menu ~= nil) then
|
||||
game.players[requesterName].gui.screen.buddy_wait_menu.destroy()
|
||||
end
|
||||
if (player.gui.center.buddy_request_menu ~= nil) then
|
||||
player.gui.center.buddy_request_menu.destroy()
|
||||
if (player.gui.screen.buddy_request_menu ~= nil) then
|
||||
player.gui.screen.buddy_request_menu.destroy()
|
||||
end
|
||||
|
||||
-- Create a new spawn point
|
||||
@ -1181,8 +1171,8 @@ function BuddySpawnRequestMenuClick(event)
|
||||
SendBroadcastMsg(requesterName .. " and " .. player.name .. " are joining the game together!")
|
||||
|
||||
-- Create the button at the top left for setting respawn point and sharing base.
|
||||
CreateSpawnCtrlGui(player)
|
||||
CreateSpawnCtrlGui(game.players[requesterName])
|
||||
AddOarcGuiTab(player, "Spawn Controls", CreateSpawnCtrlGuiTab)
|
||||
AddOarcGuiTab(game.players[requesterName], "Spawn Controls", CreateSpawnCtrlGuiTab)
|
||||
|
||||
player.print({"oarc-please-wait"})
|
||||
player.print({"", {"oarc-please-wait"}, "!"})
|
||||
@ -1196,16 +1186,16 @@ function BuddySpawnRequestMenuClick(event)
|
||||
|
||||
-- Check if player is cancelling the request.
|
||||
if (elemName == "decline_buddy_request") then
|
||||
player.gui.center.buddy_request_menu.destroy()
|
||||
player.gui.screen.buddy_request_menu.destroy()
|
||||
DisplaySpawnOptions(player)
|
||||
|
||||
local requesterBuddy = game.players[requesterName]
|
||||
|
||||
if (requesterBuddy.gui.center.buddy_wait_menu ~= nil) then
|
||||
requesterBuddy.gui.center.buddy_wait_menu.destroy()
|
||||
if (requesterBuddy.gui.screen.buddy_wait_menu ~= nil) then
|
||||
requesterBuddy.gui.screen.buddy_wait_menu.destroy()
|
||||
end
|
||||
if (requesterBuddy.gui.center.buddy_spawn ~= nil) then
|
||||
requesterBuddy.gui.center.buddy_spawn_opts.destroy()
|
||||
if (requesterBuddy.gui.screen.buddy_spawn ~= nil) then
|
||||
requesterBuddy.gui.screen.buddy_spawn_opts.destroy()
|
||||
end
|
||||
DisplaySpawnOptions(requesterBuddy)
|
||||
|
||||
@ -1216,11 +1206,11 @@ end
|
||||
|
||||
function DisplayPleaseWaitForSpawnDialog(player, delay_seconds)
|
||||
|
||||
player.gui.center.add{name = "wait_for_spawn_dialog",
|
||||
local pleaseWaitGui = player.gui.screen.add{name = "wait_for_spawn_dialog",
|
||||
type = "frame",
|
||||
direction = "vertical",
|
||||
caption={"oarc-spawn-wait"}}
|
||||
local pleaseWaitGui = player.gui.center.wait_for_spawn_dialog
|
||||
pleaseWaitGui.auto_center = true
|
||||
pleaseWaitGui.style.maximal_width = SPAWN_GUI_MAX_WIDTH
|
||||
pleaseWaitGui.style.maximal_height = SPAWN_GUI_MAX_HEIGHT
|
||||
|
||||
|
39
lib/tag.lua
39
lib/tag.lua
@ -2,13 +2,6 @@
|
||||
-- Apr 2017
|
||||
-- Allows adding play tags
|
||||
|
||||
function CreateTagGui(event)
|
||||
local player = game.players[event.player_index]
|
||||
if mod_gui.get_button_flow(player).tag == nil then
|
||||
mod_gui.get_button_flow(player).add{name="tag", type="button", caption="Tag", style=mod_gui.button_style}
|
||||
end
|
||||
end
|
||||
|
||||
-- Tag list
|
||||
local roles = {
|
||||
{display_name = "[Solo]"},
|
||||
@ -26,37 +19,27 @@ local roles = {
|
||||
{display_name = "[Rocket]"},
|
||||
{display_name = "[AFK]"}}
|
||||
|
||||
local function ExpandTagGui(player)
|
||||
local frame = mod_gui.get_frame_flow(player)["tag-panel"]
|
||||
if (frame) then
|
||||
frame.destroy()
|
||||
else
|
||||
local frame = mod_gui.get_frame_flow(player).add{type="frame", name="tag-panel", caption="What are you doing:", direction = "vertical"}
|
||||
for _, role in pairs(roles) do
|
||||
frame.add{type="button", caption=role.display_name, name=role.display_name}
|
||||
end
|
||||
if (player.admin) then
|
||||
frame.add{type="button", caption="[Admin]", name="admin"}
|
||||
frame.add{type="button", caption="[Moderator]", name="moderator"}
|
||||
end
|
||||
frame.add{type="button", caption="Clear", name="clear_btn"}
|
||||
function CreateTagGuiTab(tab_container, player)
|
||||
for _, role in pairs(roles) do
|
||||
tab_container.add{type="button", caption=role.display_name, name=role.display_name}
|
||||
end
|
||||
if (player.admin) then
|
||||
tab_container.add{type="button", caption="[Admin]", name="admin"}
|
||||
tab_container.add{type="button", caption="[Moderator]", name="moderator"}
|
||||
end
|
||||
tab_container.add{type="button", caption="Clear", name="clear_btn"}
|
||||
end
|
||||
|
||||
function TagGuiClick(event)
|
||||
function TagGuiClick(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name == "tag") then
|
||||
ExpandTagGui(player)
|
||||
end
|
||||
|
||||
if (name == "clear_btn") then
|
||||
if (name == "clear_btn") then
|
||||
player.tag = ""
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for _, role in pairs(roles) do
|
||||
if (name == role.display_name) then
|
||||
player.tag = role.display_name
|
||||
|
Loading…
x
Reference in New Issue
Block a user