forked from VoxeLibre/VoxeLibre
refine some commands to match last changes
This commit is contained in:
parent
f90243f6e5
commit
a22188ccf4
|
@ -71,3 +71,4 @@ If not specified, a value will be by default with the word pattern.
|
|||
|
||||
TODO:
|
||||
* color value must be a color string or a valid named color
|
||||
* nodename value must be a valid node name
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
local S = minetest.get_translator("mcl_commands")
|
||||
|
||||
minetest.register_chatcommand("setblock", {
|
||||
params = S("<X>,<Y>,<Z> <NodeString>"),
|
||||
description = S("Set node at given position"),
|
||||
privs = {give=true, interact=true},
|
||||
func = function(name, param)
|
||||
local p = {}
|
||||
local nodestring = nil
|
||||
p.x, p.y, p.z, nodestring = param:match("^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) +(.+)$")
|
||||
p.x, p.y, p.z = tonumber(p.x), tonumber(p.y), tonumber(p.z)
|
||||
if p.x and p.y and p.z and nodestring then
|
||||
mcl_commands.register_command("setblock", {
|
||||
func = function(cmd)
|
||||
cmd:sub(":pos:pos :node:text", { --TODO:replace by upcomming nodename type
|
||||
func = function(name)
|
||||
local itemstack = ItemStack(nodestring)
|
||||
if itemstack:is_empty() or not minetest.registered_nodes[itemstack:get_name()] then
|
||||
return false, S("Invalid node")
|
||||
return false, S("Invalid node") --workaround
|
||||
end
|
||||
minetest.set_node(p, {name=nodestring})
|
||||
return true, S("@1 spawned.", nodestring)
|
||||
end
|
||||
return false, S("Invalid parameters (see /help setblock)")
|
||||
--return false, S("Invalid parameters (see /help setblock)")
|
||||
end,
|
||||
privs = {},
|
||||
})
|
||||
end,
|
||||
description = S("Set node at given position"),
|
||||
params = S("<X>,<Y>,<Z> <NodeString>"),
|
||||
privs = {give=true, interact=true},
|
||||
})
|
|
@ -1,48 +1,19 @@
|
|||
local S = minetest.get_translator("mcl_commands")
|
||||
|
||||
minetest.register_chatcommand("playsound",{
|
||||
params = S("<sound> <target>"), --TODO:add source
|
||||
description = S("Play a sound. Arguments: <sound>: name of the sound. <target>: Target."),
|
||||
privs = {server = true},
|
||||
func = function(name, params)
|
||||
local P = {}
|
||||
local i = 0
|
||||
for str in string.gmatch(params, "([^ ]+)") do
|
||||
i = i + 1
|
||||
P[i] = str
|
||||
end
|
||||
|
||||
local params = {}
|
||||
if P[1] == tostring(P[1]) then
|
||||
params.name = P[1]
|
||||
mcl_commands.register_command("playsound", {
|
||||
func = function(cmd)
|
||||
cmd:sub(":sound:word :target:username", { --TODO:replace by upcomming types
|
||||
func = function(name, sound, target)
|
||||
if minetest.player_exists(target) then
|
||||
minetest.sound_play({name = sound}, {to_player = target}, true) --TODO:add source, gain, pitch
|
||||
else
|
||||
return false, S("Sound name is invalid!") --TODO: add mc chat message
|
||||
return false, S("Target is invalid!!") --TODO: add mc chat message
|
||||
end
|
||||
|
||||
if P[2] == tostring(P[2]) and minetest.player_exists(P[2]) then
|
||||
params.target = P[2]
|
||||
else
|
||||
return false, S("Target is invalid!!")
|
||||
end
|
||||
|
||||
-- if P[3] then
|
||||
-- params.pos = nil --TODO:position
|
||||
-- else
|
||||
-- params.pos = nil
|
||||
-- end
|
||||
|
||||
-- if P[4] == tonumber(P[4]) then
|
||||
-- params.gain = P[4]
|
||||
-- else
|
||||
-- params.gain = 1.0
|
||||
-- end
|
||||
|
||||
-- if P[5] == tonumber(P[5]) then
|
||||
-- params.pitch = P[5]
|
||||
-- else
|
||||
-- params.pitch = 1.0
|
||||
-- end
|
||||
minetest.sound_play({name = params.name}, {to_player = params.target}, true) --TODO: /stopsound
|
||||
return true
|
||||
end,
|
||||
privs = {},
|
||||
})
|
||||
end,
|
||||
description = S("Play a sound. Arguments: <sound>: name of the sound. <target>: Target."),
|
||||
params = S("<sound> <target>"),
|
||||
privs = {server = true},
|
||||
})
|
Loading…
Reference in New Issue