mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 21:01:39 +09:00
Merge pull request #164 from Cooldude2606/feature/data-tab
Added Data tab to info
This commit is contained in:
@@ -5,7 +5,7 @@ local e = defines.events -- order as per lua api as it was easier just to go dow
|
|||||||
return {
|
return {
|
||||||
Playtime = true, --- @setting Playtime If playtime is tracked for a player, play time measured in minutes
|
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
|
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
|
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
|
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
|
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,
|
TilesBuilt = e.on_player_built_tile,
|
||||||
ItemsCrafted = e.on_player_crafted_item,
|
ItemsCrafted = e.on_player_crafted_item,
|
||||||
MapsPlayed = e.on_player_created,
|
MapsPlayed = e.on_player_created,
|
||||||
DeconstructionPlanerUsed = e.on_player_deconstructed_area,
|
DeconstructionPlannerUsed = e.on_player_deconstructed_area,
|
||||||
Deaths = e.on_player_died,
|
Deaths = e.on_player_died,
|
||||||
JoinCount = e.on_player_joined_game,
|
JoinCount = e.on_player_joined_game,
|
||||||
TilesRemoved = e.on_player_mined_tile,
|
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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,11 @@ local DataSavingPreference = PlayerData:combine('DataSavingPreference')
|
|||||||
local PreferenceEnum = { 'All', 'Statistics', 'Settings', 'Required' }
|
local PreferenceEnum = { 'All', 'Statistics', 'Settings', 'Required' }
|
||||||
for k,v in ipairs(PreferenceEnum) do PreferenceEnum[v] = k end
|
for k,v in ipairs(PreferenceEnum) do PreferenceEnum[v] = k end
|
||||||
DataSavingPreference:set_default('All')
|
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
|
--- Sets your data saving preference
|
||||||
-- @command set-data-preference
|
-- @command set-data-preference
|
||||||
|
|||||||
@@ -45,9 +45,10 @@ removed=__1__ has one or more reports removed by __2__.
|
|||||||
[expcom-warnings]
|
[expcom-warnings]
|
||||||
received=__1__ received a warning from __2__ for __3__.
|
received=__1__ received a warning from __2__ for __3__.
|
||||||
player=__1__ has __2__ warnings and __3__/__4__ script warnings.
|
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__)
|
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]
|
[expcom-spawn]
|
||||||
unavailable=They was a problem getting you to spawn, please try again later.
|
unavailable=They was a problem getting you to spawn, please try again later.
|
||||||
|
|||||||
@@ -3,4 +3,81 @@ greet=[color=0,1,0] Welcome to explosive gaming community server! If you like th
|
|||||||
message-set=Your join message has been updated.
|
message-set=Your join message has been updated.
|
||||||
|
|
||||||
[quickbar]
|
[quickbar]
|
||||||
saved=Your quickbar filters have been saved.
|
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
|
||||||
@@ -42,4 +42,11 @@ set-preference=You data saving preference has been set to __1__. Existing data w
|
|||||||
get-preference=You data saving preference is __1__. Use /set-preference to change this. Use /save-data to get a local copy of your data.
|
get-preference=You data saving preference is __1__. Use /set-preference to change this. Use /save-data to get a local copy of your data.
|
||||||
get-data=Your player data has been writen to file, location: factorio/script_output/expgaming_player_data.json
|
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-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.
|
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
|
||||||
@@ -155,4 +155,12 @@ backers-management=Administrators
|
|||||||
backers-board=Board Members and Senior Backers
|
backers-board=Board Members and Senior Backers
|
||||||
backers-staff=Staff Members
|
backers-staff=Staff Members
|
||||||
backers-backers=Sponsors and Supporters
|
backers-backers=Sponsors and Supporters
|
||||||
backers-active=Active Players
|
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__
|
||||||
@@ -36,12 +36,14 @@ Commands.new_command('get-warnings', 'Gets the number of warnings a player has.
|
|||||||
local warnings = Warnings.get_warnings(player)
|
local warnings = Warnings.get_warnings(player)
|
||||||
local script_warnings = Warnings.get_script_warnings(player)
|
local script_warnings = Warnings.get_script_warnings(player)
|
||||||
local player_name_color = format_chat_player_name(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
|
else
|
||||||
local rtn = {}
|
local rtn = {}
|
||||||
local user_warnings = Warnings.user_warnings
|
|
||||||
local user_script_warnings = Warnings.user_script_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}
|
rtn[player_name] = {#warnings, 0}
|
||||||
end
|
end
|
||||||
for player_name, warnings in pairs(user_script_warnings) do
|
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
|
end
|
||||||
rtn[player_name][2] = #warnings
|
rtn[player_name][2] = #warnings
|
||||||
end
|
end
|
||||||
Commands.print{'expcom-warnings.list-tilte'}
|
Commands.print{'expcom-warnings.list-title'}
|
||||||
for player_name, warnings in pairs(rtn) do
|
for player_name, warnings in pairs(rtn) do
|
||||||
local player_name_color = format_chat_player_name(player_name)
|
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}
|
Commands.print{'expcom-warnings.list', player_name_color, warnings[1], warnings[2], config.temp_warning_limit}
|
||||||
|
|||||||
@@ -28,8 +28,20 @@ local config = require 'config.warnings' --- @dep config.warnings
|
|||||||
|
|
||||||
local valid_player = Game.get_player_from_any
|
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 = {
|
local Warnings = {
|
||||||
user_warnings={},
|
user_warnings=PlayerWarnings,
|
||||||
user_script_warnings={},
|
user_script_warnings={},
|
||||||
events = {
|
events = {
|
||||||
--- When a warning is added to a player
|
--- 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 string reason the reason that the player was given a warning
|
||||||
-- @tparam number warning_count the new number of warnings that the player has
|
-- @tparam number warning_count the new number of warnings that the player has
|
||||||
on_script_warning_added = script.generate_event_name(),
|
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
|
-- @event on_script_warning_removed
|
||||||
-- @tparam number player_index the index of the player who is having the 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
|
-- @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
|
local user_script_warnings = Warnings.user_script_warnings
|
||||||
Global.register({
|
Global.register(user_script_warnings, function(tbl)
|
||||||
user_warnings = user_warnings,
|
Warnings.user_script_warnings = tbl
|
||||||
user_script_warnings = user_script_warnings
|
user_script_warnings = tbl
|
||||||
}, 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
|
|
||||||
end)
|
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
|
-- @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
|
-- @treturn table an array of all the warnings on this player, contains tick, by_player_name and reason
|
||||||
function Warnings.get_warnings(player)
|
function Warnings.get_warnings(player)
|
||||||
return user_warnings[player.name] or {}
|
return PlayerWarnings:get(player.name, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Gets the number of warnings that a player has on them
|
--- Gets the number of warnings that a player has on them
|
||||||
-- @tparam LuaPlayer player the player to count the warnings for
|
-- @tparam LuaPlayer player the player to count the warnings for
|
||||||
-- @treturn number the number of warnings that the player has
|
-- @treturn number the number of warnings that the player has
|
||||||
function Warnings.count_warnings(player)
|
function Warnings.count_warnings(player)
|
||||||
local warnings = user_warnings[player.name] or {}
|
local warnings = PlayerWarnings:get(player.name, {})
|
||||||
return #warnings
|
return #warnings
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -97,21 +103,23 @@ function Warnings.add_warning(player, by_player_name, reason)
|
|||||||
if not player then return end
|
if not player then return end
|
||||||
if not by_player_name 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]
|
local warning_count
|
||||||
if not warnings then
|
PlayerWarnings:update(player.name, function(_, warnings)
|
||||||
warnings = {}
|
local warning = {
|
||||||
user_warnings[player.name] = warnings
|
by_player_name = by_player_name,
|
||||||
end
|
reason = reason
|
||||||
|
}
|
||||||
|
|
||||||
table.insert(warnings, {
|
if not warnings then
|
||||||
tick = game.tick,
|
warning_count = 1
|
||||||
by_player_name = by_player_name,
|
return {warning}
|
||||||
reason = reason
|
else
|
||||||
})
|
table.insert(warnings, warning)
|
||||||
|
warning_count = #warnings
|
||||||
local warning_count = #warnings
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
script.raise_event(Warnings.events.on_warning_added, {
|
script.raise_event(Warnings.events.on_warning_added, {
|
||||||
name = 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
|
reason = reason
|
||||||
})
|
})
|
||||||
|
|
||||||
local action = config.actions[#warnings]
|
local action = config.actions[warning_count]
|
||||||
if action then
|
if action then
|
||||||
local _type = type(action)
|
local _type = type(action)
|
||||||
if _type == 'function' then
|
if _type == 'function' then
|
||||||
@@ -156,7 +164,7 @@ local function warning_removed_event(player, warning_by_name, removed_by_name, w
|
|||||||
})
|
})
|
||||||
end
|
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 LuaPlayer player the player to remove a warning from
|
||||||
-- @tparam string by_player_name the name of the player who is doing the action
|
-- @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
|
-- @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 player then return end
|
||||||
if not by_player_name then return end
|
if not by_player_name then return end
|
||||||
|
|
||||||
local warnings = user_warnings[player.name]
|
local warning, warning_count
|
||||||
if not warnings then return end
|
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 warning_count
|
||||||
|
|
||||||
return #warnings
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes all warnings from a player, will trigger remove event for each warning
|
--- 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 player then return end
|
||||||
if not by_player_name 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
|
if not warnings then return end
|
||||||
|
|
||||||
local warning_count = #warnings
|
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)
|
warning_removed_event(player, warning.by_player_name, by_player_name, warning_count-n)
|
||||||
end
|
end
|
||||||
|
|
||||||
user_warnings[player.name] = nil
|
PlayerWarnings:remove(player)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -249,9 +260,9 @@ function Warnings.add_script_warning(player, reason)
|
|||||||
return warning_count
|
return warning_count
|
||||||
end
|
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 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)
|
local function script_warning_removed_event(player, warning_count)
|
||||||
script.raise_event(Warnings.events.on_script_warning_removed, {
|
script.raise_event(Warnings.events.on_script_warning_removed, {
|
||||||
name = Warnings.events.on_script_warning_removed,
|
name = Warnings.events.on_script_warning_removed,
|
||||||
|
|||||||
@@ -3,10 +3,13 @@
|
|||||||
|
|
||||||
local Event = require 'utils.event' ---@dep utils.event
|
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 PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local UsesAlt = PlayerData.Settings:combine('UsesAlt')
|
local UsesAlt = PlayerData.Settings:combine('UsesAlt')
|
||||||
UsesAlt:set_default(false)
|
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
|
--- When your data loads apply alt view if you have it enabled
|
||||||
UsesAlt:on_load(function(player_name, uses_alt)
|
UsesAlt:on_load(function(player_name, uses_alt)
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ require 'config.expcore.command_general_parse'
|
|||||||
--- Stores the bonus for the player
|
--- Stores the bonus for the player
|
||||||
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local PlayerBonus = PlayerData.Settings:combine('Bonus')
|
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
|
--- Apply a bonus amount to a player
|
||||||
local function apply_bonus(player, amount)
|
local function apply_bonus(player, amount)
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ require 'config.expcore.command_general_parse'
|
|||||||
--- Stores the join message that the player have
|
--- Stores the join message that the player have
|
||||||
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local CustomMessages = PlayerData.Settings:combine('JoinMessage')
|
local CustomMessages = PlayerData.Settings:combine('JoinMessage')
|
||||||
|
CustomMessages:set_metadata{
|
||||||
|
permission = 'command/join-message'
|
||||||
|
}
|
||||||
|
|
||||||
--- When a players data loads show their message
|
--- When a players data loads show their message
|
||||||
CustomMessages:on_load(function(player_name, player_message)
|
CustomMessages:on_load(function(player_name, player_message)
|
||||||
|
|||||||
@@ -8,6 +8,13 @@ local config = require 'config.preset_player_colours' --- @dep config.preset_pla
|
|||||||
--- Stores the colour that the player wants
|
--- Stores the colour that the player wants
|
||||||
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local PlayerColours = PlayerData.Settings:combine('Colour')
|
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
|
--- Used to compact player colours to take less space
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
|
|||||||
@@ -9,6 +9,15 @@ local config = require 'config.preset_player_quickbar' --- @dep config.preset_pl
|
|||||||
--- Stores the quickbar filters for a player
|
--- Stores the quickbar filters for a player
|
||||||
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local PlayerFilters = PlayerData.Settings:combine('QuickbarFilters')
|
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
|
--- Loads your quickbar preset
|
||||||
PlayerFilters:on_load(function(player_name, filters)
|
PlayerFilters:on_load(function(player_name, filters)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
local Event = require 'utils.event' ---@dep utils.event
|
local Event = require 'utils.event' ---@dep utils.event
|
||||||
local config = require 'config.statistics' ---@dep config.statistics
|
local config = require 'config.statistics' ---@dep config.statistics
|
||||||
|
local format_time = _C.format_time
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local afk_required = 5*3600 -- 5 minutes
|
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 PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local AllPlayerData = PlayerData.All
|
local AllPlayerData = PlayerData.All
|
||||||
local Statistics = PlayerData.Statistics
|
local Statistics = PlayerData.Statistics
|
||||||
|
Statistics:set_metadata{
|
||||||
|
display_order = config.display_order
|
||||||
|
}
|
||||||
|
|
||||||
--- Update your statistics with any which happened before the data was valid
|
--- Update your statistics with any which happened before the data was valid
|
||||||
Statistics:on_load(function(player_name, player_statistics)
|
Statistics:on_load(function(player_name, player_statistics)
|
||||||
@@ -26,11 +30,20 @@ Statistics:on_load(function(player_name, player_statistics)
|
|||||||
return player_statistics
|
return player_statistics
|
||||||
end)
|
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
|
--- Add Playtime and AfkTime if it is enabled
|
||||||
if config.Playtime or config.AfkTime then
|
if config.Playtime or config.AfkTime then
|
||||||
local playtime, afk_time
|
local playtime, afk_time
|
||||||
if config.Playtime then playtime = Statistics:combine('Playtime') 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') end
|
if config.AfkTime then afk_time = Statistics:combine('AfkTime') afk_time:set_metadata{stringify=format_minutes} end
|
||||||
Event.on_nth_tick(3600, function()
|
Event.on_nth_tick(3600, function()
|
||||||
if game.tick == 0 then return end
|
if game.tick == 0 then return end
|
||||||
for _, player in pairs(game.connected_players) do
|
for _, player in pairs(game.connected_players) do
|
||||||
@@ -40,9 +53,10 @@ if config.Playtime or config.AfkTime then
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add DistanceTraveled if it is enabled
|
--- Add DistanceTravelled if it is enabled
|
||||||
if config.DistanceTraveled then
|
if config.DistanceTravelled then
|
||||||
local stat = Statistics:combine('DistanceTraveled')
|
local stat = Statistics:combine('DistanceTravelled')
|
||||||
|
stat:set_metadata{unit=' tiles'}
|
||||||
Event.add(defines.events.on_player_changed_position, function(event)
|
Event.add(defines.events.on_player_changed_position, function(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
if not player.valid or not player.connected or player.afk_time > afk_required then return end
|
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
|
end
|
||||||
|
|
||||||
--- Add Kills if it is enabled
|
--- Add Kills if it is enabled
|
||||||
if config.DamageDealt then
|
if config.Kills then
|
||||||
local stat = Statistics:combine('Kills')
|
local stat = Statistics:combine('Kills')
|
||||||
Event.add(defines.events.on_entity_died, function(event)
|
Event.add(defines.events.on_entity_died, function(event)
|
||||||
local character = event.cause -- Check character is valid
|
local character = event.cause -- Check character is valid
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ require 'config.expcore.command_role_parse'
|
|||||||
--- Stores the tag for a player
|
--- Stores the tag for a player
|
||||||
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local PlayerTags = PlayerData.Settings:combine('Tag')
|
local PlayerTags = PlayerData.Settings:combine('Tag')
|
||||||
|
PlayerTags:set_metadata{
|
||||||
|
permission = 'command/tag'
|
||||||
|
}
|
||||||
|
|
||||||
--- When your tag is updated then apply the changes
|
--- When your tag is updated then apply the changes
|
||||||
PlayerTags:on_update(function(player_name, player_tag)
|
PlayerTags:on_update(function(player_name, player_tag)
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
local Gui = require 'expcore.gui' --- @dep expcore.gui
|
local Gui = require 'expcore.gui' --- @dep expcore.gui
|
||||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
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 Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
local Game = require 'utils.game' --- @dep utils.game
|
||||||
local format_time = _C.format_time --- @dep expcore.common
|
local format_time = _C.format_time --- @dep expcore.common
|
||||||
|
local format_number = require('util').format_number --- @dep util
|
||||||
|
|
||||||
local tabs = {}
|
local tabs = {}
|
||||||
local function Tab(caption, tooltip, element_define)
|
local function Tab(caption, tooltip, element_define)
|
||||||
@@ -259,6 +261,97 @@ Gui.element(function(_, parent)
|
|||||||
return container
|
return container
|
||||||
end))
|
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
|
--- Main readme container for the center flow
|
||||||
-- @element readme
|
-- @element readme
|
||||||
local readme_toggle
|
local readme_toggle
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ local Gui = require 'expcore.gui' --- @dep expcore.gui
|
|||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
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
|
--- Label to show the server ups
|
||||||
-- @element server_ups
|
-- @element server_ups
|
||||||
local server_ups =
|
local server_ups =
|
||||||
@@ -19,9 +28,17 @@ Gui.element{
|
|||||||
font = 'default-game'
|
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
|
--- Toggles if the server ups is visbile
|
||||||
-- @command server-ups
|
-- @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')
|
:add_alias('sups', 'ups')
|
||||||
:register(function(player)
|
:register(function(player)
|
||||||
local label = player.gui.screen[server_ups.name]
|
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'}
|
return Commands.error{'expcom-server-ups.no-ext'}
|
||||||
end
|
end
|
||||||
label.visible = not label.visible
|
label.visible = not label.visible
|
||||||
|
UsesServerUps:set(player, label.visible)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Set the location of the label
|
-- Set the location of the label
|
||||||
|
|||||||
Reference in New Issue
Block a user