Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4efe71378c | ||
|
d3d432b33a | ||
|
bf800aa5f9 | ||
|
f491c3cfc4 | ||
|
2100a02fb8 | ||
|
968f655466 | ||
|
aef179d878 | ||
|
82abee5669 |
@ -1,8 +1,8 @@
|
||||
# Central Message
|
||||
## Overview
|
||||
* Description: Simple API to display short messages at the center of the screen
|
||||
* Description: Simple API and server command to display short messages at the center of the screen
|
||||
* Author: Wuzzy
|
||||
* License of everything: WTFPL
|
||||
* License of everything: MIT License
|
||||
* Shortname: `central_message`
|
||||
* Version: 0.3.0 (using Semantic Versioning 2.0.0, see [SemVer](http://semver.org/))
|
||||
|
||||
@ -12,6 +12,9 @@ Each message is displayed for a few seconds, then it is removed.
|
||||
When multiple messages are pushed quickly in succession, the messages will be “stacked”
|
||||
on the screen.
|
||||
|
||||
This mod adds the server command “cmsg” as well as an API for mods to display messages.
|
||||
The syntax is “`/cmsg <player> <text>`”. If `<player>` is “*”, the message is sent to all players.
|
||||
|
||||
This mod can be useful to inform about all sorts of events and is an alternative to use the chat log
|
||||
to display special events.
|
||||
|
||||
@ -21,6 +24,7 @@ Some usage examples:
|
||||
* Error message directed to a single player
|
||||
* Informational messages
|
||||
* Administational messages to warn players about a coming server shutdown
|
||||
* Show messages by using a command block from Mesecons
|
||||
|
||||
## Settings
|
||||
This mod can be configured via `minetest.conf`.
|
||||
|
@ -1 +0,0 @@
|
||||
Simple API to show messages to the center of the screen to players.
|
31
init.lua
31
init.lua
@ -1,3 +1,5 @@
|
||||
local S = minetest.get_translator("central_message")
|
||||
|
||||
cmsg = {}
|
||||
cmsg.hudids = {}
|
||||
cmsg.messages = {}
|
||||
@ -92,6 +94,7 @@ cmsg.push_message_player = function(player, text)
|
||||
direction = 3,
|
||||
alignment = {x=0,y=1},
|
||||
scale = {x=800,y=20*cmsg.settings.max_messages},
|
||||
z_index = 10,
|
||||
})
|
||||
cmsg.messages[pname] = {}
|
||||
cmsg.next_msgids[pname] = 0
|
||||
@ -141,6 +144,34 @@ minetest.register_on_leaveplayer(function(player)
|
||||
cmsg.hudids[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
minetest.register_privilege("announce", {
|
||||
description = S("Can use /cmsg"),
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
minetest.register_chatcommand("cmsg", {
|
||||
description = S("Show message in the center of the screen to player (“*” sends to all players)"),
|
||||
privs = {announce = true},
|
||||
params = S("<player> <text>"),
|
||||
func = function(name, params)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local targetname, text = string.match(params, "^(%S+)%s(.+)$")
|
||||
if not targetname then
|
||||
return false, S("Invalid usage, see “/help cmsg”.")
|
||||
end
|
||||
if targetname == "*" then
|
||||
cmsg.push_message_all(text)
|
||||
return true, S("Message sent.")
|
||||
else
|
||||
local target = minetest.get_player_by_name(targetname)
|
||||
if not target then
|
||||
return false, S("The player @1 is not online.", targetname)
|
||||
end
|
||||
cmsg.push_message_player(target, text)
|
||||
return true, S("Message sent.")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Horrible Workaround code starts here
|
||||
cmsg.steps = 0
|
||||
cmsg.last_push = -1
|
||||
|
7
locale/central_message.de.tr
Normal file
7
locale/central_message.de.tr
Normal file
@ -0,0 +1,7 @@
|
||||
# textdomain:central_message
|
||||
Can use /cmsg=Kann /cmsg benutzen
|
||||
Show message in the center of the screen to player (“*” sends to all players)")=Nachricht in Mitte des Bildschirms an Spieler senden („*“ sendet an alle Spieler)
|
||||
<player> <text>=<Spieler> <Text>
|
||||
Invalid usage, see “/help cmsg”.=Ungültige Verwendung, siehe „/help cmsg“.
|
||||
Message sent.=Nachricht gesendet.
|
||||
The player @1 is not online.=Der Spieler @1 ist nicht online.
|
7
locale/template.txt
Normal file
7
locale/template.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# textdomain:central_message
|
||||
Can use /cmsg=
|
||||
Show message in the center of the screen to player (“*” sends to all players)")=
|
||||
<player> <text>=
|
||||
Invalid usage, see “/help cmsg”.=
|
||||
Message sent.=
|
||||
The player @1 is not online.=
|
Loading…
x
Reference in New Issue
Block a user