1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

update to donator perks

This commit is contained in:
grilledham 2018-09-11 00:08:22 +01:00
parent 654713ae28
commit 102318aaaf
4 changed files with 54 additions and 12 deletions

View File

@ -1,6 +1,7 @@
local Event = require 'utils.event'
local Global = require 'utils.global'
local Gui = require 'utils.gui'
local Donators = require 'resources.donators'
local UserGroups = require 'user_groups'
local PlayerStats = require 'player_stats'
local Utils = require 'utils.utils'
@ -23,6 +24,7 @@ local rank_colors = {
}
local inv_sprite_time_step = 1 / sprite_time_step
local rank_perk_flag = Donators.donator_perk_flags.rank
local rank_names = {
'Guest',
'Regular',
@ -91,7 +93,7 @@ local function get_rank_level(player)
end
local name = player.name
if UserGroups.is_donator(name) then
if UserGroups.is_donator_perk(name, rank_perk_flag) then
return 3
elseif UserGroups.is_regular(name) then
return 2
@ -745,6 +747,6 @@ Gui.on_click(
local reporting_player = event.player
local reported_player = Gui.get_data(event.element)
Report.spawn_reporting_popup (reporting_player, reported_player)
Report.spawn_reporting_popup(reporting_player, reported_player)
end
)

View File

@ -1,8 +1,21 @@
return {
['robertkruijt'] = true,
['aldldl'] = true,
['Geostyx'] = true,
['Linaori'] = true,
['Terarink'] = true,
['Xertez'] = true
local Module = {}
Module.donator_perk_flags = {
rank = 0x1,
welcome = 0x2, -- not implemented
train = 0x4,
currency = 0x8 -- not implemented
}
local d = Module.donator_perk_flags
Module.donators = {
['robertkruijt'] = d.rank + d.train,
['aldldl'] = d.rank + d.train,
['Geostyx'] = d.rank + d.train,
['Linaori'] = d.rank + d.train,
['Terarink'] = d.rank + d.train,
['Xertez'] = d.rank + d.train,
}
return Module

View File

@ -1,11 +1,17 @@
local Event = require 'utils.event'
local Market_items = require 'resources.market_items'
local Global = require 'utils.global'
local Donators = require 'resources.donators'
local UserGroups = require 'user_groups'
local train_perk_flag = Donators.donator_perk_flags.train
local saviour_token_name = 'small-plane' -- item name for what saves players
local saviour_timeout = 180 -- number of ticks players are train immune after getting hit (roughly)
table.insert(Market_items, {price = {{Market_items.market_item, 100}}, offer = {type = 'give-item', item = saviour_token_name}})
table.insert(
Market_items,
{price = {{Market_items.market_item, 100}}, offer = {type = 'give-item', item = saviour_token_name}}
)
local remove_stack = {name = saviour_token_name, count = 1}
@ -58,6 +64,17 @@ local function on_pre_death(event)
return
end
local player_name = player.name
if UserGroups.is_donator_perk(player_name, train_perk_flag) then
saved_players[player_index] = game_tick
save_player(player)
game.print(player_name .. ' has been saved from a train death as a perk of donating to the server.')
return
end
local saviour_tokens = player.get_item_count(saviour_token_name)
if saviour_tokens < 1 then
return
@ -70,7 +87,7 @@ local function on_pre_death(event)
game.print(
table.concat {
player.name,
player_name,
' has been saved from a train death. Their ',
saviour_token_name,
' survival item has be used up.'

View File

@ -1,5 +1,6 @@
global.regulars = require 'resources.regulars'
global.donators = require 'resources.donators'
local Donators = require 'resources.donators'
global.donators = Donators.donators
local Event = require 'utils.event'
local Utils = require 'utils.utils'
@ -71,6 +72,15 @@ function Module.is_donator(player_name)
return global.donators[player_name]
end
function Module.is_donator_perk(player_name, perk)
local d = global.donators[player_name]
if not d then
return false
end
return bit32.band(d, perk) == perk
end
Event.add(
defines.events.on_player_joined_game,
function(event)