Merge pull request #164 from Cooldude2606/feature/data-tab

Added Data tab to info
This commit is contained in:
Cooldude2606
2020-06-06 02:01:45 +01:00
committed by GitHub
17 changed files with 343 additions and 59 deletions

View File

@@ -5,7 +5,7 @@ local e = defines.events -- order as per lua api as it was easier just to go dow
return {
Playtime = true, --- @setting Playtime If playtime is tracked for a player, play time measured in minutes
AfkTime = true, --- @setting AfkTime If afk time is tracked for a player, play time measured in minutes, afk is once a player does nothing for 5 minutes
DistanceTraveled = true, --- @setting DistanceTraveled If distance traveled is checked, only counts if not afk
DistanceTravelled = true, --- @setting DistanceTravelled If distance Travelled is checked, only counts if not afk
MachinesRemoved = true, --- @setting MachinesRemoved If removed machines are tracked, includes marked for decon and player mined entity
TreesDestroyed = true, --- @setting OreMined If ore mined is tracked for a player, includes marked for decon and player mined entity but only trees
OreMined = true, --- @setting OreMined If ore mined is tracked for a player, includes player mined entity but only ore
@@ -22,10 +22,25 @@ return {
TilesBuilt = e.on_player_built_tile,
ItemsCrafted = e.on_player_crafted_item,
MapsPlayed = e.on_player_created,
DeconstructionPlanerUsed = e.on_player_deconstructed_area,
DeconstructionPlannerUsed = e.on_player_deconstructed_area,
Deaths = e.on_player_died,
JoinCount = e.on_player_joined_game,
TilesRemoved = e.on_player_mined_tile,
CapsulesUsed = e.on_player_used_capsule
CapsulesUsed = e.on_player_used_capsule,
EntityRepaired= e.on_player_repaired_entity
},
display_order = { --- @setting display_order The order that the statistics should be shown in when in a gui or command
'Playtime', 'AfkTime',
'MapsPlayed', 'JoinCount',
'ChatMessages', 'CommandsUsed',
'RocketsLaunched', 'ResearchCompleted',
'MachinesBuilt', 'MachinesRemoved',
'TilesBuilt', 'TilesRemoved',
'TreesDestroyed', 'OreMined',
'ItemsCrafted', 'ItemsPickedUp',
'Kills', 'Deaths',
'DamageDealt', 'DistanceTravelled',
'CapsulesUsed', 'EntityRepaired',
'DeconstructionPlannerUsed', 'MapTagsMade',
}
}

View File

@@ -56,6 +56,11 @@ local DataSavingPreference = PlayerData:combine('DataSavingPreference')
local PreferenceEnum = { 'All', 'Statistics', 'Settings', 'Required' }
for k,v in ipairs(PreferenceEnum) do PreferenceEnum[v] = k end
DataSavingPreference:set_default('All')
DataSavingPreference:set_metadata{
name = {'expcore-data.preference'},
tooltip = {'expcore-data.preference-tooltip'},
value_tooltip ={'expcore-data.preference-value-tooltip'}
}
--- Sets your data saving preference
-- @command set-data-preference

View File

@@ -45,9 +45,10 @@ removed=__1__ has one or more reports removed by __2__.
[expcom-warnings]
received=__1__ received a warning from __2__ for __3__.
player=__1__ has __2__ warnings and __3__/__4__ script warnings.
list-tilte=The following player have this many warnings (and this many script warnings):
player-detail=__1__ gave warning for: __2__
list-title=The following players have this many warnings (and this many script warnings):
list=__1__: __2__ (__3__/__4__)
cleared=__1__ had all they warnings cleared by __2__.
cleared=__1__ had all their warnings cleared by __2__.
[expcom-spawn]
unavailable=They was a problem getting you to spawn, please try again later.

View File

