diff --git a/mods/ITEMS/mcl_potions/commands.lua b/mods/ITEMS/mcl_potions/commands.lua new file mode 100644 index 0000000000..4c38b394a6 --- /dev/null +++ b/mods/ITEMS/mcl_potions/commands.lua @@ -0,0 +1,56 @@ +local S = minetest.get_translator("mcl_potions") + +-- ░█████╗░██╗░░██╗░█████╗░████████╗  ░█████╗░░█████╗░███╗░░░███╗███╗░░░███╗░█████╗░███╗░░██╗██████╗░░██████╗ +-- ██╔══██╗██║░░██║██╔══██╗╚══██╔══╝  ██╔══██╗██╔══██╗████╗░████║████╗░████║██╔══██╗████╗░██║██╔══██╗██╔════╝ +-- ██║░░╚═╝███████║███████║░░░██║░░░  ██║░░╚═╝██║░░██║██╔████╔██║██╔████╔██║███████║██╔██╗██║██║░░██║╚█████╗░ +-- ██║░░██╗██╔══██║██╔══██║░░░██║░░░  ██║░░██╗██║░░██║██║╚██╔╝██║██║╚██╔╝██║██╔══██║██║╚████║██║░░██║░╚═══██╗ +-- ╚█████╔╝██║░░██║██║░░██║░░░██║░░░  ╚█████╔╝╚█████╔╝██║░╚═╝░██║██║░╚═╝░██║██║░░██║██║░╚███║██████╔╝██████╔╝ +-- ░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░  ░╚════╝░░╚════╝░╚═╝░░░░░╚═╝╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═════╝░╚═════╝░ + + +local get_chat_function = {} + +get_chat_function["poison"] = mcl_potions.poison_func +get_chat_function["regeneration"] = mcl_potions.regeneration_func +get_chat_function["invisibility"] = mcl_potions.invisiblility_func +get_chat_function["fire_resistance"] = mcl_potions.fire_resistance_func +get_chat_function["night_vision"] = mcl_potions.night_vision_func +get_chat_function["water_breathing"] = mcl_potions.water_breathing_func +get_chat_function["leaping"] = mcl_potions.leaping_func +get_chat_function["swiftness"] = mcl_potions.swiftness_func +get_chat_function["heal"] = mcl_potions.healing_func + +minetest.register_chatcommand("effect",{ + params = S(" []"), + description = S("Add a status effect to yourself. Arguments: : name of potion effect, e.g. poison. : duration in seconds. : effect strength multiplier (1 = 100%)"), + 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 + + if not P[1] then + return false, S("Missing effect parameter!") + elseif not tonumber(P[2]) then + return false, S("Missing or invalid duration parameter!") + elseif P[3] and not tonumber(P[3]) then + return false, S("Invalid factor parameter!") + end + -- Default factor = 1 + if not P[3] then + P[3] = 1.0 + end + + if get_chat_function[P[1]] then + get_chat_function[P[1]](minetest.get_player_by_name(name), tonumber(P[3]), tonumber(P[2])) + return true + else + return false, S("@1 is not an available potion effect.", P[1]) + end + + end, +}) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index d9233c6d3d..263427921b 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -1,5 +1,3 @@ -local S = minetest.get_translator("mcl_potions") - local is_invisible = {} local is_poisoned = {} local is_regenerating = {} @@ -883,58 +881,3 @@ function mcl_potions._extinguish_nearby_fire(pos, radius) return exting end - --- ░█████╗░██╗░░██╗░█████╗░████████╗  ░█████╗░░█████╗░███╗░░░███╗███╗░░░███╗░█████╗░███╗░░██╗██████╗░░██████╗ --- ██╔══██╗██║░░██║██╔══██╗╚══██╔══╝  ██╔══██╗██╔══██╗████╗░████║████╗░████║██╔══██╗████╗░██║██╔══██╗██╔════╝ --- ██║░░╚═╝███████║███████║░░░██║░░░  ██║░░╚═╝██║░░██║██╔████╔██║██╔████╔██║███████║██╔██╗██║██║░░██║╚█████╗░ --- ██║░░██╗██╔══██║██╔══██║░░░██║░░░  ██║░░██╗██║░░██║██║╚██╔╝██║██║╚██╔╝██║██╔══██║██║╚████║██║░░██║░╚═══██╗ --- ╚█████╔╝██║░░██║██║░░██║░░░██║░░░  ╚█████╔╝╚█████╔╝██║░╚═╝░██║██║░╚═╝░██║██║░░██║██║░╚███║██████╔╝██████╔╝ --- ░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░  ░╚════╝░░╚════╝░╚═╝░░░░░╚═╝╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═════╝░╚═════╝░ - - -local get_chat_function = {} - -get_chat_function["poison"] = mcl_potions.poison_func -get_chat_function["regeneration"] = mcl_potions.regeneration_func -get_chat_function["invisibility"] = mcl_potions.invisiblility_func -get_chat_function["fire_resistance"] = mcl_potions.fire_resistance_func -get_chat_function["night_vision"] = mcl_potions.night_vision_func -get_chat_function["water_breathing"] = mcl_potions.water_breathing_func -get_chat_function["leaping"] = mcl_potions.leaping_func -get_chat_function["swiftness"] = mcl_potions.swiftness_func -get_chat_function["heal"] = mcl_potions.healing_func - -minetest.register_chatcommand("effect",{ - params = S(" []"), - description = S("Add a status effect to yourself. Arguments: : name of potion effect, e.g. poison. : duration in seconds. : effect strength multiplier (1 = 100%)"), - 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 - - if not P[1] then - return false, S("Missing effect parameter!") - elseif not tonumber(P[2]) then - return false, S("Missing or invalid duration parameter!") - elseif P[3] and not tonumber(P[3]) then - return false, S("Invalid factor parameter!") - end - -- Default factor = 1 - if not P[3] then - P[3] = 1.0 - end - - if get_chat_function[P[1]] then - get_chat_function[P[1]](minetest.get_player_by_name(name), tonumber(P[3]), tonumber(P[2])) - return true - else - return false, S("@1 is not an available potion effect.", P[1]) - end - - end, -}) diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index a712005e7e..1083b0c334 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -19,6 +19,7 @@ mcl_potions.LINGERING_FACTOR = 0.25 local modpath = minetest.get_modpath("mcl_potions") dofile(modpath .. "/functions.lua") +dofile(modpath .. "/commands.lua") dofile(modpath .. "/splash.lua") dofile(modpath .. "/lingering.lua") dofile(modpath .. "/tipped_arrow.lua")