mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
fixed donator_messages
This commit is contained in:
parent
69fa8309f0
commit
218f53da83
@ -1,6 +1,6 @@
|
||||
local Game = require 'utils.game'
|
||||
local Event = require 'utils.event'
|
||||
local Donators = require 'resources.donators'
|
||||
local UserGroups = require 'features.user_groups'
|
||||
|
||||
local function player_joined(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
@ -8,7 +8,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
|
||||
|
@ -7,7 +7,6 @@ local Token = require 'utils.global_token'
|
||||
|
||||
global.regulars = {}
|
||||
global.donators = Donators.donators
|
||||
global.donator_welcome_messages = {}
|
||||
|
||||
local Module = {}
|
||||
|
||||
@ -72,7 +71,7 @@ function Module.get_rank(player)
|
||||
end
|
||||
|
||||
function Module.is_donator(player_name)
|
||||
return global.donators[player_name]
|
||||
return global.donators[player_name] ~= nil
|
||||
end
|
||||
|
||||
function Module.player_has_donator_perk(player_name, perk_flag)
|
||||
@ -81,38 +80,47 @@ function Module.player_has_donator_perk(player_name, perk_flag)
|
||||
return false
|
||||
end
|
||||
|
||||
return bit32.band(d, perk_flag) == perk_flag
|
||||
local flags = d.perk_flags
|
||||
if not flags then
|
||||
return false
|
||||
end
|
||||
|
||||
return bit32.band(flags, perk_flag) == perk_flag
|
||||
end
|
||||
|
||||
function Module.get_donator_welcome_message(player_name)
|
||||
return global.donator_welcome_messages[player_name]
|
||||
local d = global.donators[player_name]
|
||||
if not d then
|
||||
return nil
|
||||
end
|
||||
|
||||
return d.welcome_messages
|
||||
end
|
||||
|
||||
function Module.set_donator(player_name, perks)
|
||||
global.donators[player_name] = perks
|
||||
Server.donator_set(player_name, perks)
|
||||
function Module.set_donator(player_name, data)
|
||||
global.donators[player_name] = data
|
||||
Server.set_data('donators', player_name, data)
|
||||
end
|
||||
|
||||
function Module.sync_donators(donators, messages)
|
||||
global.donators = donators
|
||||
global.donator_welcome_messages = messages
|
||||
end
|
||||
local sync_donators_callback =
|
||||
Token.register(
|
||||
function(data)
|
||||
global.donators = data.entries
|
||||
end
|
||||
)
|
||||
|
||||
function Module.server_set_donator(player_name, perks)
|
||||
global.donators[player_name] = perks
|
||||
function Module.sync_donators()
|
||||
Server.try_get_all_data('donators', sync_donators_callback)
|
||||
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)
|
||||
for k, _ in pairs(global.donators) do
|
||||
table.insert(result, k)
|
||||
end
|
||||
|
||||
result = table.concat(result, ', ')
|
||||
game.print(result)
|
||||
end
|
||||
|
||||
@ -131,6 +139,7 @@ Event.add(
|
||||
Server.events.on_server_started,
|
||||
function()
|
||||
Module.sync_regulars()
|
||||
Module.sync_donators()
|
||||
end
|
||||
)
|
||||
|
||||
@ -141,4 +150,11 @@ Server.on_data_set_changed(
|
||||
end
|
||||
)
|
||||
|
||||
Server.on_data_set_changed(
|
||||
'donators',
|
||||
function(data)
|
||||
global.donators[data.key] = data.value
|
||||
end
|
||||
)
|
||||
|
||||
return Module
|
||||
|
@ -7,33 +7,32 @@ Module.donator_perk_flags = {
|
||||
|
||||
local d = Module.donator_perk_flags
|
||||
|
||||
Module.donators = {
|
||||
['aldldl'] = d.rank,
|
||||
['Geostyx'] = d.rank,
|
||||
['Linaori'] = d.rank,
|
||||
['Xertez'] = d.rank,
|
||||
['Chevalier1200'] = d.rank + d.train,
|
||||
['DraugTheWhopper'] = d.rank + d.train,
|
||||
['der-dave.com'] = d.rank + d.train,
|
||||
['Jayefuu'] = d.rank,
|
||||
['Valansch'] = d.rank,
|
||||
['plague006'] = d.rank,
|
||||
['chromaddict'] = d.rank,
|
||||
['InphinitePhractals'] = d.rank + d.train,
|
||||
['shoghicp'] = d.rank + d.train,
|
||||
['DuelleuD'] = d.rank + d.train,
|
||||
['henrycn1997'] = d.rank + d.train,
|
||||
['Raiguard'] = d.rank + d.train,
|
||||
}
|
||||
|
||||
Module.welcome_messages = {
|
||||
['Linaori'] = 'I present to you Linaori of house Refactorio, Lady of the Void, Remover of Spaghetti, Queen of the Endless Nauvis, Breaker of Biters and Mother of Code!',
|
||||
['Valansch'] = 'Welcome Valansch, <insert custom welcome message here>.',
|
||||
['der-dave.com'] = "Dave doesn't want a welcome message.",
|
||||
['plague006'] = 'plague wrote this dumb message you have to read. If you want your own dumb on-join message be sure to donate on Patreon!',
|
||||
['shoghicp'] = 'Need more servers!',
|
||||
['aldldl'] = "ALo's Here",
|
||||
['Raiguard'] = "I am... was... God. The one you call 'The Almighty'. The creator of Factories. But now, I am dead. The Biters killed me. I am sorry.",
|
||||
}
|
||||
|
||||
Module.donators = {}
|
||||
--[[ {
|
||||
['aldldl'] = {perk_flags = d.rank, welcome_messages = "ALo's Here"},
|
||||
['Geostyx'] = {perk_flags = d.rank},
|
||||
['Linaori'] = {
|
||||
perk_flags = d.rank,
|
||||
welcome_messages = 'I present to you Linaori of house Refactorio, Lady of the Void, Remover of Spaghetti, Queen of the Endless Nauvis, Breaker of Biters and Mother of Code!'
|
||||
},
|
||||
['Xertez'] = {perk_flags = d.rank},
|
||||
['Chevalier1200'] = {perk_flags = d.rank + d.train},
|
||||
['DraugTheWhopper'] = {perk_flags = d.rank + d.train},
|
||||
['der-dave.com'] = {perk_flags = d.rank + d.train, welcome_messages = "Dave doesn't want a welcome message."},
|
||||
['Jayefuu'] = {perk_flags = d.rank},
|
||||
['Valansch'] = {perk_flags = d.rank, welcome_messages = 'Welcome Valansch, <insert custom welcome message here>.'},
|
||||
['plague006'] = {
|
||||
perk_flags = d.rank,
|
||||
welcome_messages = 'plague wrote this dumb message you have to read. If you want your own dumb on-join message be sure to donate on Patreon!'
|
||||
},
|
||||
['chromaddict'] = {perk_flags = d.rank},
|
||||
['InphinitePhractals'] = {perk_flags = d.rank + d.train},
|
||||
['shoghicp'] = {perk_flags = d.rank + d.train, welcome_messages = 'Need more servers!'},
|
||||
['DuelleuD'] = {perk_flags = d.rank + d.train},
|
||||
['henrycn1997'] = {perk_flags = d.rank + d.train},
|
||||
['Raiguard'] = {
|
||||
perk_flags = d.rank + d.train,
|
||||
welcome_messages = "I am... was... God. The one you call 'The Almighty'. The creator of Factories. But now, I am dead. The Biters killed me. I am sorry."
|
||||
}
|
||||
} ]]
|
||||
return Module
|
||||
|
Loading…
Reference in New Issue
Block a user