mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 16:39:33 +01:00
mcl_potions: Move command to own file
This commit is contained in:
parent
f4f976a7a5
commit
2a7edbde49
3 changed files with 57 additions and 57 deletions
56
mods/ITEMS/mcl_potions/commands.lua
Normal file
56
mods/ITEMS/mcl_potions/commands.lua
Normal file
|
@ -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("<effect> <duration> [<factor>]"),
|
||||||
|
description = S("Add a status effect to yourself. Arguments: <effect>: name of potion effect, e.g. poison. <duration>: duration in seconds. <factor>: 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,
|
||||||
|
})
|
|
@ -1,5 +1,3 @@
|
||||||
local S = minetest.get_translator("mcl_potions")
|
|
||||||
|
|
||||||
local is_invisible = {}
|
local is_invisible = {}
|
||||||
local is_poisoned = {}
|
local is_poisoned = {}
|
||||||
local is_regenerating = {}
|
local is_regenerating = {}
|
||||||
|
@ -883,58 +881,3 @@ function mcl_potions._extinguish_nearby_fire(pos, radius)
|
||||||
return exting
|
return exting
|
||||||
end
|
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("<effect> <duration> [<factor>]"),
|
|
||||||
description = S("Add a status effect to yourself. Arguments: <effect>: name of potion effect, e.g. poison. <duration>: duration in seconds. <factor>: 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,
|
|
||||||
})
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ mcl_potions.LINGERING_FACTOR = 0.25
|
||||||
|
|
||||||
local modpath = minetest.get_modpath("mcl_potions")
|
local modpath = minetest.get_modpath("mcl_potions")
|
||||||
dofile(modpath .. "/functions.lua")
|
dofile(modpath .. "/functions.lua")
|
||||||
|
dofile(modpath .. "/commands.lua")
|
||||||
dofile(modpath .. "/splash.lua")
|
dofile(modpath .. "/splash.lua")
|
||||||
dofile(modpath .. "/lingering.lua")
|
dofile(modpath .. "/lingering.lua")
|
||||||
dofile(modpath .. "/tipped_arrow.lua")
|
dofile(modpath .. "/tipped_arrow.lua")
|
||||||
|
|
Loading…
Reference in a new issue