[pclasses & mff_pclasses] Change info menu

- Change info menu from a textarea to label components
 - Make `textify` public, becoming `pclasses.api.textify`
 - Use textify to create label lines
This commit is contained in:
LeMagnesium 2016-09-22 21:10:01 +02:00
parent 0baa0ea091
commit 99655796ff
No known key found for this signature in database
GPG Key ID: A54DDB5272C51E8B
5 changed files with 67 additions and 52 deletions

View File

@ -28,17 +28,19 @@ pclasses.api.register_class("hunter", {
tile = "default_wood.png", tile = "default_wood.png",
holo_item = "throwing:bow_minotaur_horn_improved" holo_item = "throwing:bow_minotaur_horn_improved"
}, },
informations = "Being a hunter is mostly being tactical, or just kicking in and firing arrows like madness. " .. informations = pclasses.api.textify("Being a hunter is mostly being tactical, or just kicking in and firing arrows like madness.\n" ..
"Being a hunter, you're in the only class which member can use new and exclusive ranged weapons, like spears, " .. "Being a hunter, you're in the only class which member can use new and exclusive\n" ..
"arbalests and bows. Your stamina is increased to 40, you're a sport person, able to sprint for a long " .. "ranged weapons, like spears, arbalests and bows. Your stamina is increased to\n" ..
"time, which is found to be useful when you hunt down animals and mobs who can't run faster than you " .. "40, you're a sport person, able to sprint for a long time, which is found to be\n" ..
"walk.. and even more when you need to cowardly run away... anyway. The point is, being a hunter is " .. "useful when you hunt down animals and mobs who can't run faster than you walk..\n" ..
"great, since you can access new and exclusive weapons, and leather armors, crafted from leather. " .. "and even more when you need to cowardly run away... anyway. The point is, being\n" ..
"Obviously.. Those clothes are pretty strong, and will protect you more than wooden " .. "a hunter is great, since you can access new and exclusive weapons, and leather\n" ..
"pieces (at least the reinforced one), with the satation consumption of wearing nothing.\n" .. "armors, crafted from leather. Obviously.. Those clothes are pretty strong, and\n" ..
"If you want to risk it and become a hunter, you should look for a green pedestal with a bow so fancy over it " .. "will protect you more than wooden pieces (at least the reinforced one), with the\n" ..
"that you can already tell that we're gonna make you use loads of ores for it. (actually you need to fight a " .. "satation consumption of wearing nothing. If you want to risk it and become a\n" ..
"super strong mob, but it's just details...)" "hunter, you should look for a green pedestal with a bow so fancy over it that you\n" ..
"can already tell that we're gonna make you use loads of ores for it. (actually\n" ..
"you need to fight a super strong mob, but it's just details...)")
}) })

View File

@ -23,15 +23,17 @@ pclasses.api.register_class("warrior", {
tile = "default_steel_block.png", tile = "default_steel_block.png",
holo_item = "default:dungeon_master_s_blood_sword" holo_item = "default:dungeon_master_s_blood_sword"
}, },
informations = "'Warriors' is a class of players designed to improve fighting parameters of players " .. informations = pclasses.api.textify("'Warriors' is a class of players designed to improve fighting parameters of players who\n" ..
"who chose to belong to it. You become a big tank, of human shape. Not only can you wear stronger " .. "chose to belong to it. You become a big tank, of human shape. Not only can you wear\n" ..
"protections (like the Black Mithril armor's pieces, because Black Mithril is a thing here), and " .. "stronger protections (like the Black Mithril armor's pieces, because Black Mithril is a thing\n" ..
"use more powerful hand-to-hand weapons (such as the Dungeon Master's blood sword, because yes, you are going " .. "here), and use more powerful hand-to-hand weapons (such as the Dungeon Master's\n" ..
"to fight Dungeon Masters and drain their blood), but your stamina bar is boosted up to 20! Trust us, " .. "blood sword, because yes, you are going to fight Dungeon Masters and drain their blood),\n" ..
"running away is an important part of fighting a Dungeon Master. Being a warrior, you regenerate " .. "but your stamina bar is boosted up to 20! Trust us, running away is an important part\n" ..
"health faster, which is, again, quite handy, at the cost of needing to eat more frequently (less handy).\n" .. "of fighting a Dungeon Master. Being a warrior, you regenerate health faster, which is,\n" ..
"The pedestal tied to the Warriors' includes the strongest sword, available only to Warriors : the " .. "again, quite handy, at the cost of needing to eat more frequently (less handy). The\n" ..
"Dungeon Master's Blood Sword. It just looks like what you imagine, just more pixel-ish." "pedestal tied to the Warriors' includes the strongest sword, available only to Warriors :\n" ..
"the Dungeon Master's Blood Sword. It just looks like what you imagine, just\n" ..
"more pixel-ish.")
}) })
pclasses.api.reserve_item("warrior", "default:sword_mithril") pclasses.api.reserve_item("warrior", "default:sword_mithril")

