mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Added changes requested by mark
This commit is contained in:
@@ -33,10 +33,10 @@ 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 against you' end
|
||||
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 against you'
|
||||
return 'You have '..count..' warnings'
|
||||
end
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ end
|
||||
|
||||
--- 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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -29,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
|
||||
@@ -43,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
|
||||
|
||||
@@ -284,7 +284,7 @@ Gui.element(function(_, parent)
|
||||
-- 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, enum[preference], preference_meta.value_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
|
||||
@@ -319,8 +319,10 @@ Gui.element(function(_, parent)
|
||||
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, format_number(value or 0), metadata.value_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
|
||||
|
||||
@@ -37,7 +37,7 @@ 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]
|
||||
|
||||
Reference in New Issue
Block a user