1
0
Fork 0

Improved potion descriptions

* added support for effect descriptions
* added descriptions for some effects
* fixed a crash
This commit is contained in:
the-real-herowl 2024-01-07 22:54:10 +01:00
parent dc35f43bfa
commit 83530b4298
2 changed files with 48 additions and 27 deletions

View File

@ -135,6 +135,7 @@ tt.register_snippet(function(itemstring, _, itemstack)
local plus = meta:get_int("mcl_potions:potion_plus")
if def._dynamic_tt then s = s.. def._dynamic_tt(potency+1).. "\n" end
local effects = def._effect_list
if effects then
local effect
local dur
local timestamp
@ -162,8 +163,9 @@ tt.register_snippet(function(itemstring, _, itemstack)
else roman_lvl = "" end
s = s.. effect.description.. roman_lvl.. " (".. timestamp.. ")\n"
if effect.uses_factor then factor = effect.level_to_factor(ef_level) end
if effect.get_tt then ef_tt = effect.get_tt(factor) else ef_tt = "" end
if effect.get_tt then ef_tt = minetest.colorize("grey", effect.get_tt(factor)) else ef_tt = "" end
if ef_tt ~= "" then s = s.. ef_tt.. "\n" end
end
end
return s:trim()
end)

View File

@ -165,6 +165,9 @@ mcl_potions.register_effect({
mcl_potions.register_effect({
name = "poison",
description = S("Poison"),
get_tt = function(factor)
return S("-1 HP / @1 s", factor)
end,
res_condition = function(object)
local entity = object:get_luaentity()
return (entity and (entity.harmed_by_heal or string.find(entity.name, "spider")))
@ -184,6 +187,9 @@ mcl_potions.register_effect({
mcl_potions.register_effect({
name = "regeneration",
description = S("Regeneration"),
get_tt = function(factor)
return S("+1 HP / @1 s", factor)
end,
res_condition = function(object)
local entity = object:get_luaentity()
return (entity and entity.harmed_by_heal)
@ -238,6 +244,10 @@ mcl_potions.register_effect({
mcl_potions.register_effect({
name = "leaping",
description = S("Leaping"),
get_tt = function(factor)
if factor > 0 then return S("+@1% jumping power", math.floor(factor*100)) end
return S("-@1% jumping power", math.floor(-factor*100))
end,
res_condition = function(object)
return (not object:is_player())
end,
@ -256,6 +266,9 @@ mcl_potions.register_effect({
mcl_potions.register_effect({
name = "swiftness",
description = S("Swiftness"),
get_tt = function(factor)
return S("+@1% running speed", math.floor(factor*100))
end,
res_condition = function(object)
return (not object:is_player())
end,
@ -274,6 +287,9 @@ mcl_potions.register_effect({
mcl_potions.register_effect({
name = "slowness",
description = S("Slowness"),
get_tt = function(factor)
return S("-@1% running speed", math.floor(factor*100))
end,
res_condition = function(object)
return (not object:is_player())
end,
@ -331,6 +347,9 @@ mcl_potions.register_effect({
mcl_potions.register_effect({
name = "withering",
description = S("Withering"),
get_tt = function(factor)
return S("-1 HP / @1 s, can kill", factor)
end,
res_condition = function(object)
local entity = object:get_luaentity()
return (entity and string.find(entity.name, "wither"))