1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Player can use /setting-all to show all their values

This commit is contained in:
Lynn 2019-02-02 16:28:22 +01:00
parent 3ebd1f5f7b
commit 398927844e
2 changed files with 21 additions and 0 deletions

View File

@ -422,3 +422,11 @@ Command.add('setting-get', {
player.print(format('Setting "%s" has a value of: "%s"', setting_name, value))
end)
Command.add('setting-all', {
description = 'Display all settings for yourself',
}, function (_, player)
for name, value in pairs(Settings.all(player.index)) do
player.print(format('%s=%s', name, value))
end
end)

View File

@ -3,6 +3,7 @@ local type = type
local error = error
local tonumber = tonumber
local tostring = tostring
local pairs = pairs
local format = string.format
--- Contains a set of callables that will attempt to sanitize and transform the input
@ -160,4 +161,16 @@ function Public.get(player_index, name)
return player_setting ~= nil and player_setting or setting.default
end
---Returns a table of all settings for a given player in a key => value setup
---@param player_index number
function Public.all(player_index)
local player_settings = memory[player_index] or {}
local output = {}
for name, data in pairs(settings) do
output[name] = player_settings[name] or data.default
end
return output
end
return Public