View File

@ -23,22 +23,24 @@ pclasses.api.register_class("wizard", {
color = {r = 230, g = 230, b = 0}, color = {r = 230, g = 230, b = 0},
holo_item = "default:book" holo_item = "default:book"
}, },
informations = "'Wizards' is a class of players aimed at enhancing magic abilities. Basically, " .. informations = pclasses.api.textify("'Wizards' is a class of players aimed at enhancing magic abilities. Basically, you\n" ..
"you become a wizard. Or a witch. Whichever one you prefer. You can then use magic, which is nice. " .. "become a wizard. Or a witch. Whichever one you prefer. You can then use magic, which\n" ..
"But since this magic was implemented by the people coding for this server (well, one of them, mostly), " .. "is nice. But since this magic was implemented by the people coding for this server\n" ..
"you should expect a few things to not.. work.. If you have comments, complaints and threats, " .. "(well, one of them, mostly), you should expect a few things to not.. work.. If you have\n" ..
"contact us, well, me.. Being a wizard means you will need energy, or 'mana', to cast spells, " .. "comments, complaints and threats, contact us, well, me.. Being a wizard means you will\n" ..
"or rather, to use our ugly wands. This energy is recharged by.. waiting. You use it every time " .. "need energy, or 'mana', to cast spells, or rather, to use our ugly wands. This energy is\n" ..
"you cast a spell or engrave a rune with a wand, to charge it, and not have you throw zillions of " .. "recharged by.. waiting. You use it every time you cast a spell or engrave a rune with a\n" ..
"spell in a minute. Once your mana charger has dropped down to 0, or too low for that cool shape " .. "wand, to charge it, and not have you throw zillions of spell in a minute. Once your\n" ..
"shift spell (not implemented (yet?)), just wait a bit and it will come back on its own. At least it should. " .. "your mana charger has dropped down to 0, or too low for that cool shape shift spell\n" ..
"The maximum mana capacity is significantly higher in Wizards (and Witches) than in any other class.\n" .. "(not implemented (yet?)), just wait a bit and it will come back on its own. At least it\n" ..
"Since this class is still a work in progress, the following things are not implemented yet. Note : " .. "should. The maximum mana capacity is significantly higher in Wizards (and Witches) than\n" ..
"poking at the developers could help us bring you the content, it's motivating!\n" .. "in any other class. Since this class is still a work in progress, the following things are\n" ..
"Wizards can wear silk robes (not there yet) to add in maximum mana levels and mana regeneration if worn entirely. " .. "not implemented yet. Note : poking at the developers could help us bring you the\n" ..
"It is interesting to note that those robes do not make you hungry faster, contrary to most armors.\n" .. "content, it's motivating! Wizards can wear silk robes (not there yet) to add in maximum\n" ..
"Finally, the pedestal to use in order to become a member of this class has a book floating over it, " .. "mana levels and mana regeneration if worn entirely. It is interesting to note that those\n" ..
"to symbolize wisdom." "robes do not make you hungry faster, contrary to most armors. Finally, the pedestal to\n" ..
"use in order to become a member of this class has a book floating over it, to symbolize\n" ..
"wisdom.")
}) })
-- Reserved items here -- Reserved items here

View File

