mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-16 02:46:55 +02:00
updates
This commit is contained in:
parent
4e080475c1
commit
b553e1daa8
@ -1,7 +1,7 @@
|
||||
require 'config'
|
||||
require 'utils.utils'
|
||||
require 'utils.list_utils'
|
||||
require 'user_groups'
|
||||
local UserGroups = require 'user_groups'
|
||||
require 'custom_commands'
|
||||
require 'base_data'
|
||||
require 'train_station_names'
|
||||
@ -159,7 +159,7 @@ local function player_joined(event)
|
||||
return
|
||||
end
|
||||
|
||||
local message = Donators.welcome_messages[player.name]
|
||||
local message = UserGroups.get_donator_welcome_message(player.name)
|
||||
if not message then
|
||||
return
|
||||
end
|
||||
@ -323,6 +323,6 @@ local Server = require 'server'
|
||||
Event.add(
|
||||
defines.events.on_research_finished,
|
||||
function(event)
|
||||
Server.to_discord_raw('**Research ' .. event.research.name .. ' finished.**')
|
||||
Server.to_discord_raw('**Research ' .. event.research.name .. ' finished.**')
|
||||
end
|
||||
)
|
||||
|
42
server.lua
42
server.lua
@ -1,7 +1,13 @@
|
||||
local Public = {}
|
||||
|
||||
local raw_print = print
|
||||
function print(str)
|
||||
raw_print('[PRINT] ' .. str)
|
||||
end
|
||||
|
||||
local discord_tag = '[DISCORD]'
|
||||
local discord_raw_tag = '[DISCORD-RAW]'
|
||||
local discord_bold_tag = '[DISCORD-BOLD]'
|
||||
local discord_admin_tag = '[DISCORD-ADMIN]'
|
||||
local discord_admin_raw_tag = '[DISCORD-ADMIN-RAW]'
|
||||
local discord_embed_tag = '[DISCORD-EMBED]'
|
||||
@ -11,45 +17,57 @@ local discord_admin_embed_raw_tag = '[DISCORD-ADMIN-EMBED-RAW]'
|
||||
local regular_promote_tag = '[REGULAR-PROMOTE]'
|
||||
local regular_deomote_tag = '[REGULAR-DEOMOTE]'
|
||||
|
||||
Public.raw_print = raw_print
|
||||
|
||||
function Public.to_discord(message)
|
||||
print(discord_tag .. message)
|
||||
raw_print(discord_tag .. message)
|
||||
end
|
||||
|
||||
function Public.to_discord_raw(message)
|
||||
print(discord_raw_tag .. message)
|
||||
raw_print(discord_raw_tag .. message)
|
||||
end
|
||||
|
||||
function Public.to_discord_bold(message)
|
||||
raw_print(discord_bold_tag .. message)
|
||||
end
|
||||
|
||||
function Public.to_admin(message)
|
||||
print(discord_admin_tag .. message)
|
||||
raw_print(discord_admin_tag .. message)
|
||||
end
|
||||
|
||||
function Public.to_admin_raw(message)
|
||||
print(discord_admin_raw_tag .. message)
|
||||
raw_print(discord_admin_raw_tag .. message)
|
||||
end
|
||||
|
||||
function Public.to_discord_embed(message)
|
||||
print(discord_embed_tag .. message)
|
||||
raw_print(discord_embed_tag .. message)
|
||||
end
|
||||
|
||||
function Public.to_discord_embed_raw(message)
|
||||
print(discord_embed_raw_tag .. message)
|
||||
raw_print(discord_embed_raw_tag .. message)
|
||||
end
|
||||
|
||||
function Public.to_admin_embed(message)
|
||||
print(discord_admin_embed_tag .. message)
|
||||
raw_print(discord_admin_embed_tag .. message)
|
||||
end
|
||||
|
||||
function Public.to_admin_embed_raw(message)
|
||||
print(discord_admin_embed_raw_tag .. message)
|
||||
raw_print(discord_admin_embed_raw_tag .. message)
|
||||
end
|
||||
|
||||
function Public.regular_promote(target, promotor)
|
||||
local message = table.concat {regular_promote_tag, target, ' ', promotor or ''}
|
||||
print(message)
|
||||
local control_message = table.concat {regular_promote_tag, target, ' ', promotor}
|
||||
local discord_message = table.concat {discord_bold_tag, promotor .. ' promoted ' .. target .. ' to regular.'}
|
||||
|
||||
raw_print(control_message)
|
||||
raw_print(discord_message)
|
||||
end
|
||||
|
||||
function Public.regular_deomote(target)
|
||||
print(regular_deomote_tag .. target)
|
||||
function Public.regular_deomote(target, demotor)
|
||||
local discord_message = table.concat {discord_bold_tag, target, ' was demoted from regular by ', demotor, '.'}
|
||||
|
||||
raw_print(regular_deomote_tag .. target)
|
||||
raw_print(discord_message)
|
||||
end
|
||||
|
||||
return Public
|
||||
|
@ -3,20 +3,12 @@ local UserGroups = require 'user_groups'
|
||||
|
||||
local Public = {}
|
||||
|
||||
function Public.get_poll_result(id)
|
||||
Poll.send_poll_result_to_discord(id)
|
||||
end
|
||||
Public.get_poll_result = Poll.send_poll_result_to_discord
|
||||
|
||||
function Public.regular_sync(names)
|
||||
global.regulars = names
|
||||
end
|
||||
Public.regular_sync = UserGroups.sync_regulars
|
||||
|
||||
function Public.regular_promote(name)
|
||||
global.regulars[name] = true
|
||||
end
|
||||
Public.regular_promote = UserGroups.server_add_regular
|
||||
|
||||
function Public.regular_demote(name)
|
||||
global.regulars[name] = nil
|
||||
end
|
||||
Public.regular_demote = UserGroups.server_remove_regular
|
||||
|
||||
return Public
|
||||
|
@ -1,8 +1,11 @@
|
||||
global.regulars = {}--require 'resources.regulars'
|
||||
local Donators = require 'resources.donators'
|
||||
global.donators = Donators.donators
|
||||
local Event = require 'utils.event'
|
||||
local Utils = require 'utils.utils'
|
||||
local Server = require 'server'
|
||||
--local Donators = require 'resources.donators'
|
||||
|
||||
global.regulars = {}
|
||||
global.donators = {}
|
||||
global.donator_welcome_messages = {}
|
||||
|
||||
local Module = {}
|
||||
|
||||
@ -22,9 +25,11 @@ Module.is_regular =
|
||||
function(player_name)
|
||||
return Utils.cast_bool(global.regulars[player_name] or global.regulars[player_name:lower()]) --to make it backwards compatible
|
||||
end
|
||||
Module.add_regular = function(player_name)
|
||||
|
||||
Module.add_regular =
|
||||
function(player_name)
|
||||
local actor = Utils.get_actor()
|
||||
if Module.is_regular(player_name) then
|
||||
--[[ if Module.is_regular(player_name) then
|
||||
player_print(player_name .. ' is already a regular.')
|
||||
else
|
||||
if game.players[player_name] then
|
||||
@ -35,13 +40,16 @@ Module.add_regular = function(player_name)
|
||||
else
|
||||
player_print(player_name .. ' does not exist.')
|
||||
end
|
||||
end
|
||||
end ]]
|
||||
global.regulars[player_name] = true
|
||||
game.print(actor .. ' promoted ' .. player_name .. ' to regular.')
|
||||
Server.regular_promote(player_name, actor)
|
||||
end
|
||||
|
||||
Module.remove_regular =
|
||||
function(player_name)
|
||||
local actor = Utils.get_actor()
|
||||
if game.players[player_name] then
|
||||
--[[ if game.players[player_name] then
|
||||
player_name = game.players[player_name].name
|
||||
if Module.is_regular(player_name) then
|
||||
game.print(player_name .. ' was demoted from regular by ' .. actor .. '.')
|
||||
@ -49,13 +57,37 @@ Module.remove_regular =
|
||||
global.regulars[player_name] = nil
|
||||
global.regulars[player_name:lower()] = nil --backwards compatible
|
||||
update_file()
|
||||
end ]]
|
||||
global.regulars[player_name] = nil
|
||||
game.print(player_name .. ' was demoted from regular by ' .. actor .. '.')
|
||||
Server.regular_deomote(player_name, actor)
|
||||
end
|
||||
|
||||
function Module.server_add_regular(player_name)
|
||||
global.regulars[player_name] = true
|
||||
end
|
||||
|
||||
function Module.server_remove_regular(player_name)
|
||||
global.regulars[player_name] = nil
|
||||
end
|
||||
|
||||
function Module.sync_regulars(names)
|
||||
local r = {}
|
||||
for _, name in ipairs(names) do
|
||||
r[name] = true
|
||||
end
|
||||
|
||||
global.regulars = r
|
||||
end
|
||||
|
||||
Module.print_regulars = function()
|
||||
local result = {}
|
||||
for k, _ in pairs(global.regulars) do
|
||||
player_print(k)
|
||||
table.insert(result, k)
|
||||
end
|
||||
|
||||
result = table.concat(result, ', ')
|
||||
game.print(result)
|
||||
end
|
||||
|
||||
function Module.get_rank(player)
|
||||
@ -81,6 +113,15 @@ function Module.player_has_donator_perk(player_name, perk_flag)
|
||||
return bit32.band(d, perk_flag) == perk_flag
|
||||
end
|
||||
|
||||
function Module.get_donator_welcome_message(player_name)
|
||||
return global.donator_welcome_messages[player_name]
|
||||
end
|
||||
|
||||
function Module.sync_donators(donators, messages)
|
||||
global.donators = donators
|
||||
global.donator_welcome_messages = messages
|
||||
end
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function(event)
|
||||
|
Loading…
Reference in New Issue
Block a user