Added support for varied descriptions

This commit is contained in:
the-real-herowl 2024-01-07 23:19:05 +01:00
parent 74754fbca5
commit 1294549f03
1 changed files with 21 additions and 4 deletions

View File

@ -182,7 +182,15 @@ function mcl_potions.register_potion(def)
error("Unable to register potion: name is not a string") error("Unable to register potion: name is not a string")
end end
local pdef = {} local pdef = {}
if def.desc_prefix and def.desc_suffix then
pdef.description = S("@1 Potion @2", def.desc_prefix, def.desc_suffix) pdef.description = S("@1 Potion @2", def.desc_prefix, def.desc_suffix)
elseif def.desc_prefix then
pdef.description = S("@1 Potion", def.desc_prefix)
elseif def.desc_suffix then
pdef.description = S("Potion @1", def.desc_suffix)
else
pdef.description = S("Strange Potion")
end
pdef._tt_help = def._tt pdef._tt_help = def._tt
pdef._dynamic_tt = def._dynamic_tt pdef._dynamic_tt = def._dynamic_tt
local potion_longdesc = def._longdesc local potion_longdesc = def._longdesc
@ -242,7 +250,7 @@ function mcl_potions.register_potion(def)
minetest.register_craftitem(modname..":"..name, pdef) minetest.register_craftitem(modname..":"..name, pdef)
if def.has_splash or def.has_splash == nil then if def.has_splash or def.has_splash == nil then
local splash_desc = S("Splash @1 Potion @2", def.desc_prefix, def.desc_suffix) local splash_desc = S("Splash @1", pdef.description)
local sdef = {} local sdef = {}
sdef._tt = def._tt sdef._tt = def._tt
sdef._dynamic_tt = def._dynamic_tt sdef._dynamic_tt = def._dynamic_tt
@ -261,7 +269,7 @@ function mcl_potions.register_potion(def)
end end
if def.has_lingering or def.has_lingering == nil then if def.has_lingering or def.has_lingering == nil then
local ling_desc = S("Lingering @1 Potion @2", def.desc_prefix, def.desc_suffix) local ling_desc = S("Lingering @1", pdef.description)
local ldef = {} local ldef = {}
ldef._tt = def._tt ldef._tt = def._tt
ldef._longdesc = def._longdesc ldef._longdesc = def._longdesc
@ -280,7 +288,16 @@ function mcl_potions.register_potion(def)
end end
if def.has_arrow then if def.has_arrow then
local arr_desc = S("@1 Arrow @2", def.desc_prefix, def.desc_suffix) local arr_desc
if def.desc_prefix and def.desc_suffix then
arr_desc = S("@1 Arrow @2", def.desc_prefix, def.desc_suffix)
elseif def.desc_prefix then
arr_desc = S("@1 Arrow", def.desc_prefix)
elseif def.desc_suffix then
arr_desc = S("Arrow @1", def.desc_suffix)
else
arr_desc = S("Strange Tipped Arrow")
end
local adef = {} local adef = {}
adef._tt = def._tt adef._tt = def._tt
adef._longdesc = def._longdesc adef._longdesc = def._longdesc