@@ -4,3 +4,80 @@ message-set=Your join message has been updated.
[quickbar]
saved=Your quickbar filters have been saved.
[exp-required]
Warnings=Warnings
Warnings-tooltip=The total number of warnings you have received from staff
Warnings-value-tooltip=The total number of warnings you have received from staff
[exp-settings]
Colour=Colour
Colour-tooltip=Your player colour
Colour-value-tooltip=Change by using /color
JoinMessage=Join Message
JoinMessage-tooltip=The message displayed when you join
JoinMessage-value-tooltip=Change by using /join-message
QuickbarFilters=Quickbar Filters
QuickbarFilters-tooltip=The filters on your quickbar
QuickbarFilters-value-tooltip=Change by using /save-quickbar
UsesAlt=Alt View
UsesAlt-tooltip=Whether you use alt view when you play
UsesAlt-value-tooltip=Change by pressing __CONTROL__show-info__
UsesServerUps=Server UPS
UsesServerUps-tooltip=Whether the current server UPS is shown
UsesServerUps-value-tooltip=Change by using /server-ups
Tag=Player Tag
Tag-tooltip=The tag shown after your name
Tag-value-tooltip=Change by using /tag
Bonus=Player Bonus
Bonus-tooltip=The bonus given to your character
Bonus-value-tooltip=Change by using /bonus
[exp-statistics]
MapsPlayed=Maps Played
MapsPlayed-tooltip=The number of unique maps you have played on
JoinCount=Join Count
JoinCount-tooltip=The number of times you have joined our servers
Playtime=Playtime
Playtime-tooltip=The amount of time you have spent on our servers
AfkTime=AFK Time
AfkTime-tooltip=The amount of time you have been AFK on our servers
ChatMessages=Messages
ChatMessages-tooltip=The number of messages you have sent in chat
CommandsUsed=Commands
CommandsUsed-tooltip=The number of commands you have used
RocketsLaunched=Rockets Launched
RocketsLaunched-tooltip=The number of rockets launched while you were online
ResearchCompleted=Research Completed
ResearchCompleted-tooltip=The number of research projects completed while you were online
MachinesBuilt=Machines Built
MachinesBuilt-tooltip=The number of machines you have built
MachinesRemoved=Machines Removed
MachinesRemoved-tooltip=The number of machines you have removed
TilesBuilt=Tiles Placed
TilesBuilt-tooltip=The number of tiles you have placed
TilesRemoved=Tiles Removed
TilesRemoved-tooltip=The number of tiles you have removed
TreesDestroyed=Trees Destroyed
TreesDestroyed-tooltip=The number of trees you have destroyed
OreMined=Ore Mined
OreMined-tooltip=The amount of ore you have mined
ItemsCrafted=Items Crafted
ItemsCrafted-tooltip=The number of items you have crafted
ItemsPickedUp=Items Picked Up
ItemsPickedUp-tooltip=The number of items you have picked up
Kills=Kills
Kills-tooltip=The number of biters and biter bases you have squished
Deaths=Deaths
Deaths-tooltip=The number of times you have died
DamageDealt=Damage Dealt
DamageDealt-tooltip=The amount of damage you have dealt to other forces
DistanceTravelled=Distance Travelled
DistanceTravelled-tooltip=The total distance in tiles that you have travelled
CapsulesUsed=Capsules Used
CapsulesUsed-tooltip=The number of capsules you have used
EntityRepaired=Machines Repaired
EntityRepaired-tooltip=The number of machines which you have repaired
DeconstructionPlannerUsed=Decon Planner Used
DeconstructionPlannerUsed-tooltip=The number of times you have used the deconstruction planner
MapTagsMade=Map Tags Created
MapTagsMade-tooltip=The number of map tags you have created

View File

