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:
parent
3ebd1f5f7b
commit
398927844e
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user