1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-02-07 13:31:54 +02:00

improve table doc

add instructions for changing ranks in ranks
add missing config entry
refine regular and probation commands
This commit is contained in:
Matthew Heguy 2019-01-30 14:42:42 -05:00
parent 28daf88f21
commit 63bb4e6a83
4 changed files with 40 additions and 5 deletions

View File

@ -39,6 +39,10 @@ global.config = {
map_settings = true,
difficulty = true
},
-- time before a player gets the auto-trusted rank, allowing them access to the deconstructions planner, nukes, etc.
rank_system = {
time_for_trust = 3*60*60*60 -- 3 hours
},
-- saves players' lives if they have a small-plane in their inventory, also adds the small-plane to the market and must therefor be loaded first
train_saviour = {
enabled = true

View File

@ -7,6 +7,7 @@ local Utils = require 'utils.core'
local Game = require 'utils.game'
local Event = require 'utils.event'
local Command = require 'utils.command'
local Color = require 'resources.color_presets'
local Ranks = require 'resources.ranks'
local format = string.format
@ -76,10 +77,23 @@ local function regular(args)
local add_target = args['name|remove']
local remove_target = args['name']
if not game.players[remove_target] then
Game.player_print('The player you targeted has never joined this game, please ensure no typo in name.', Color.red)
return
end
if remove_target and add_target == 'remove' then
Rank.set_rank(remove_target, Ranks.guest)
if Rank.decrease_player_rank(remove_target) then
game.print(format("%s removed %s's regular rank.", Utils.get_actor(), remove_target), Color.yellow)
else
Game.player_print(format('%s is already a regular.', remove_target), Color.red)
end
else
Rank.set_rank(add_target, Ranks.regular)
if Rank.set_rank(add_target, Ranks.regular) then
game.print(format('%s promoted %s to regular.', Utils.get_actor(), remove_target), Color.yellow)
else
Game.player_print(format('%s is already a regular.', remove_target), Color.red)
end
end
end
@ -87,11 +101,27 @@ end
local function probation(args)
local add_target = args['name|remove']
local remove_target = args['name']
local target_player = game.players[remove_target]
if not target_player then
Game.player_print('The player you targeted has never joined this game, please ensure no typo in name.', Color.red)
return
end
if remove_target and add_target == 'remove' then
Rank.set_rank(remove_target, Ranks.guest)
if Rank.reset_rank(remove_target) then
game.print(format('%s took %s off of probation.', Utils.get_actor(), remove_target), Color.yellow)
target_player.print('Your probation status has been removed. You may now perform functions as usual', Color.yellow)
else
Game.player_print(format('%s is not on probation.', remove_target), Color.red)
end
else
Rank.set_rank(add_target, Ranks.probation)
if Rank.set_rank(add_target, Ranks.probation) then
game.print(format('%s put %s on probation.', Utils.get_actor(), remove_target), Color.yellow)
target_player.print('You have been placed on probation. You have limited access to normal functions.', Color.yellow)
else
Game.player_print(format('%s is already on probation.', remove_target), Color.red)
end
end
end

View File

@ -1,3 +1,4 @@
-- When adding/removing/changing ranks, rank_system has a migrate_data() function you can use to adjust the existing data.
return {
probation = -1,
guest = 0,

View File

@ -109,7 +109,7 @@ end
--- Chooses a random entry from a table
-- because this uses math.random, it cannot be used outside of events
-- @param t <table> to select an element from
-- @param t <table>
-- @param key <boolean> to indicate whether to return the key or value
-- @return <any> a random element of table t
function table.get_random_dictionary_entry(t, key)