@@ -43,3 +43,10 @@ get-preference=You data saving preference is __1__. Use /set-preference to chang
get-data=Your player data has been writen to file, location: factorio/script_output/expgaming_player_data.json
data-failed=Your player data has failed to load. Any changes to your data will not be saved.
data-restore=Your player data has been restored and changes will now save when you leave.
preference=Saving Preference
preference-tooltip=Which categories will be saved when you leave the game
preference-value-tooltip=Change by using /set-preference
preference-All=All data will be saved
preference-Statistics=Only statistics, settings, and required data will be saved
preference-Settings=Only settings and required data will be saved
preference-Required=Only required data will be saved

View File

@@ -156,3 +156,11 @@ backers-board=Board Members and Senior Backers
backers-staff=Staff Members
backers-backers=Sponsors and Supporters
backers-active=Active Players
data-tab=Data
data-tooltip=All of your stored player data
data-general=Our servers will save your player data so that we can sync it between servers. All of your data can be found below, if you wish to save a copy locally then use /save-data. If you want to change what data is saved then use /set-preference.
data-settings=Settings
data-statistics=Statistics
data-required=Required
data-misc=Miscellaneous
data-format=__1____2__

View File

@@ -36,12 +36,14 @@ Commands.new_command('get-warnings', 'Gets the number of warnings a player has.
local warnings = Warnings.get_warnings(player)
local script_warnings = Warnings.get_script_warnings(player)
local player_name_color = format_chat_player_name(player)
Commands.print{'expcom-warnings.player', player_name_color, warnings, script_warnings, config.temp_warning_limit}
Commands.print{'expcom-warnings.player', player_name_color, #warnings, #script_warnings, config.temp_warning_limit}
for _, warning in ipairs(warnings) do
Commands.print{'expcom-warnings.player-detail', format_chat_player_name(warning.by_player_name), warning.reason}
end
else
local rtn = {}
local user_warnings = Warnings.user_warnings
local user_script_warnings = Warnings.user_script_warnings
for player_name, warnings in pairs(user_warnings) do
for player_name, warnings in pairs(Warnings.user_warnings:get_all()) do
rtn[player_name] = {#warnings, 0}
end
for player_name, warnings in pairs(user_script_warnings) do
@@ -50,7 +52,7 @@ Commands.new_command('get-warnings', 'Gets the number of warnings a player has.
end
rtn[player_name][2] = #warnings
end
Commands.print{'expcom-warnings.list-tilte'}
Commands.print{'expcom-warnings.list-title'}
for player_name, warnings in pairs(rtn) do
local player_name_color = format_chat_player_name(player_name)
Commands.print{'expcom-warnings.list', player_name_color, warnings[1], warnings[2], config.temp_warning_limit}

View File

@@ -28,8 +28,20 @@ local config = require 'config.warnings' --- @dep config.warnings
local valid_player = Game.get_player_from_any
--- Stores the quickbar filters for a player
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local PlayerWarnings = PlayerData.Required:combine('Warnings')
PlayerWarnings:set_metadata{
stringify = function(value)
if not value then return 'You have no warnings' end
local count = 0
for _ in pairs(value) do count = count + 1 end
return 'You have '..count..' warnings'
end
}
local Warnings = {
user_warnings={},
user_warnings=PlayerWarnings,
user_script_warnings={},
events = {
--- When a warning is added to a player
@@ -52,7 +64,7 @@ local Warnings = {
-- @tparam string reason the reason that the player was given a warning
-- @tparam number warning_count the new number of warnings that the player has
on_script_warning_added = script.generate_event_name(),
--- When a warning is remnoved from a player, by the script
--- When a warning is removed from a player, by the script
-- @event on_script_warning_removed
-- @tparam number player_index the index of the player who is having the warning removed
-- @tparam number warning_count the new number of warnings that the player has
@@ -60,30 +72,24 @@ local Warnings = {
}
}
local user_warnings = Warnings.user_warnings
local user_script_warnings = Warnings.user_script_warnings
Global.register({
user_warnings = user_warnings,
user_script_warnings = user_script_warnings
}, function(tbl)
Warnings.user_warnings = tbl.user_warnings
Warnings.user_script_warnings = tbl.user_script_warnings
user_warnings = Warnings.user_warnings
user_script_warnings = Warnings.user_script_warnings
Global.register(user_script_warnings, function(tbl)
Warnings.user_script_warnings = tbl
user_script_warnings = tbl
end)
--- Gets an array of warnings that the player has, always returns a list even if emtpy
--- Gets an array of warnings that the player has, always returns a list even if empty
-- @tparam LuaPlayer player the player to get the warning for
-- @treturn table an array of all the warnings on this player, contains tick, by_player_name and reason
function Warnings.get_warnings(player)
return user_warnings[player.name] or {}
return PlayerWarnings:get(player.name, {})
end
--- Gets the number of warnings that a player has on them
-- @tparam LuaPlayer player the player to count the warnings for
-- @treturn number the number of warnings that the player has
function Warnings.count_warnings(player)
local warnings = user_warnings[player.name] or {}
local warnings = PlayerWarnings:get(player.name, {})
return #warnings
end
@@ -97,21 +103,23 @@ function Warnings.add_warning(player, by_player_name, reason)
if not player then return end
if not by_player_name then return end
reason = reason or 'Non given.'
reason = reason or 'None given.'
local warnings = user_warnings[player.name]
if not warnings then
warnings = {}
user_warnings[player.name] = warnings
end
local warning_count
PlayerWarnings:update(player.name, function(_, warnings)
local warning = {
by_player_name = by_player_name,
reason = reason
}
table.insert(warnings, {
tick = game.tick,
by_player_name = by_player_name,
reason = reason
})
local warning_count = #warnings
if not warnings then
warning_count = 1
return {warning}
else
table.insert(warnings, warning)
warning_count = #warnings
end
end)
script.raise_event(Warnings.events.on_warning_added, {
name = Warnings.events.on_warning_added,
@@ -122,7 +130,7 @@ function Warnings.add_warning(player, by_player_name, reason)
reason = reason
})
local action = config.actions[#warnings]
local action = config.actions[warning_count]
if action then
local _type = type(action)
if _type == 'function' then
@@ -156,7 +164,7 @@ local function warning_removed_event(player, warning_by_name, removed_by_name, w
})
end
--- Removes a warning from a player, always removes the earlyist warning, fifo
--- Removes a warning from a player, always removes the earliest warning, fifo
-- @tparam LuaPlayer player the player to remove a warning from
-- @tparam string by_player_name the name of the player who is doing the action
-- @treturn number the number of warnings that the player has
@@ -165,14 +173,17 @@ function Warnings.remove_warning(player, by_player_name)
if not player then return end
if not by_player_name then return end
local warnings = user_warnings[player.name]
if not warnings then return end
local warning, warning_count
PlayerWarnings:update(player.name, function(_, warnings)
if not warnings then return end
warning = table.remove(warnings, 1)
warning_count = #warnings
end)
local warning = table.remove(warnings, 1)
if not warning then return end
warning_removed_event(player, warning.by_player_name, by_player_name, warning_count)
warning_removed_event(player, warning.by_player_name, by_player_name, #warnings)
return #warnings
return warning_count
end
--- Removes all warnings from a player, will trigger remove event for each warning
@@ -184,7 +195,7 @@ function Warnings.clear_warnings(player, by_player_name)
if not player then return end
if not by_player_name then return end
local warnings = user_warnings[player.name]
local warnings = PlayerWarnings:get(player)
if not warnings then return end
local warning_count = #warnings
@@ -192,7 +203,7 @@ function Warnings.clear_warnings(player, by_player_name)
warning_removed_event(player, warning.by_player_name, by_player_name, warning_count-n)
end
user_warnings[player.name] = nil
PlayerWarnings:remove(player)
return true
end
@@ -249,9 +260,9 @@ function Warnings.add_script_warning(player, reason)
return warning_count
end
--- Script warning removed event tigger due to it being looped in clear script warnings
--- Script warning removed event trigger due to it being looped in clear script warnings
-- @tparam LuaPlayer player the player who is having a script warning removed
-- @tparam number warning_count the number of warning that the player has
-- @tparam number warning_count the number of warnings that the player has
local function script_warning_removed_event(player, warning_count)
script.raise_event(Warnings.events.on_script_warning_removed, {
name = Warnings.events.on_script_warning_removed,

View File

@@ -3,10 +3,13 @@
local Event = require 'utils.event' ---@dep utils.event
--- Stores the join message that the player have
--- Stores the visible state of alt mode
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local UsesAlt = PlayerData.Settings:combine('UsesAlt')
UsesAlt:set_default(false)
UsesAlt:set_metadata{
stringify = function(value) return value and 'Visible' or 'Hidden' end
}
--- When your data loads apply alt view if you have it enabled
UsesAlt:on_load(function(player_name, uses_alt)

View File

@@ -12,6 +12,14 @@ require 'config.expcore.command_general_parse'
--- Stores the bonus for the player
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local PlayerBonus = PlayerData.Settings:combine('Bonus')
PlayerBonus:set_default(0)
PlayerBonus:set_metadata{
permission = 'command/bonus',
stringify = function(value)
if not value or value == 0 then return 'None set' end
return (value*100)..'%'
end
}
--- Apply a bonus amount to a player
local function apply_bonus(player, amount)

View File

@@ -8,6 +8,9 @@ require 'config.expcore.command_general_parse'
--- Stores the join message that the player have
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local CustomMessages = PlayerData.Settings:combine('JoinMessage')
CustomMessages:set_metadata{
permission = 'command/join-message'
}
--- When a players data loads show their message
CustomMessages:on_load(function(player_name, player_message)

View File

@@ -8,6 +8,13 @@ local config = require 'config.preset_player_colours' --- @dep config.preset_pla
--- Stores the colour that the player wants
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local PlayerColours = PlayerData.Settings:combine('Colour')
PlayerColours:set_metadata{
stringify = function(value)
if not value then return 'None set' end
local c = value[1]
return string.format('Red: %d Green: %d Blue: %d', c[1], c[2], c[3])
end
}
--- Used to compact player colours to take less space
local floor = math.floor

View File

@@ -9,6 +9,15 @@ local config = require 'config.preset_player_quickbar' --- @dep config.preset_pl
--- Stores the quickbar filters for a player
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local PlayerFilters = PlayerData.Settings:combine('QuickbarFilters')
PlayerFilters:set_metadata{
permission = 'command/save-quickbar',
stringify = function(value)
if not value then return 'No filters set' end
local count = 0
for _ in pairs(value) do count = count + 1 end
return count..' filters set'
end
}
--- Loads your quickbar preset
PlayerFilters:on_load(function(player_name, filters)

View File

@@ -1,6 +1,7 @@
local Event = require 'utils.event' ---@dep utils.event
local config = require 'config.statistics' ---@dep config.statistics
local format_time = _C.format_time
local floor = math.floor
local afk_required = 5*3600 -- 5 minutes
@@ -8,6 +9,9 @@ local afk_required = 5*3600 -- 5 minutes
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local AllPlayerData = PlayerData.All
local Statistics = PlayerData.Statistics
Statistics:set_metadata{
display_order = config.display_order
}
--- Update your statistics with any which happened before the data was valid
Statistics:on_load(function(player_name, player_statistics)
@@ -26,11 +30,20 @@ Statistics:on_load(function(player_name, player_statistics)
return player_statistics
end)
--- Used to format time in minute format
local function format_minutes(value)
return format_time(value*3600, {
long = true,
hours = true,
minutes = true
})
end
--- Add Playtime and AfkTime if it is enabled
if config.Playtime or config.AfkTime then
local playtime, afk_time
if config.Playtime then playtime = Statistics:combine('Playtime') end
if config.AfkTime then afk_time = Statistics:combine('AfkTime') end
if config.Playtime then playtime = Statistics:combine('Playtime') playtime:set_metadata{stringify=format_minutes} end
if config.AfkTime then afk_time = Statistics:combine('AfkTime') afk_time:set_metadata{stringify=format_minutes} end
Event.on_nth_tick(3600, function()
if game.tick == 0 then return end
for _, player in pairs(game.connected_players) do
@@ -40,9 +53,10 @@ if config.Playtime or config.AfkTime then
end)
end
--- Add DistanceTraveled if it is enabled
if config.DistanceTraveled then
local stat = Statistics:combine('DistanceTraveled')
--- Add DistanceTravelled if it is enabled
if config.DistanceTravelled then
local stat = Statistics:combine('DistanceTravelled')
stat:set_metadata{unit=' tiles'}
Event.add(defines.events.on_player_changed_position, function(event)
local player = game.players[event.player_index]
if not player.valid or not player.connected or player.afk_time > afk_required then return end
@@ -85,7 +99,7 @@ if config.DamageDealt then
end
--- Add Kills if it is enabled
if config.DamageDealt then
if config.Kills then
local stat = Statistics:combine('Kills')
Event.add(defines.events.on_entity_died, function(event)
local character = event.cause -- Check character is valid

View File

@@ -11,6 +11,9 @@ require 'config.expcore.command_role_parse'
--- Stores the tag for a player
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local PlayerTags = PlayerData.Settings:combine('Tag')
PlayerTags:set_metadata{
permission = 'command/tag'
}
--- When your tag is updated then apply the changes
PlayerTags:on_update(function(player_name, player_tag)

View File

@@ -7,9 +7,11 @@
local Gui = require 'expcore.gui' --- @dep expcore.gui
local Roles = require 'expcore.roles' --- @dep expcore.roles
local Commands = require 'expcore.commands' --- @dep expcore.commands
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local Event = require 'utils.event' --- @dep utils.event
local Game = require 'utils.game' --- @dep utils.game
local format_time = _C.format_time --- @dep expcore.common
local format_number = require('util').format_number --- @dep util
local tabs = {}
local function Tab(caption, tooltip, element_define)
@@ -259,6 +261,97 @@ Gui.element(function(_, parent)
return container
end))
--- Content area for the player data tab
-- @element commands_content
Tab({'readme.data-tab'}, {'readme.data-tooltip'},
Gui.element(function(_, parent)
local container = parent.add{ type='flow', direction='vertical' }
local player = Gui.get_player_from_element(parent)
local player_name = player.name
local enum = PlayerData.PreferenceEnum
local preference = PlayerData.DataSavingPreference:get(player_name)
local preference_meta = PlayerData.DataSavingPreference.metadata
preference = enum[preference]
-- Add the title and description to the content
Gui.title_label(container, title_width, {'readme.data-tab'})
Gui.centered_label(container, frame_width, {'readme.data-general'})
Gui.bar(container)
container.add{ type='flow' }
local scroll_pane = title_table_scroll(container)
-- Add the required area
local required = title_table(scroll_pane, 250, {'readme.data-required'}, 2)
Gui.centered_label(required, 150, preference_meta.name, preference_meta.tooltip)
Gui.centered_label(required, 420, {'expcore-data.preference-'..enum[preference]}, preference_meta.value_tooltip)
for name, child in pairs(PlayerData.Required.children) do
local metadata = child.metadata
local value = child:get(player_name)
if value ~= nil or metadata.show_always then
if metadata.stringify then value = metadata.stringify(value) end
Gui.centered_label(required, 150, metadata.name or {'exp-required.'..name}, metadata.tooltip or {'exp-required.'..name..'-tooltip'})
Gui.centered_label(required, 420, tostring(value), metadata.value_tooltip or {'exp-required.'..name..'-value-tooltip'})
end
end
-- Add the settings area
if preference <= enum.Settings then
local settings = title_table(scroll_pane, 255, {'readme.data-settings'}, 2)
for name, child in pairs(PlayerData.Settings.children) do
local metadata = child.metadata
local value = child:get(player_name)
if not metadata.permission or Roles.player_allowed(player, metadata.permission) then
if metadata.stringify then value = metadata.stringify(value) end
if value == nil then value = 'None set' end
Gui.centered_label(settings, 150, metadata.name or {'exp-settings.'..name}, metadata.tooltip or {'exp-settings.'..name..'-tooltip'})
Gui.centered_label(settings, 420, tostring(value), metadata.value_tooltip or {'exp-settings.'..name..'-value-tooltip'})
end
end
end
-- Add the statistics area
if preference <= enum.Statistics then
local count = 4
local statistics = title_table(scroll_pane, 250, {'readme.data-statistics'}, 4)
for _, name in pairs(PlayerData.Statistics.metadata.display_order) do
local child = PlayerData.Statistics[name]
local metadata = child.metadata
local value = child:get(player_name)
if value ~= nil or metadata.show_always then
count = count - 2
if metadata.stringify then value = metadata.stringify(value)
else value = format_number(value or 0) end
Gui.centered_label(statistics, 150, metadata.name or {'exp-statistics.'..name}, metadata.tooltip or {'exp-statistics.'..name..'-tooltip'})
Gui.centered_label(statistics, 130, {'readme.data-format', value, metadata.unit or ''}, metadata.value_tooltip or {'exp-statistics.'..name..'-tooltip'})
end
end
if count > 0 then for i = 1, count do Gui.centered_label(statistics, 140) end end
end
-- Add the misc area
local skip = {DataSavingPreference=true, Settings=true, Statistics=true, Required=true}
local count = 0; for _ in pairs(PlayerData.All.children) do count = count + 1 end
if preference <= enum.All and count > 4 then
local misc = title_table(scroll_pane, 232, {'readme.data-misc'}, 2)
for name, child in pairs(PlayerData.All.children) do
if not skip[name] then
local metadata = child.metadata
local value = child:get(player_name)
if value ~= nil or metadata.show_always then
if metadata.stringify then value = metadata.stringify(value) end
Gui.centered_label(misc, 150, metadata.name or name, metadata.tooltip)
Gui.centered_label(misc, 420, tostring(value), metadata.value_tooltip)
end
end
end
end
return container
end))
--- Main readme container for the center flow
-- @element readme
local readme_toggle

View File

@@ -8,6 +8,15 @@ local Gui = require 'expcore.gui' --- @dep expcore.gui
local Event = require 'utils.event' --- @dep utils.event
local Commands = require 'expcore.commands' --- @dep expcore.commands
--- Stores the visible state of server ups
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
local UsesServerUps = PlayerData.Settings:combine('UsesServerUps')
UsesServerUps:set_default(false)
UsesServerUps:set_metadata{
permission = 'command/server-ups',
stringify = function(value) return value and 'Visible' or 'Hidden' end
}
--- Label to show the server ups
-- @element server_ups
local server_ups =
@@ -19,9 +28,17 @@ Gui.element{
font = 'default-game'
}
--- Change the visible state when your data loads
UsesServerUps:on_load(function(player_name, visible)
local player = game.players[player_name]
local label = player.gui.screen[server_ups.name]
if not global.ext or not global.ext.server_ups then visible = false end
label.visible = visible
end)
--- Toggles if the server ups is visbile
-- @command server-ups
Commands.new_command('server-ups', 'Toggle the server ups display')
Commands.new_command('server-ups', 'Toggle the server UPS display')
:add_alias('sups', 'ups')
:register(function(player)
local label = player.gui.screen[server_ups.name]
@@ -29,6 +46,7 @@ Commands.new_command('server-ups', 'Toggle the server ups display')
return Commands.error{'expcom-server-ups.no-ext'}
end
label.visible = not label.visible
UsesServerUps:set(player, label.visible)
end)
-- Set the location of the label