Improved potion descriptions
* added support for effect descriptions * added descriptions for some effects * fixed a crash
This commit is contained in:
parent
dc35f43bfa
commit
83530b4298
|
@ -135,35 +135,37 @@ 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
|
||||
local effect
|
||||
local dur
|
||||
local timestamp
|
||||
local ef_level
|
||||
local roman_lvl
|
||||
local factor
|
||||
local ef_tt
|
||||
for name, details in pairs(effects) do
|
||||
effect = mcl_potions.registered_effects[name]
|
||||
if details.dur_variable then
|
||||
dur = details.dur * math.pow(mcl_potions.PLUS_FACTOR, plus)
|
||||
if potency > 0 and details.uses_level then
|
||||
dur = dur / math.pow(mcl_potions.POTENT_FACTOR, potency)
|
||||
if effects then
|
||||
local effect
|
||||
local dur
|
||||
local timestamp
|
||||
local ef_level
|
||||
local roman_lvl
|
||||
local factor
|
||||
local ef_tt
|
||||
for name, details in pairs(effects) do
|
||||
effect = mcl_potions.registered_effects[name]
|
||||
if details.dur_variable then
|
||||
dur = details.dur * math.pow(mcl_potions.PLUS_FACTOR, plus)
|
||||
if potency > 0 and details.uses_level then
|
||||
dur = dur / math.pow(mcl_potions.POTENT_FACTOR, potency)
|
||||
end
|
||||
else
|
||||
dur = details.dur
|
||||
end
|
||||
else
|
||||
dur = details.dur
|
||||
timestamp = math.floor(dur/60)..string.format(":%02d",math.floor(dur % 60))
|
||||
if details.uses_level then
|
||||
ef_level = details.level + details.level_scaling * (potency)
|
||||
else
|
||||
ef_level = details.level
|
||||
end
|
||||
if ef_level > 1 then roman_lvl = " ".. mcl_util.to_roman(ef_level)
|
||||
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 = minetest.colorize("grey", effect.get_tt(factor)) else ef_tt = "" end
|
||||
if ef_tt ~= "" then s = s.. ef_tt.. "\n" end
|
||||
end
|
||||
timestamp = math.floor(dur/60)..string.format(":%02d",math.floor(dur % 60))
|
||||
if details.uses_level then
|
||||
ef_level = details.level + details.level_scaling * (potency)
|
||||
else
|
||||
ef_level = details.level
|
||||
end
|
||||
if ef_level > 1 then roman_lvl = " ".. mcl_util.to_roman(ef_level)
|
||||
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 ef_tt ~= "" then s = s.. ef_tt.. "\n" end
|
||||
end
|
||||
return s:trim()
|
||||
end)
|
||||
|
|
|
@ -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"))
|
||||
|
|
Loading…
Reference in New Issue