1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00
This commit is contained in:
grilledham 2018-10-03 23:26:33 +01:00
parent b90a4d68ae
commit b14b6c6ee7
3 changed files with 75 additions and 2 deletions

View File

@ -247,6 +247,45 @@ local function regular(cmd)
end
end
local function donator(cmd)
local player = game.player
if player and not player.admin then
cant_run(cmd.name)
return
end
if cmd.parameter == nil then
player_print('Command failed. Usage: /donator <player> <perks>')
return
end
local params = {}
for param in string.gmatch(cmd.parameter, '%S+') do
table.insert(params, param)
end
if params[2] == nil then
player_print('Command failed. Usage: /donator <player> <perks>')
return
end
local perks = params[2]
if perks == 'nil' then
perks = nil
end
if (tonumber(perks) == nil and perks ~= nil) then
player_print("Command failed. perks must be number or the string 'nil' to remove donator.")
return
end
local target = params[1]
UserGroups.set_donator(target, perks)
local message = table.concat {'Player ', target, ' donator perks set to ', perks}
player_print(message)
end
local function afk()
for _, v in pairs(game.players) do
if v.afk_time > 300 then
@ -657,6 +696,8 @@ commands.add_command('tppos', 'Teleports you to a selected entity. (Admins only)
commands.add_command('walkabout', '<player> <duration> - Send someone on a walk. (Admins only)', walkabout)
commands.add_command('regulars', 'Prints a list of game regulars.', UserGroups.print_regulars)
commands.add_command('regular', '<promote, demote>, <player> Change regular status of a player. (Admins only)', regular)
commands.add_command('donator', '<player> <perks> Change donator perks for a player. (Admins only)', donator)
commands.add_command('donators', 'Prints a list of game donators and thier perks.', UserGroups.print_donators)
commands.add_command('afk', 'Shows how long players have been afk.', afk)
commands.add_command(
'follow',

View File

@ -16,6 +16,7 @@ local discord_admin_embed_tag = '[DISCORD-ADMIN-EMBED]'
local discord_admin_embed_raw_tag = '[DISCORD-ADMIN-EMBED-RAW]'
local regular_promote_tag = '[REGULAR-PROMOTE]'
local regular_deomote_tag = '[REGULAR-DEOMOTE]'
local donator_set_tag = '[DONATOR-SET]'
Public.raw_print = raw_print
@ -70,4 +71,12 @@ function Public.regular_deomote(target, demotor)
raw_print(discord_message)
end
function Public.donator_set(target, perks)
perks = perks or 'nil'
local message = table.concat {donator_set_tag, target, ' ', perks}
raw_print(message)
end
return Public

View File

@ -1,10 +1,10 @@
local Event = require 'utils.event'
local Utils = require 'utils.utils'
local Server = require 'server'
--local Donators = require 'resources.donators'
local Donators = require 'resources.donators'
global.regulars = {}
global.donators = {}
global.donators = Donators.donators
global.donator_welcome_messages = {}
local Game = require 'utils.game'
@ -118,11 +118,34 @@ function Module.get_donator_welcome_message(player_name)
return global.donator_welcome_messages[player_name]
end
function Module.set_donator(player_name, perks)
global.donators[player_name] = perks
Server.donator_set(player_name, perks)
end
function Module.sync_donators(donators, messages)
global.donators = donators
global.donator_welcome_messages = messages
end
function Module.server_set_donator(player_name, perks)
global.donators[player_name] = perks
end
function Module.print_donators()
local result = {}
for k, v in pairs(global.donators) do
table.insert(result, k)
table.insert(result, ' : ')
table.insert(result, v)
table.insert(result, ', ')
end
table.remove(result)
result = table.concat(result)
game.print(result)
end
Event.add(
defines.events.on_player_joined_game,
function(event)