mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
Add toast command
This commit is contained in:
parent
52ef181117
commit
e4eff300f2
@ -2,11 +2,16 @@ local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Gui = require 'utils.gui'
|
||||
local Token = require 'utils.token'
|
||||
local Command = require 'utils.command'
|
||||
local Utils = require 'utils.core'
|
||||
local Game = require 'utils.game'
|
||||
local Settings = require 'utils.redmew_settings'
|
||||
local Color = require 'resources.color_presets'
|
||||
local Ranks = require 'resources.ranks'
|
||||
|
||||
local pairs = pairs
|
||||
local next = next
|
||||
local format = string.format
|
||||
|
||||
local toast_volume_name = 'toast-volume'
|
||||
Settings.register(toast_volume_name, 'fraction', 1.0)
|
||||
@ -247,4 +252,40 @@ function Public.toast_all_players(duration, message)
|
||||
end
|
||||
end
|
||||
|
||||
Command.add(
|
||||
'toast-all',
|
||||
{
|
||||
description = 'Sends a toast to all players',
|
||||
arguments = {'msg'},
|
||||
capture_excess_arguments = true,
|
||||
required_rank = Ranks.admin,
|
||||
allowed_by_server = true
|
||||
},
|
||||
function(args)
|
||||
Public.toast_all_players(15, args.msg)
|
||||
Utils.print_admins(format('%s sent a toast to all players', Utils.get_actor()))
|
||||
end
|
||||
)
|
||||
|
||||
Command.add(
|
||||
'toast-player',
|
||||
{
|
||||
description = 'Sends a toast to a specific player',
|
||||
arguments = {'player', 'msg'},
|
||||
capture_excess_arguments = true,
|
||||
required_rank = Ranks.admin,
|
||||
allowed_by_server = true
|
||||
},
|
||||
function(args)
|
||||
local player_name = args.player
|
||||
local player = game.players[player_name]
|
||||
if player then
|
||||
Public.toast_player(player, 15, args.msg)
|
||||
Utils.print_admins(format('%s sent a toast to %s', Utils.get_actor(), player_name))
|
||||
else
|
||||
Game.player_print({'common.fail_no_target'}, Color.yellow)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
|
@ -1,3 +1,6 @@
|
||||
[common]
|
||||
fail_no_target=Target not found
|
||||
|
||||
[ranks]
|
||||
probation=Probation
|
||||
guest=Guest
|
||||
@ -31,3 +34,7 @@ run_twice=The game has been saved, run the command again to commence the apocaly
|
||||
apocalypse_begins=The ground begins to rumble. It seems as if the world itself is coming to an end.
|
||||
apocalypse_already_running=The apocalypse has already begun. There is nothing more to do in this world.
|
||||
toast_message=The end times are here. The four biters of the apocalypse have been summoned. Repent as the aliens take back what is theirs.
|
||||
|
||||
[toast]
|
||||
toast_all=__1__ sent a toast to all players.
|
||||
toast_player=__1__ sent a toast to __2__.
|
||||
|
Loading…
x
Reference in New Issue
Block a user