@ -15,11 +15,12 @@ pclasses.api.register_class("adventurer", {
end, end,
on_unassigned = function(pname) on_unassigned = function(pname)
end, end,
informations = "Adventurer, the casual players, or hardcore players. Whatever end of the spectrum " .. informations = pclasses.api.textify("Adventurer, the casual players, or hardcore players. Whatever end of the spectrum\n" ..
"you're in, adventurer will bring you what you want : no advantages, no help. Maybe you don't want " .. "you're in, adventurer will bring you what you want : no advantages, no help. Maybe you\n" ..
"that if you just began playing. If that's the case.. just pick another tab and read what's in it. " .. "don't want that if you just began playing. If that's the case.. just pick another tab and\n" ..
"You'll still be able to come back to this boilerplate class whenever you want to (minus actual " .. "read what's in it. You'll still be able to come back to this boilerplate class whenever you\n" ..
"cooldown regulation of.. an hour between two changes) if you like being hurt, or hardcore gaming, " .. "want to (minus actual cooldown regulation of.. an hour between two changes) if you like\n" ..
"which, from afar, look alike.... The pedestal has a backpack over it, because, yay adventures!" "being hurt, or hardcore gaming, which, from afar, look alike.... The pedestal has a backpack\n" ..
"over it, because, yay adventures!")
}) })

View File

@ -91,19 +91,27 @@ local pbutton_form = "size[10,10]" ..
"button_exit[4.5,9.5;1,0.5;pmenu_leave;Leave]" .. "button_exit[4.5,9.5;1,0.5;pmenu_leave;Leave]" ..
"tabheader[0,0;pmenu_header;infos" "tabheader[0,0;pmenu_header;infos"
function textify(text) function pclasses.api.textify(text)
return "textarea[0.5,0.2;9.6,10;pmenu_data;;" .. text .. "]" --return "textarea[0.5,0.2;9.6,10;pmenu_data;;" .. text .. "]"
local returned = ""
for i, line in pairs(text:split('\n')) do
returned = ("%slabel[0.2,%f;%s]"):format(returned, 0.2 + (i-1)*0.5, line)
end
return returned
end end
local pbuttons = {} local pbuttons = {}
local pforms = {} local pforms = {}
local pinfo = textify( local pinfo = pclasses.api.textify(
"PClasses (Player Classes) allows you to become a member of specific classes implemented with abilities, advantages, and reserved items. " .. "PClasses (Player Classes) allows you to become a member of specific classes implemented\n" ..
"Each one of the classes defined grants the right to carry items, called reserved items, tied to the abilities of a class. A hunter will be " .. "with abilities, advantages, and reserved items. Each one of the classes defined grants\n" ..
"able to use arrows, whereas a warrior can own powerful weapons. Each time you switch classes, you will lose your stats and items, the latter " .. "the right to carry items, called reserved items, tied to the abilities of a class. A \n" ..
"being transfered into a special part of your inventory, the graveyard. Once you return to a class that allows you to use those items, they will " .. "hunter will be able to use arrows, whereas a warrior can own powerful weapons. Each time\n" ..
"return in your main inventory.\n" .. "you switch classes, you will lose your stats and items, the latter being transfered into\n" ..
"You can use this menu to navigate between classes and read informations about what abilities come with specific classes." "a special part of your inventory, the graveyard. Once you return to a class that allows\n" ..
"you to use those items, they will return in your main inventory.\n" ..
"You can use this menu to navigate between classes and read informations about what\n" ..
"abilities come with specific classes."
) )
@ -126,7 +134,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.pmenu_header + 0 == 1 then if fields.pmenu_header + 0 == 1 then
player:set_inventory_formspec(pbutton_form .. pinfo) player:set_inventory_formspec(pbutton_form .. pinfo)
else else
player:set_inventory_formspec(string.sub(pbutton_form, 1, -3) .. fields.pmenu_header .. "]" .. textify(pclasses.classes[pbuttons[fields.pmenu_header-1]].informations or "No informations available")) player:set_inventory_formspec(string.sub(pbutton_form, 1, -3) .. fields.pmenu_header .. "]" .. (pclasses.classes[pbuttons[fields.pmenu_header-1]].informations or "No informations available"))
end end
return return