Compare commits
5 Commits
968f655466
...
4efe71378c
Author | SHA1 | Date |
---|---|---|
Wuzzy | 4efe71378c | |
Wuzzy | d3d432b33a | |
Wuzzy | bf800aa5f9 | |
Wuzzy | f491c3cfc4 | |
Wuzzy | 2100a02fb8 |
|
@ -2,7 +2,7 @@
|
||||||
## Overview
|
## Overview
|
||||||
* Description: Simple API and server command 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
|
* Author: Wuzzy
|
||||||
* License of everything: WTFPL
|
* License of everything: MIT License
|
||||||
* Shortname: `central_message`
|
* Shortname: `central_message`
|
||||||
* Version: 0.3.0 (using Semantic Versioning 2.0.0, see [SemVer](http://semver.org/))
|
* Version: 0.3.0 (using Semantic Versioning 2.0.0, see [SemVer](http://semver.org/))
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Simple API to show messages to the center of the screen to players.
|
|
17
init.lua
17
init.lua
|
@ -1,3 +1,5 @@
|
||||||
|
local S = minetest.get_translator("central_message")
|
||||||
|
|
||||||
cmsg = {}
|
cmsg = {}
|
||||||
cmsg.hudids = {}
|
cmsg.hudids = {}
|
||||||
cmsg.messages = {}
|
cmsg.messages = {}
|
||||||
|
@ -92,6 +94,7 @@ cmsg.push_message_player = function(player, text)
|
||||||
direction = 3,
|
direction = 3,
|
||||||
alignment = {x=0,y=1},
|
alignment = {x=0,y=1},
|
||||||
scale = {x=800,y=20*cmsg.settings.max_messages},
|
scale = {x=800,y=20*cmsg.settings.max_messages},
|
||||||
|
z_index = 10,
|
||||||
})
|
})
|
||||||
cmsg.messages[pname] = {}
|
cmsg.messages[pname] = {}
|
||||||
cmsg.next_msgids[pname] = 0
|
cmsg.next_msgids[pname] = 0
|
||||||
|
@ -142,29 +145,29 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_privilege("announce", {
|
minetest.register_privilege("announce", {
|
||||||
description = "Can use /cmsg",
|
description = S("Can use /cmsg"),
|
||||||
give_to_singleplayer = false,
|
give_to_singleplayer = false,
|
||||||
})
|
})
|
||||||
minetest.register_chatcommand("cmsg", {
|
minetest.register_chatcommand("cmsg", {
|
||||||
description = "Show message in the center of the screen to player (“*” sends to all players)",
|
description = S("Show message in the center of the screen to player (“*” sends to all players)"),
|
||||||
privs = {announce = true},
|
privs = {announce = true},
|
||||||
params = "<player> <text>",
|
params = S("<player> <text>"),
|
||||||
func = function(name, params)
|
func = function(name, params)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
local targetname, text = string.match(params, "^(%S+)%s(.+)$")
|
local targetname, text = string.match(params, "^(%S+)%s(.+)$")
|
||||||
if not targetname then
|
if not targetname then
|
||||||
return false, "Invalid usage, see /help title"
|
return false, S("Invalid usage, see “/help cmsg”.")
|
||||||
end
|
end
|
||||||
if targetname == "*" then
|
if targetname == "*" then
|
||||||
cmsg.push_message_all(text)
|
cmsg.push_message_all(text)
|
||||||
return true, "Message sent."
|
return true, S("Message sent.")
|
||||||
else
|
else
|
||||||
local target = minetest.get_player_by_name(targetname)
|
local target = minetest.get_player_by_name(targetname)
|
||||||
if not target then
|
if not target then
|
||||||
return false, "The player "..targetname.." is not online."
|
return false, S("The player @1 is not online.", targetname)
|
||||||
end
|
end
|
||||||
cmsg.push_message_player(target, text)
|
cmsg.push_message_player(target, text)
|
||||||
return true, "Message sent."
|
return true, S("Message sent.")
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -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.
|
|
@ -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…
Reference in New Issue