mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-28 03:56:53 +02:00
update to donator perks
This commit is contained in:
parent
654713ae28
commit
102318aaaf
@ -1,6 +1,7 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
|
local Donators = require 'resources.donators'
|
||||||
local UserGroups = require 'user_groups'
|
local UserGroups = require 'user_groups'
|
||||||
local PlayerStats = require 'player_stats'
|
local PlayerStats = require 'player_stats'
|
||||||
local Utils = require 'utils.utils'
|
local Utils = require 'utils.utils'
|
||||||
@ -23,6 +24,7 @@ local rank_colors = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local inv_sprite_time_step = 1 / sprite_time_step
|
local inv_sprite_time_step = 1 / sprite_time_step
|
||||||
|
local rank_perk_flag = Donators.donator_perk_flags.rank
|
||||||
local rank_names = {
|
local rank_names = {
|
||||||
'Guest',
|
'Guest',
|
||||||
'Regular',
|
'Regular',
|
||||||
@ -91,7 +93,7 @@ local function get_rank_level(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local name = player.name
|
local name = player.name
|
||||||
if UserGroups.is_donator(name) then
|
if UserGroups.is_donator_perk(name, rank_perk_flag) then
|
||||||
return 3
|
return 3
|
||||||
elseif UserGroups.is_regular(name) then
|
elseif UserGroups.is_regular(name) then
|
||||||
return 2
|
return 2
|
||||||
@ -745,6 +747,6 @@ Gui.on_click(
|
|||||||
local reporting_player = event.player
|
local reporting_player = event.player
|
||||||
local reported_player = Gui.get_data(event.element)
|
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
|
end
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,21 @@
|
|||||||
return {
|
local Module = {}
|
||||||
['robertkruijt'] = true,
|
|
||||||
['aldldl'] = true,
|
Module.donator_perk_flags = {
|
||||||
['Geostyx'] = true,
|
rank = 0x1,
|
||||||
['Linaori'] = true,
|
welcome = 0x2, -- not implemented
|
||||||
['Terarink'] = true,
|
train = 0x4,
|
||||||
['Xertez'] = true
|
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
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Market_items = require 'resources.market_items'
|
local Market_items = require 'resources.market_items'
|
||||||
local Global = require 'utils.global'
|
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_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)
|
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}
|
local remove_stack = {name = saviour_token_name, count = 1}
|
||||||
|
|
||||||
@ -58,6 +64,17 @@ local function on_pre_death(event)
|
|||||||
return
|
return
|
||||||
end
|
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)
|
local saviour_tokens = player.get_item_count(saviour_token_name)
|
||||||
if saviour_tokens < 1 then
|
if saviour_tokens < 1 then
|
||||||
return
|
return
|
||||||
@ -70,7 +87,7 @@ local function on_pre_death(event)
|
|||||||
|
|
||||||
game.print(
|
game.print(
|
||||||
table.concat {
|
table.concat {
|
||||||
player.name,
|
player_name,
|
||||||
' has been saved from a train death. Their ',
|
' has been saved from a train death. Their ',
|
||||||
saviour_token_name,
|
saviour_token_name,
|
||||||
' survival item has be used up.'
|
' survival item has be used up.'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
global.regulars = require 'resources.regulars'
|
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 Event = require 'utils.event'
|
||||||
local Utils = require 'utils.utils'
|
local Utils = require 'utils.utils'
|
||||||
|
|
||||||
@ -71,6 +72,15 @@ function Module.is_donator(player_name)
|
|||||||
return global.donators[player_name]
|
return global.donators[player_name]
|
||||||
end
|
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(
|
Event.add(
|
||||||
defines.events.on_player_joined_game,
|
defines.events.on_player_joined_game,
|
||||||
function(event)
|
function(event)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user