forked from VoxeLibre/VoxeLibre
Improved /effect command return messages
Also improved the name of a variable
This commit is contained in:
parent
b6a574ae66
commit
3aa6a2a816
|
@ -10,7 +10,7 @@ local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
|
||||||
minetest.register_chatcommand("effect",{
|
minetest.register_chatcommand("effect",{
|
||||||
params = S("<effect>|heal|list <duration|heal-amount> [<level>] [<factor>]"),
|
params = S("<effect>|heal|list <duration|heal-amount> [<level>] [<factor>]"),
|
||||||
description = S("Add a status effect to yourself. Arguments: <effect>: name of status effect, e.g. poison. Passing list as effect name lists available effects. Passing heal as effect name heals (or harms) by amount designed by the next parameter. <duration>: duration in seconds. (<heal-amount>: amount of healing when the effect is heal, passing a negative value subtracts health.) <level>: effect power determinant, bigger level results in more powerful effect for effects that depend on the level, defaults to 1, pass F to use low-level factor instead. <factor>: effect strength modifier, can mean different things depending on the effect."),
|
description = S("Add a status effect to yourself. Arguments: <effect>: name of status effect. Passing \"list\" as effect name lists available effects. Passing \"heal\" as effect name heals (or harms) by amount designed by the next parameter. <duration>: duration in seconds. (<heal-amount>: amount of healing when the effect is \"heal\", passing a negative value subtracts health.) <level>: effect power determinant, bigger level results in more powerful effect for effects that depend on the level (no changes for other effects), defaults to 1, pass F to use low-level factor instead. <factor>: effect strength modifier, can mean different things depending on the effect, no changes for effects that do not depend on level/factor."),
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
func = function(name, params)
|
func = function(name, params)
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ minetest.register_chatcommand("effect",{
|
||||||
return false, S("Missing effect parameter!")
|
return false, S("Missing effect parameter!")
|
||||||
elseif P[1] == "list" then
|
elseif P[1] == "list" then
|
||||||
local effects = "heal"
|
local effects = "heal"
|
||||||
for name, _ in pairs(mcl_potions.registered_effects) do
|
for effect, _ in pairs(mcl_potions.registered_effects) do
|
||||||
effects = effects .. ", " .. name
|
effects = effects .. ", " .. effect
|
||||||
end
|
end
|
||||||
return true, effects
|
return true, effects
|
||||||
elseif P[1] == "heal" then
|
elseif P[1] == "heal" then
|
||||||
|
@ -61,14 +61,22 @@ minetest.register_chatcommand("effect",{
|
||||||
if P[3] == "F" then
|
if P[3] == "F" then
|
||||||
local given = mcl_potions.give_effect(P[1], minetest.get_player_by_name(name), tonumber(P[4]), tonumber(P[2]))
|
local given = mcl_potions.give_effect(P[1], minetest.get_player_by_name(name), tonumber(P[4]), tonumber(P[2]))
|
||||||
if given then
|
if given then
|
||||||
|
if def.uses_factor then
|
||||||
return true, S("@1 effect given to player @2 for @3 seconds with factor of @4.", def.description, name, P[2], P[4])
|
return true, S("@1 effect given to player @2 for @3 seconds with factor of @4.", def.description, name, P[2], P[4])
|
||||||
|
else
|
||||||
|
return true, S("@1 effect given to player @2 for @3 seconds.", def.description, name, P[2])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return false, S("Giving effect @1 to player @2 failed.", def.description, name)
|
return false, S("Giving effect @1 to player @2 failed.", def.description, name)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local given = mcl_potions.give_effect_by_level(P[1], minetest.get_player_by_name(name), tonumber(P[3]), tonumber(P[2]))
|
local given = mcl_potions.give_effect_by_level(P[1], minetest.get_player_by_name(name), tonumber(P[3]), tonumber(P[2]))
|
||||||
if given then
|
if given then
|
||||||
|
if def.uses_factor then
|
||||||
return true, S("@1 effect on level @2 given to player @3 for @4 seconds.", def.description, P[3], name, P[2])
|
return true, S("@1 effect on level @2 given to player @3 for @4 seconds.", def.description, P[3], name, P[2])
|
||||||
|
else
|
||||||
|
return true, S("@1 effect given to player @2 for @3 seconds.", def.description, name, P[2])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return false, S("Giving effect @1 to player @2 failed.", def.description, name)
|
return false, S("Giving effect @1 to player @2 failed.", def.description, name)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue