mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-30 04:30:58 +02:00
Review feedback
This commit is contained in:
parent
398927844e
commit
c2b3fcc4f7
@ -2,7 +2,7 @@ local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Gui = require 'utils.gui'
|
||||
local Token = require 'utils.token'
|
||||
local Settings = require 'utils.settings'
|
||||
local Settings = require 'utils.redmew_settings'
|
||||
local Color = require 'resources.color_presets'
|
||||
|
||||
local pairs = pairs
|
||||
|
@ -1,13 +1,13 @@
|
||||
local Game = require 'utils.game'
|
||||
local Timestamp = require 'utils.timestamp'
|
||||
local Command = require 'utils.command'
|
||||
local Settings = require 'utils.settings'
|
||||
local Utils = require 'utils.core'
|
||||
local Report = require 'features.report'
|
||||
local Server = require 'features.server'
|
||||
local UserGroups = require 'features.user_groups'
|
||||
local Walkabout = require 'features.walkabout'
|
||||
local PlayerStats = require 'features.player_stats'
|
||||
local Settings = require 'utils.redmew_settings'
|
||||
|
||||
local format = string.format
|
||||
local ceil = math.ceil
|
||||
@ -386,44 +386,44 @@ Command.add(
|
||||
UserGroups.print_regulars
|
||||
)
|
||||
|
||||
Command.add('setting-set', {
|
||||
Command.add('redmew-setting-set', {
|
||||
description = 'Set a setting for yourself',
|
||||
arguments = {'setting_name', 'new_value'},
|
||||
capture_excess_arguments = true,
|
||||
}, function (arguments, player)
|
||||
local value
|
||||
local setting_name = arguments.setting_name
|
||||
local success, message = pcall(function()
|
||||
local success, data = pcall(function()
|
||||
value = Settings.set(player.index, setting_name, arguments.new_value)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
player.print(message)
|
||||
player.print(data.message)
|
||||
return
|
||||
end
|
||||
|
||||
player.print(format('Changed "%s" to: "%s"', setting_name, value))
|
||||
end)
|
||||
|
||||
Command.add('setting-get', {
|
||||
Command.add('redmew-setting-get', {
|
||||
description = 'Display a setting value for yourself',
|
||||
arguments = {'setting_name'},
|
||||
}, function (arguments, player)
|
||||
local value
|
||||
local setting_name = arguments.setting_name
|
||||
local success, message = pcall(function()
|
||||
local success, data = pcall(function()
|
||||
value = Settings.get(player.index, setting_name)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
player.print(message)
|
||||
player.print(data.message)
|
||||
return
|
||||
end
|
||||
|
||||
player.print(format('Setting "%s" has a value of: "%s"', setting_name, value))
|
||||
end)
|
||||
|
||||
Command.add('setting-all', {
|
||||
Command.add('redmew-setting-all', {
|
||||
description = 'Display all settings for yourself',
|
||||
}, function (_, player)
|
||||
for name, value in pairs(Settings.all(player.index)) do
|
||||
|
@ -120,13 +120,13 @@ end
|
||||
function Public.set(player_index, name, value)
|
||||
local setting = settings[name]
|
||||
if not setting then
|
||||
return error(format('Setting "%s" does not exist.', name))
|
||||
return error({message = format('Setting "%s" does not exist.', name)})
|
||||
end
|
||||
|
||||
local success, sanitized_value = setting.callback(value)
|
||||
|
||||
if not success then
|
||||
error(format('set("%s") failed: %s', name, sanitized_value))
|
||||
error({message = format('Setting "%s" failed: %s', name, sanitized_value)})
|
||||
end
|
||||
|
||||
local player_settings = memory[player_index]
|
||||
@ -149,7 +149,7 @@ end
|
||||
function Public.get(player_index, name)
|
||||
local setting = settings[name]
|
||||
if not setting then
|
||||
return error(format('Setting "%s" does not exist.', name))
|
||||
return error({message = format('Setting "%s" does not exist.', name)})
|
||||
end
|
||||
|
||||
local player_settings = memory[player_index]
|
Loading…
x
Reference in New Issue
Block a user