2021-05-29 14:12:33 +00:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
2021-04-17 07:26:37 +00:00
--local brewhelp = S("Try different combinations to create potions.")
2020-06-17 21:50:18 +00:00
2021-05-29 14:12:33 +00:00
local function potion_image ( colorstring , opacity )
2020-06-17 21:50:18 +00:00
if not opacity then
opacity = 127
end
2020-07-03 22:33:24 +00:00
return " mcl_potions_potion_overlay.png^[colorize: " .. colorstring .. " : " .. tostring ( opacity ) .. " ^mcl_potions_potion_bottle.png "
2020-06-17 21:50:18 +00:00
end
local how_to_drink = S ( " Use the “Place” key to drink it. " )
2020-08-01 01:20:52 +00:00
local potion_intro = S ( " Drinking a potion gives you a particular effect. " )
2020-06-17 21:50:18 +00:00
2020-07-12 00:26:45 +00:00
local function time_string ( dur )
2020-08-08 08:00:16 +00:00
if not dur then
return nil
end
2020-07-12 00:26:45 +00:00
return math.floor ( dur / 60 ) .. string.format ( " :%02d " , math.floor ( dur % 60 ) )
end
2020-07-17 00:56:00 +00:00
local function perc_string ( num )
2020-07-17 01:02:21 +00:00
local rem = math.floor ( ( num - 1.0 ) * 100 + 0.1 ) % 5
local out = math.floor ( ( num - 1.0 ) * 100 + 0.1 ) - rem
2020-07-17 00:56:00 +00:00
if ( num - 1.0 ) < 0 then
2020-07-17 01:02:21 +00:00
return out .. " % "
2020-07-17 00:56:00 +00:00
else
2020-07-17 01:02:21 +00:00
return " + " .. out .. " % "
2020-07-17 00:56:00 +00:00
end
end
2020-07-11 17:40:48 +00:00
2020-07-22 21:46:49 +00:00
-- ██████╗░███████╗░██████╗░██╗░██████╗████████╗███████╗██████╗░
-- ██╔══██╗██╔════╝██╔════╝░██║██╔════╝╚══██╔══╝██╔════╝██╔══██╗
-- ██████╔╝█████╗░░██║░░██╗░██║╚█████╗░░░░██║░░░█████╗░░██████╔╝
-- ██╔══██╗██╔══╝░░██║░░╚██╗██║░╚═══██╗░░░██║░░░██╔══╝░░██╔══██╗
-- ██║░░██║███████╗╚██████╔╝██║██████╔╝░░░██║░░░███████╗██║░░██║
-- ╚═╝░░╚═╝╚══════╝░╚═════╝░╚═╝╚═════╝░░░░╚═╝░░░╚══════╝╚═╝░░╚═╝
--
-- ██████╗░░█████╗░████████╗██╗░█████╗░███╗░░██╗░██████╗
-- ██╔══██╗██╔══██╗╚══██╔══╝██║██╔══██╗████╗░██║██╔════╝
-- ██████╔╝██║░░██║░░░██║░░░██║██║░░██║██╔██╗██║╚█████╗░
-- ██╔═══╝░██║░░██║░░░██║░░░██║██║░░██║██║╚████║░╚═══██╗
-- ██║░░░░░╚█████╔╝░░░██║░░░██║╚█████╔╝██║░╚███║██████╔╝
-- ╚═╝░░░░░░╚════╝░░░░╚═╝░░░╚═╝░╚════╝░╚═╝░░╚══╝╚═════╝░
2020-08-10 08:30:00 +00:00
function return_on_use ( def , effect , dur )
return function ( itemstack , user , pointed_thing )
if pointed_thing.type == " node " then
if user and not user : get_player_control ( ) . sneak then
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node ( pointed_thing.under )
if user and not user : get_player_control ( ) . sneak then
if minetest.registered_nodes [ node.name ] and minetest.registered_nodes [ node.name ] . on_rightclick then
return minetest.registered_nodes [ node.name ] . on_rightclick ( pointed_thing.under , node , user , itemstack ) or itemstack
end
end
end
elseif pointed_thing.type == " object " then
return itemstack
end
2024-01-15 06:08:02 +00:00
--def.on_use(user, effect, dur) -- Will do effect immediately but not reduce item count until eating delay ends which makes it exploitable by deliberately not finishing delay
-- Wrapper for handling mcl_hunger delayed eating
local name = user : get_player_name ( )
mcl_hunger.eat_internal [ name ] . _custom_itemstack = itemstack -- Used as comparison to make sure the custom wrapper executes only when the same item is eaten
mcl_hunger.eat_internal [ name ] . _custom_var = {
user = user ,
effect = effect ,
dur = dur ,
}
mcl_hunger.eat_internal [ name ] . _custom_func = def.on_use
mcl_hunger.eat_internal [ name ] . _custom_wrapper = function ( name )
mcl_hunger.eat_internal [ name ] . _custom_func (
mcl_hunger.eat_internal [ name ] . _custom_var.user ,
mcl_hunger.eat_internal [ name ] . _custom_var.effect ,
mcl_hunger.eat_internal [ name ] . _custom_var.dur
)
end
2020-08-13 16:16:53 +00:00
local old_name , old_count = itemstack : get_name ( ) , itemstack : get_count ( )
itemstack = minetest.do_item_eat ( 0 , " mcl_potions:glass_bottle " , itemstack , user , pointed_thing )
if old_name ~= itemstack : get_name ( ) or old_count ~= itemstack : get_count ( ) then
mcl_potions._use_potion ( itemstack , user , def.color )
end
return itemstack
2020-08-10 08:30:00 +00:00
end
end
2020-07-11 17:40:48 +00:00
local function register_potion ( def )
2020-07-12 00:26:45 +00:00
local dur = mcl_potions.DURATION
if def.is_inv then
dur = dur * mcl_potions.INV_FACTOR
end
2023-08-08 00:53:01 +00:00
if def.name == " poison " or def.name == " regeneration " or def.name == " withering " then
2020-07-12 00:26:45 +00:00
dur = 45
end
2020-08-08 21:48:03 +00:00
local on_use = nil
if def.on_use then
2020-08-10 08:30:00 +00:00
on_use = return_on_use ( def , def.effect , dur )
2020-08-08 21:48:03 +00:00
end
2020-07-12 00:26:45 +00:00
2020-07-12 11:18:54 +00:00
local function get_tt ( tt , effect , dur )
local _tt
if effect and def.is_dur then
2020-07-17 00:56:00 +00:00
_tt = perc_string ( effect ) .. " | " .. time_string ( dur )
2023-08-08 00:53:01 +00:00
if def.name == " poison " or def.name == " regeneration " or def.name == " withering " then
2020-08-05 13:10:05 +00:00
_tt = S ( " 1 HP/@1s | @2 " , effect , time_string ( dur ) )
2020-07-12 11:18:54 +00:00
end
2020-07-12 11:59:29 +00:00
elseif def.name == " healing " or def.name == " harming " then
2020-08-05 13:10:05 +00:00
_tt = S ( " @1 HP " , effect )
2021-04-17 07:26:37 +00:00
else
2020-07-12 11:18:54 +00:00
_tt = tt or time_string ( dur ) or S ( " No effect " )
2020-07-12 00:26:45 +00:00
end
2020-07-12 11:18:54 +00:00
return _tt
2020-07-12 00:26:45 +00:00
end
2020-07-12 11:35:11 +00:00
local function get_splash_fun ( effect , sp_dur )
2020-07-12 11:59:29 +00:00
if def.is_dur then
2020-07-12 11:35:11 +00:00
return function ( player , redx ) def.on_use ( player , effect , sp_dur * redx ) end
2020-07-12 16:32:54 +00:00
elseif def.effect then
2020-07-12 11:35:11 +00:00
return function ( player , redx ) def.on_use ( player , effect * redx , sp_dur ) end
end
2020-07-12 16:32:54 +00:00
-- covers case of no effect (water, awkward, mundane)
2020-07-13 01:15:54 +00:00
return function ( ) end
2020-07-12 11:35:11 +00:00
end
2020-07-19 22:56:18 +00:00
local function get_lingering_fun ( effect , ling_dur )
if def.is_dur then
return function ( player ) def.on_use ( player , effect , ling_dur ) end
elseif def.effect then
return function ( player ) def.on_use ( player , effect * 0.5 , ling_dur ) end
end
-- covers case of no effect (water, awkward, mundane)
return function ( ) end
end
2020-07-20 01:08:50 +00:00
local function get_arrow_fun ( effect , dur )
2020-07-12 11:59:29 +00:00
if def.is_dur then
2020-07-20 01:08:50 +00:00
return function ( player ) def.on_use ( player , effect , dur ) end
2020-07-12 16:32:54 +00:00
elseif def.effect then
2020-07-20 01:08:50 +00:00
return function ( player ) def.on_use ( player , effect , dur ) end
2020-07-12 11:59:29 +00:00
end
2020-07-12 16:32:54 +00:00
-- covers case of no effect (water, awkward, mundane)
return function ( ) end
2020-07-12 11:59:29 +00:00
end
2020-07-31 08:41:44 +00:00
local desc
if not def.no_potion then
2020-08-05 13:10:05 +00:00
if def.description_potion then
desc = def.description_potion
else
desc = S ( " @1 Potion " , def.description )
end
2020-07-31 08:41:44 +00:00
else
desc = def.description
end
2020-08-01 01:20:52 +00:00
local potion_longdesc = def._longdesc
if not def.no_effect then
potion_longdesc = potion_intro .. " \n " .. def._longdesc
end
2020-08-08 08:00:16 +00:00
local potion_usagehelp
2020-08-01 01:20:52 +00:00
local basic_potion_tt
if def.name ~= " dragon_breath " then
potion_usagehelp = how_to_drink
basic_potion_tt = get_tt ( def._tt , def.effect , dur )
end
2020-07-31 08:41:44 +00:00
2020-07-11 17:40:48 +00:00
minetest.register_craftitem ( " mcl_potions: " .. def.name , {
2020-07-31 08:41:44 +00:00
description = desc ,
2020-08-01 01:20:52 +00:00
_tt_help = basic_potion_tt ,
_doc_items_longdesc = potion_longdesc ,
_doc_items_usagehelp = potion_usagehelp ,
2020-07-28 21:02:43 +00:00
stack_max = def.stack_max or 1 ,
2020-07-12 00:26:45 +00:00
inventory_image = def.image or potion_image ( def.color ) ,
wield_image = def.image or potion_image ( def.color ) ,
2023-10-26 22:15:57 +00:00
groups = def.groups or { brewitem = 1 , food = 3 , can_eat_when_full = 1 , bottle = 1 } ,
2020-07-12 00:26:45 +00:00
on_place = on_use ,
on_secondary_use = on_use ,
2020-07-11 17:40:48 +00:00
} )
2020-07-12 11:59:29 +00:00
-- Register Splash and Lingering
2020-07-12 11:18:54 +00:00
local splash_dur = dur * mcl_potions.SPLASH_FACTOR
2020-07-12 11:59:29 +00:00
local ling_dur = dur * mcl_potions.LINGERING_FACTOR
2020-07-12 11:18:54 +00:00
local splash_def = {
tt = get_tt ( def._tt , def.effect , splash_dur ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 11:35:11 +00:00
potion_fun = get_splash_fun ( def.effect , splash_dur ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 11:18:54 +00:00
}
2020-07-12 12:20:56 +00:00
local ling_def
if def.name == " healing " or def.name == " harming " then
ling_def = {
tt = get_tt ( def._tt , def.effect * mcl_potions.LINGERING_FACTOR , ling_dur ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 12:20:56 +00:00
potion_fun = get_lingering_fun ( def.effect * mcl_potions.LINGERING_FACTOR , ling_dur ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 12:20:56 +00:00
}
else
ling_def = {
tt = get_tt ( def._tt , def.effect , ling_dur ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 12:20:56 +00:00
potion_fun = get_lingering_fun ( def.effect , ling_dur ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 12:20:56 +00:00
}
end
2020-07-19 22:56:18 +00:00
local arrow_def = {
2020-07-20 01:08:50 +00:00
tt = get_tt ( def._tt , def.effect , dur / 8. ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-20 01:08:50 +00:00
potion_fun = get_arrow_fun ( def.effect , dur / 8. ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-19 22:56:18 +00:00
}
2020-07-31 08:41:44 +00:00
if def.color and not def.no_throwable then
2020-08-05 13:10:05 +00:00
local desc
if def.description_splash then
desc = def.description_splash
else
desc = S ( " Splash @1 Potion " , def.description )
end
mcl_potions.register_splash ( def.name , desc , def.color , splash_def )
if def.description_lingering then
desc = def.description_lingering
else
desc = S ( " Lingering @1 Potion " , def.description )
end
mcl_potions.register_lingering ( def.name , desc , def.color , ling_def )
2020-07-31 08:41:44 +00:00
if not def.no_arrow then
mcl_potions.register_arrow ( def.name , S ( " Arrow of @1 " , def.description ) , def.color , arrow_def )
end
2020-07-12 11:18:54 +00:00
end
2020-07-11 17:40:48 +00:00
if def.is_II then
2020-07-12 00:26:45 +00:00
2020-07-31 08:41:44 +00:00
local desc_mod = S ( " II " )
2020-07-12 00:26:45 +00:00
local effect_II
if def.name == " healing " or def.name == " harming " then
effect_II = def.effect * mcl_potions.II_FACTOR
elseif def.name == " poison " or def.name == " regeneration " then
effect_II = 1.2
2023-08-08 00:53:01 +00:00
elseif def.name == " withering " then
effect_II = 2
2020-07-12 00:26:45 +00:00
else
effect_II = def.effect ^ mcl_potions.II_FACTOR
end
2020-07-13 01:15:54 +00:00
local dur_2 = dur / mcl_potions.II_FACTOR
2020-07-12 00:26:45 +00:00
if def.name == " poison " then dur_2 = dur_2 - 1 end
if def.name == " slowness " then
dur_2 = 20
effect_II = 0.40
2020-07-31 08:41:44 +00:00
desc_mod = S ( " IV " )
2020-07-12 00:26:45 +00:00
end
2020-08-10 08:30:00 +00:00
on_use = return_on_use ( def , effect_II , dur_2 )
2020-07-12 00:26:45 +00:00
minetest.register_craftitem ( " mcl_potions: " .. def.name .. " _2 " , {
2020-07-31 08:41:44 +00:00
description = S ( " @1 Potion@2 " , def.description , desc_mod ) ,
2020-07-12 11:18:54 +00:00
_tt_help = get_tt ( def._tt_2 , effect_II , dur_2 ) ,
2020-08-01 01:20:52 +00:00
_doc_items_longdesc = potion_longdesc ,
_doc_items_usagehelp = potion_usagehelp ,
2020-07-24 23:02:54 +00:00
stack_max = def.stack_max or 1 ,
2020-07-12 00:26:45 +00:00
inventory_image = def.image or potion_image ( def.color ) ,
wield_image = def.image or potion_image ( def.color ) ,
2023-10-26 22:15:57 +00:00
groups = def.groups or { brewitem = 1 , food = 3 , can_eat_when_full = 1 , bottle = 1 } ,
2020-07-12 00:26:45 +00:00
on_place = on_use ,
on_secondary_use = on_use ,
} )
2020-07-12 11:18:54 +00:00
2020-07-12 11:59:29 +00:00
-- Register Splash and Lingering
2020-07-12 11:18:54 +00:00
local splash_dur_2 = dur_2 * mcl_potions.SPLASH_FACTOR
2020-07-12 11:59:29 +00:00
local ling_dur_2 = dur_2 * mcl_potions.LINGERING_FACTOR
2020-07-12 11:18:54 +00:00
2020-07-12 12:50:48 +00:00
local splash_def_2
if def.name == " healing " then
splash_def_2 = {
tt = get_tt ( def._tt_2 , 7 , splash_dur_2 ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 12:50:48 +00:00
potion_fun = get_splash_fun ( 7 , splash_dur_2 ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 12:50:48 +00:00
}
else
splash_def_2 = {
tt = get_tt ( def._tt_2 , effect_II , splash_dur_2 ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 12:50:48 +00:00
potion_fun = get_splash_fun ( effect_II , splash_dur_2 ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 12:50:48 +00:00
}
end
local ling_def_2
2020-07-12 12:20:56 +00:00
if def.name == " healing " or def.name == " harming " then
2020-07-12 12:50:48 +00:00
ling_def_2 = {
tt = get_tt ( def._tt_2 , effect_II * mcl_potions.LINGERING_FACTOR , ling_dur_2 ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 12:50:48 +00:00
potion_fun = get_lingering_fun ( effect_II * mcl_potions.LINGERING_FACTOR , ling_dur_2 ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 12:50:48 +00:00
}
else
ling_def_2 = {
tt = get_tt ( def._tt_2 , effect_II , ling_dur_2 ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 12:50:48 +00:00
potion_fun = get_lingering_fun ( effect_II , ling_dur_2 ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 12:50:48 +00:00
}
2020-07-12 12:20:56 +00:00
end
2020-07-12 12:50:48 +00:00
2020-07-20 01:08:50 +00:00
local arrow_def_2 = {
tt = get_tt ( def._tt_2 , effect_II , dur_2 / 8. ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-20 01:08:50 +00:00
potion_fun = get_arrow_fun ( effect_II , dur_2 / 8. ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-20 01:08:50 +00:00
}
2020-07-31 08:41:44 +00:00
if def.color and not def.no_throwable then
mcl_potions.register_splash ( def.name .. " _2 " , S ( " Splash @1@2 Potion " , def.description , desc_mod ) , def.color , splash_def_2 )
mcl_potions.register_lingering ( def.name .. " _2 " , S ( " Lingering @1@2 Potion " , def.description , desc_mod ) , def.color , ling_def_2 )
if not def.no_arrow then
mcl_potions.register_arrow ( def.name .. " _2 " , S ( " Arrow of @1@2 " , def.description , desc_mod ) , def.color , arrow_def_2 )
end
2020-07-12 11:18:54 +00:00
end
2020-07-12 00:26:45 +00:00
end
if def.is_plus then
2020-07-13 01:15:54 +00:00
local dur_pl = dur * mcl_potions.PLUS_FACTOR
2023-08-08 00:53:01 +00:00
if def.name == " poison " or def.name == " regeneration " or def.name == " withering " then
2020-07-12 00:26:45 +00:00
dur_pl = 90
end
2020-08-10 08:30:00 +00:00
on_use = return_on_use ( def , def.effect , dur_pl )
2020-07-12 00:26:45 +00:00
minetest.register_craftitem ( " mcl_potions: " .. def.name .. " _plus " , {
2020-07-31 08:41:44 +00:00
description = S ( " @1 + Potion " , def.description ) ,
2020-07-12 11:18:54 +00:00
_tt_help = get_tt ( def._tt_plus , def.effect , dur_pl ) ,
2020-08-01 01:20:52 +00:00
_doc_items_longdesc = potion_longdesc ,
_doc_items_usagehelp = potion_usagehelp ,
2020-07-12 00:26:45 +00:00
stack_max = 1 ,
inventory_image = def.image or potion_image ( def.color ) ,
wield_image = def.image or potion_image ( def.color ) ,
2023-10-26 22:15:57 +00:00
groups = def.groups or { brewitem = 1 , food = 3 , can_eat_when_full = 1 , bottle = 1 } ,
2020-07-12 00:26:45 +00:00
on_place = on_use ,
on_secondary_use = on_use ,
} )
2020-07-12 11:35:11 +00:00
-- Register Splash
2020-07-12 11:18:54 +00:00
local splash_dur_pl = dur_pl * mcl_potions.SPLASH_FACTOR
2020-07-12 11:59:29 +00:00
local ling_dur_pl = dur_pl * mcl_potions.LINGERING_FACTOR
2020-07-12 11:18:54 +00:00
2020-07-12 11:35:11 +00:00
local splash_def_pl = {
tt = get_tt ( def._tt_plus , def.effect , splash_dur_pl ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 11:35:11 +00:00
potion_fun = get_splash_fun ( def.effect , splash_dur_pl ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 11:18:54 +00:00
}
2020-07-12 11:59:29 +00:00
local ling_def_pl = {
tt = get_tt ( def._tt_plus , def.effect , ling_dur_pl ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-12 11:59:29 +00:00
potion_fun = get_lingering_fun ( def.effect , ling_dur_pl ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-12 11:59:29 +00:00
}
2020-07-20 01:08:50 +00:00
local arrow_def_pl = {
tt = get_tt ( def._tt_pl , def.effect , dur_pl / 8. ) ,
2020-08-01 01:20:52 +00:00
longdesc = def._longdesc ,
2020-07-20 01:08:50 +00:00
potion_fun = get_arrow_fun ( def.effect , dur_pl / 8. ) ,
2020-08-01 01:20:52 +00:00
no_effect = def.no_effect ,
2020-08-19 15:37:41 +00:00
instant = def.instant ,
2020-07-20 01:08:50 +00:00
}
2020-07-31 08:41:44 +00:00
if def.color and not def.no_throwable then
mcl_potions.register_splash ( def.name .. " _plus " , S ( " Splash @1 + Potion " , def.description ) , def.color , splash_def_pl )
mcl_potions.register_lingering ( def.name .. " _plus " , S ( " Lingering @1 + Potion " , def.description ) , def.color , ling_def_pl )
if not def.no_arrow then
mcl_potions.register_arrow ( def.name .. " _plus " , S ( " Arrow of @1 + " , def.description ) , def.color , arrow_def_pl )
end
2020-07-12 11:18:54 +00:00
end
2020-07-11 17:40:48 +00:00
end
end
2020-07-22 21:46:49 +00:00
-- ██████╗░░█████╗░████████╗██╗░█████╗░███╗░░██╗
-- ██╔══██╗██╔══██╗╚══██╔══╝██║██╔══██╗████╗░██║
-- ██████╔╝██║░░██║░░░██║░░░██║██║░░██║██╔██╗██║
-- ██╔═══╝░██║░░██║░░░██║░░░██║██║░░██║██║╚████║
-- ██║░░░░░╚█████╔╝░░░██║░░░██║╚█████╔╝██║░╚███║
-- ╚═╝░░░░░░╚════╝░░░░╚═╝░░░╚═╝░╚════╝░╚═╝░░╚══╝
--
-- ██████╗░███████╗███████╗██╗███╗░░██╗██╗████████╗██╗░█████╗░███╗░░██╗░██████╗
-- ██╔══██╗██╔════╝██╔════╝██║████╗░██║██║╚══██╔══╝██║██╔══██╗████╗░██║██╔════╝
-- ██║░░██║█████╗░░█████╗░░██║██╔██╗██║██║░░░██║░░░██║██║░░██║██╔██╗██║╚█████╗░
-- ██║░░██║██╔══╝░░██╔══╝░░██║██║╚████║██║░░░██║░░░██║██║░░██║██║╚████║░╚═══██╗
-- ██████╔╝███████╗██║░░░░░██║██║░╚███║██║░░░██║░░░██║╚█████╔╝██║░╚███║██████╔╝
-- ╚═════╝░╚══════╝╚═╝░░░░░╚═╝╚═╝░░╚══╝╚═╝░░░╚═╝░░░╚═╝░╚════╝░╚═╝░░╚══╝╚═════╝░
2020-07-11 17:40:48 +00:00
local awkward_def = {
name = " awkward " ,
2020-08-05 13:10:05 +00:00
description_potion = S ( " Awkward Potion " ) ,
description_splash = S ( " Awkward Splash Potion " ) ,
description_lingering = S ( " Awkward Lingering Potion " ) ,
2020-07-31 08:41:44 +00:00
no_arrow = true ,
2020-08-01 01:20:52 +00:00
no_effect = true ,
2020-07-11 17:40:48 +00:00
_tt = S ( " No effect " ) ,
_longdesc = S ( " Has an awkward taste and is used for brewing potions. " ) ,
2020-07-12 00:26:45 +00:00
color = " #0000FF " ,
2023-10-26 22:15:57 +00:00
groups = { brewitem = 1 , food = 3 , can_eat_when_full = 1 , bottle = 1 } ,
2020-07-11 17:40:48 +00:00
on_use = minetest.item_eat ( 0 , " mcl_potions:glass_bottle " ) ,
}
2020-06-19 01:04:31 +00:00
2020-07-11 17:40:48 +00:00
local mundane_def = {
name = " mundane " ,
2020-08-05 13:10:05 +00:00
description_potion = S ( " Mundane Potion " ) ,
description_splash = S ( " Mundane Splash Potion " ) ,
description_lingering = S ( " Mundane Lingering Potion " ) ,
2020-07-31 08:41:44 +00:00
no_arrow = true ,
2020-08-01 01:20:52 +00:00
no_effect = true ,
2020-07-11 17:40:48 +00:00
_tt = S ( " No effect " ) ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Has a terrible taste and is not useful for brewing potions. " ) ,
2020-07-12 00:26:45 +00:00
color = " #0000FF " ,
2020-07-11 17:40:48 +00:00
on_use = minetest.item_eat ( 0 , " mcl_potions:glass_bottle " ) ,
}
local thick_def = {
name = " thick " ,
2020-08-05 13:10:05 +00:00
description_potion = S ( " Thick Potion " ) ,
description_splash = S ( " Thick Splash Potion " ) ,
description_lingering = S ( " Thick Lingering Potion " ) ,
2020-07-31 08:41:44 +00:00
no_arrow = true ,
2020-08-01 01:20:52 +00:00
no_effect = true ,
2020-07-11 17:40:48 +00:00
_tt = S ( " No effect " ) ,
2020-07-17 21:09:51 +00:00
_longdesc = S ( " Has a bitter taste and is not useful for brewing potions. " ) ,
2020-07-12 00:26:45 +00:00
color = " #0000FF " ,
2020-07-11 17:40:48 +00:00
on_use = minetest.item_eat ( 0 , " mcl_potions:glass_bottle " ) ,
}
local dragon_breath_def = {
name = " dragon_breath " ,
2020-07-31 08:41:44 +00:00
description = S ( " Dragon's Breath " ) ,
no_arrow = true ,
no_potion = true ,
no_throwable = true ,
2020-08-01 01:20:52 +00:00
no_effect = true ,
_longdesc = S ( " This item is used in brewing and can be combined with splash potions to create lingering potions. " ) ,
2021-01-17 11:07:49 +00:00
image = " mcl_potions_dragon_breath.png " ,
2023-10-26 22:15:57 +00:00
groups = { brewitem = 1 , bottle = 1 } ,
2020-07-11 17:40:48 +00:00
on_use = nil ,
2020-07-24 23:02:54 +00:00
stack_max = 64 ,
2020-07-11 17:40:48 +00:00
}
2020-06-17 21:50:18 +00:00
2020-07-11 17:40:48 +00:00
local healing_def = {
name = " healing " ,
2020-07-31 08:41:44 +00:00
description = S ( " Healing " ) ,
2020-08-05 13:10:05 +00:00
_tt = S ( " +4 HP " ) ,
_tt_2 = S ( " +8 HP " ) ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Instantly heals. " ) ,
2021-05-14 10:07:42 +00:00
color = " #F82423 " ,
2020-07-12 00:26:45 +00:00
effect = 4 ,
2020-08-19 15:37:41 +00:00
instant = true ,
2020-07-12 00:26:45 +00:00
on_use = mcl_potions.healing_func ,
is_II = true ,
2020-07-11 17:40:48 +00:00
}
local harming_def = {
name = " harming " ,
2020-07-31 08:41:44 +00:00
description = S ( " Harming " ) ,
2020-08-05 13:10:05 +00:00
_tt = S ( " -6 HP " ) ,
_tt_II = S ( " -12 HP " ) ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Instantly deals damage. " ) ,
2021-05-14 10:07:42 +00:00
color = " #430A09 " ,
2020-07-12 00:26:45 +00:00
effect = - 6 ,
2020-08-19 15:37:41 +00:00
instant = true ,
2020-07-12 00:26:45 +00:00
on_use = mcl_potions.healing_func ,
is_II = true ,
2020-07-12 11:59:29 +00:00
is_inv = true ,
2020-07-12 00:26:45 +00:00
}
local night_vision_def = {
name = " night_vision " ,
2020-07-31 08:41:44 +00:00
description = S ( " Night Vision " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-19 08:40:07 +00:00
_longdesc = S ( " Increases the perceived brightness of light under a dark sky. " ) ,
2021-05-14 10:07:42 +00:00
color = " #1F1FA1 " ,
2020-07-12 00:26:45 +00:00
effect = nil ,
is_dur = true ,
on_use = mcl_potions.night_vision_func ,
is_plus = true ,
}
local swiftness_def = {
name = " swiftness " ,
2020-07-31 08:41:44 +00:00
description = S ( " Swiftness " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Increases walking speed. " ) ,
2021-05-14 10:07:42 +00:00
color = " #7CAFC6 " ,
2020-07-12 00:26:45 +00:00
effect = 1.2 ,
is_dur = true ,
on_use = mcl_potions.swiftness_func ,
is_II = true ,
is_plus = true ,
}
local slowness_def = {
name = " slowness " ,
2020-07-31 08:41:44 +00:00
description = S ( " Slowness " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Decreases walking speed. " ) ,
2021-05-14 10:07:42 +00:00
color = " #5A6C81 " ,
2020-07-12 00:26:45 +00:00
effect = 0.85 ,
is_dur = true ,
on_use = mcl_potions.swiftness_func ,
is_II = true ,
is_plus = true ,
is_inv = true ,
}
local leaping_def = {
name = " leaping " ,
2020-07-31 08:41:44 +00:00
description = S ( " Leaping " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Increases jump strength. " ) ,
2021-05-14 10:07:42 +00:00
color = " #22FF4C " ,
2020-07-17 00:56:00 +00:00
effect = 1.15 ,
2020-07-12 00:26:45 +00:00
is_dur = true ,
on_use = mcl_potions.leaping_func ,
is_II = true ,
is_plus = true ,
}
2023-08-08 00:53:01 +00:00
local withering_def = {
name = " withering " ,
description = S ( " Withering " ) ,
_tt = nil ,
_longdesc = S ( " Applies the withering effect which deals damage at a regular interval and can kill. " ) ,
color = " #000000 " ,
effect = 4 ,
is_dur = true ,
on_use = mcl_potions.withering_func ,
is_II = true ,
is_plus = true ,
is_inv = true ,
}
2020-07-12 00:26:45 +00:00
local poison_def = {
name = " poison " ,
2020-07-31 08:41:44 +00:00
description = S ( " Poison " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Applies the poison effect which deals damage at a regular interval. " ) ,
2021-05-14 10:07:42 +00:00
color = " #4E9331 " ,
2020-07-12 00:26:45 +00:00
effect = 2.5 ,
is_dur = true ,
on_use = mcl_potions.poison_func ,
is_II = true ,
is_plus = true ,
is_inv = true ,
}
local regeneration_def = {
name = " regeneration " ,
2020-07-31 08:41:44 +00:00
description = S ( " Regeneration " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Regenerates health over time. " ) ,
2021-05-14 10:07:42 +00:00
color = " #CD5CAB " ,
2020-07-12 00:26:45 +00:00
effect = 2.5 ,
is_dur = true ,
on_use = mcl_potions.regeneration_func ,
is_II = true ,
is_plus = true ,
}
local invisibility_def = {
name = " invisibility " ,
2020-07-31 08:41:44 +00:00
description = S ( " Invisibility " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Grants invisibility. " ) ,
2021-05-14 10:07:42 +00:00
color = " #7F8392 " ,
2020-07-12 00:26:45 +00:00
is_dur = true ,
on_use = mcl_potions.invisiblility_func ,
is_plus = true ,
}
local water_breathing_def = {
name = " water_breathing " ,
2020-07-31 08:41:44 +00:00
description = S ( " Water Breathing " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Grants limitless breath underwater. " ) ,
2021-05-14 10:07:42 +00:00
color = " #2E5299 " ,
2020-07-12 00:26:45 +00:00
is_dur = true ,
on_use = mcl_potions.water_breathing_func ,
is_plus = true ,
}
local fire_resistance_def = {
name = " fire_resistance " ,
2020-07-31 08:41:44 +00:00
description = S ( " Fire Resistance " ) ,
2020-07-12 00:26:45 +00:00
_tt = nil ,
2020-08-01 01:20:52 +00:00
_longdesc = S ( " Grants immunity to damage from heat sources like fire. " ) ,
2021-05-14 10:07:42 +00:00
color = " #E49A3A " ,
2020-07-12 00:26:45 +00:00
is_dur = true ,
on_use = mcl_potions.fire_resistance_func ,
is_plus = true ,
2020-07-11 17:40:48 +00:00
}
2020-07-11 18:27:37 +00:00
local defs = { awkward_def , mundane_def , thick_def , dragon_breath_def ,
2020-08-08 08:00:16 +00:00
healing_def , harming_def , night_vision_def , swiftness_def ,
2023-08-08 00:53:01 +00:00
slowness_def , leaping_def , withering_def , poison_def , regeneration_def ,
2020-08-08 08:00:16 +00:00
invisibility_def , water_breathing_def , fire_resistance_def }
2020-07-11 17:40:48 +00:00
2020-07-11 18:27:37 +00:00
for _ , def in ipairs ( defs ) do
register_potion ( def )
end
2020-06-17 21:50:18 +00:00
2020-07-10 23:25:34 +00:00
-- minetest.register_craftitem("mcl_potions:weakness", {
2020-07-31 08:41:44 +00:00
-- description = S("Weakness"),
2020-08-08 07:32:38 +00:00
-- _tt_help = TODO,
2020-07-10 23:25:34 +00:00
-- _doc_items_longdesc = brewhelp,
2021-05-14 10:07:42 +00:00
-- wield_image = potion_image("#484D48"),
-- inventory_image = potion_image("#484D48"),
2020-08-01 01:20:52 +00:00
-- groups = { brewitem=1, food=3, can_eat_when_full=1 },
2020-07-10 23:25:34 +00:00
-- stack_max = 1,
--
-- on_place = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, -4, mcl_potions.DURATION*mcl_potions.INV_FACTOR)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#484D48")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end,
--
-- on_secondary_use = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, -4, mcl_potions.DURATION*mcl_potions.INV_FACTOR)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#484D48")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end
-- })
--
-- minetest.register_craftitem("mcl_potions:weakness_plus", {
2020-07-31 08:41:44 +00:00
-- description = S("Weakness +"),
2020-08-08 07:32:38 +00:00
-- _tt_help = TODO,
2020-07-10 23:25:34 +00:00
-- _doc_items_longdesc = brewhelp,
2021-05-14 10:07:42 +00:00
-- wield_image = potion_image("#484D48"),
-- inventory_image = potion_image("#484D48"),
2020-08-01 01:20:52 +00:00
-- groups = { brewitem=1, food=3, can_eat_when_full=1 },
2020-07-10 23:25:34 +00:00
-- stack_max = 1,
--
-- on_place = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, -4, mcl_potions.DURATION_2*mcl_potions.INV_FACTOR)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#484D48")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end,
--
-- on_secondary_use = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, -4, mcl_potions.DURATION_2*mcl_potions.INV_FACTOR)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#484D48")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end
-- })
--
-- minetest.register_craftitem("mcl_potions:strength", {
2020-07-31 08:41:44 +00:00
-- description = S("Strength"),
2020-08-08 07:32:38 +00:00
-- _tt_help = TODO,
2020-07-10 23:25:34 +00:00
-- _doc_items_longdesc = brewhelp,
2021-05-14 10:07:42 +00:00
-- wield_image = potion_image("#932423"),
-- inventory_image = potion_image("#932423"),
2020-08-01 01:20:52 +00:00
-- groups = { brewitem=1, food=3, can_eat_when_full=1 },
2020-07-10 23:25:34 +00:00
-- stack_max = 1,
--
-- on_place = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, 3, mcl_potions.DURATION)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#932423")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end,
--
-- on_secondary_use = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, 3, mcl_potions.DURATION)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#932423")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end
-- })
--
-- minetest.register_craftitem("mcl_potions:strength_2", {
2020-07-31 08:41:44 +00:00
-- description = S("Strength II"),
2020-08-08 07:32:38 +00:00
-- _tt_help = TODO,
2020-07-10 23:25:34 +00:00
-- _doc_items_longdesc = brewhelp,
2021-05-14 10:07:42 +00:00
-- wield_image = potion_image("#932423"),
-- inventory_image = potion_image("#932423"),
2020-08-01 01:20:52 +00:00
-- groups = { brewitem=1, food=3, can_eat_when_full=1 },
2020-07-10 23:25:34 +00:00
-- stack_max = 1,
--
-- on_place = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, 6, mcl_potions.DURATION_2)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#932423")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end,
--
-- on_secondary_use = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, 6, mcl_potions.DURATION_2)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#932423")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end
-- })
--
-- minetest.register_craftitem("mcl_potions:strength_plus", {
2020-07-31 08:41:44 +00:00
-- description = S("Strength +"),
2020-08-08 07:32:38 +00:00
-- _tt_help = TODO,
2020-07-10 23:25:34 +00:00
-- _doc_items_longdesc = brewhelp,
2021-05-14 10:07:42 +00:00
-- wield_image = potion_image("#932423"),
-- inventory_image = potion_image("#932423"),
2020-08-01 01:20:52 +00:00
-- groups = { brewitem=1, food=3, can_eat_when_full=1 },
2020-07-10 23:25:34 +00:00
-- stack_max = 1,
--
-- on_place = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, 3, mcl_potions.DURATION_PLUS)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#932423")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end,
--
-- on_secondary_use = function(itemstack, user, pointed_thing)
-- mcl_potions.weakness_func(user, 3, mcl_potions.DURATION_PLUS)
-- minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
2021-05-14 10:07:42 +00:00
-- mcl_potions._use_potion(itemstack, user, "#932423")
2020-07-10 23:25:34 +00:00
-- return itemstack
-- end
-- })