mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-07-03 16:10:26 +02:00
Add MT 5.0.0 translation support
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
local S = minetest.get_translator("mesecons_commandblock")
|
||||
local F = minetest.formspec_escape
|
||||
|
||||
minetest.register_chatcommand("say", {
|
||||
params = "<text>",
|
||||
description = "Say <text> as the server",
|
||||
params = S("<text>"),
|
||||
description = S("Say <text> as the server"),
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
minetest.chat_send_all(name .. ": " .. param)
|
||||
@ -8,36 +11,36 @@ minetest.register_chatcommand("say", {
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("tell", {
|
||||
params = "<name> <text>",
|
||||
description = "Say <text> to <name> privately",
|
||||
params = S("<name> <text>"),
|
||||
description = S("Say <text> to <name> privately"),
|
||||
func = function(name, param)
|
||||
local found, _, target, message = param:find("^([^%s]+)%s+(.*)$")
|
||||
if found == nil then
|
||||
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||
minetest.chat_send_player(name, S("Invalid usage: @1", param))
|
||||
return
|
||||
end
|
||||
if not minetest.get_player_by_name(target) then
|
||||
minetest.chat_send_player(name, "Invalid target: " .. target)
|
||||
minetest.chat_send_player(name, S("Invalid target: @1", target))
|
||||
end
|
||||
minetest.chat_send_player(target, name .. " whispers: " .. message, false)
|
||||
minetest.chat_send_player(target, S("@1 whispers: @2", name, message), false)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("hp", {
|
||||
params = "<name> <value>",
|
||||
description = "Set health of <name> to <value> hitpoints",
|
||||
params = S("<name> <value>"),
|
||||
description = S("Set health of <name> to <value> hitpoints"),
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
local found, _, target, value = param:find("^([^%s]+)%s+(%d+)$")
|
||||
if found == nil then
|
||||
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||
minetest.chat_send_player(name, S("Invalid usage: @1", param))
|
||||
return
|
||||
end
|
||||
local player = minetest.get_player_by_name(target)
|
||||
if player then
|
||||
player:set_hp(value)
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid target: " .. target)
|
||||
minetest.chat_send_player(name, S("Invalid target: @1", target))
|
||||
end
|
||||
end
|
||||
})
|
||||
@ -46,18 +49,19 @@ local function initialize_data(meta)
|
||||
local commands = minetest.formspec_escape(meta:get_string("commands"))
|
||||
meta:set_string("formspec",
|
||||
"invsize[9,5;]" ..
|
||||
"textarea[0.5,0.5;8.5,4;commands;Commands;"..commands.."]" ..
|
||||
"label[1,3.8;@nearest, @farthest, and @random are replaced by the respective player names]" ..
|
||||
"button_exit[3.3,4.5;2,1;submit;Submit]")
|
||||
"textarea[0.5,0.5;8.5,4;commands;"..F(S("Commands"))..";"..commands.."]" ..
|
||||
"label[1,3.8;"..F(S("@nearest, @farthest, and @random are replaced by the respective player names"))"]" ..
|
||||
"button_exit[3.3,4.5;2,1;submit;"..F(S("Submit")).."]")
|
||||
local owner = meta:get_string("owner")
|
||||
local ownstr = ""
|
||||
if owner == "" then
|
||||
owner = "not owned"
|
||||
ownstr = S("(not owned)")
|
||||
else
|
||||
owner = "owned by " .. owner
|
||||
ownstr = S("(owned by @1)", owner)
|
||||
end
|
||||
meta:set_string("infotext", "Command Block\n" ..
|
||||
"(" .. owner .. ")\n" ..
|
||||
"Commands: "..commands)
|
||||
meta:set_string("infotext", S("Command Block").."\n" ..
|
||||
ownstr .. "\n" ..
|
||||
S("Commands: @1", commands))
|
||||
end
|
||||
|
||||
local function construct(pos)
|
||||
@ -150,15 +154,15 @@ local function commandblock_action_on(pos, node)
|
||||
end
|
||||
local cmddef = minetest.chatcommands[cmd]
|
||||
if not cmddef then
|
||||
minetest.chat_send_player(owner, "The command "..cmd.." does not exist")
|
||||
minetest.chat_send_player(owner, S("The command @1 does not exist", cmd))
|
||||
return
|
||||
end
|
||||
local has_privs, missing_privs = minetest.check_player_privs(owner, cmddef.privs)
|
||||
if not has_privs then
|
||||
minetest.chat_send_player(owner, "You don't have permission "
|
||||
.."to run "..cmd
|
||||
.." (missing privileges: "
|
||||
..table.concat(missing_privs, ", ")..")")
|
||||
minetest.chat_send_player(owner,
|
||||
S("You don't have permission to run @1 (missing privileges: @2)",
|
||||
cmd,
|
||||
table.concat(missing_privs, ", ")))
|
||||
return
|
||||
end
|
||||
cmddef.func(owner, param)
|
||||
@ -178,7 +182,7 @@ local function can_dig(pos, player)
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_commandblock:commandblock_off", {
|
||||
description = "Command Block",
|
||||
description = S("Command Block"),
|
||||
tiles = {"jeija_commandblock_off.png"},
|
||||
inventory_image = minetest.inventorycube("jeija_commandblock_off.png"),
|
||||
is_ground_content = false,
|
||||
|
Reference in New Issue
Block a user