mirror of
				https://github.com/sys4-fr/server-nalc.git
				synced 2025-10-31 04:25:32 +01:00 
			
		
		
		
	[pclasses] Add information menus (informations not yet written)
- For #473
This commit is contained in:
		| @@ -14,6 +14,10 @@ function pclasses.api.register_class(cname, def) | ||||
| 			cname .. ". Reason : no definition table.") | ||||
| 		return | ||||
| 	end | ||||
| 	if cname == "infos" then | ||||
| 	   minetest.log("error", "[PClasses] Error registering class with reserved name : infos") | ||||
| 	   return | ||||
| 	end | ||||
| 	pclasses.register_class_switch(cname, def.switch_params) | ||||
|  | ||||
| 	pclasses.classes[cname] = def | ||||
|   | ||||
| @@ -1,2 +1,3 @@ | ||||
| 3d_armor | ||||
| sprint | ||||
| unified_inventory | ||||
|   | ||||
| @@ -85,3 +85,65 @@ function pclasses.api.vacuum_graveyard(player) | ||||
| 		end | ||||
| 	end | ||||
| end | ||||
|  | ||||
| -- Inventory description buttons | ||||
| local pbutton_form = "size[10,10]" .. | ||||
|    "button_exit[4.5,9.5;1,0.5;pmenu_leave;Leave]" .. | ||||
|    "tabheader[0,0;pmenu_header;infos" | ||||
|  | ||||
| function textify(text) | ||||
|    return "textarea[0.5,0.2;9.6,10;pmenu_data;;" .. text .. "]" | ||||
| end | ||||
|  | ||||
| local pbuttons = {} | ||||
| local pforms = {} | ||||
| local pinfo = textify( | ||||
|    "PClasses (Player Classes) allows you to become a member of specific classes implemented with abilities, advantages, and reserved items. " .. | ||||
|       "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 " .. | ||||
|       "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 " .. | ||||
|       "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 " .. | ||||
|       "return in your main inventory.\n" .. | ||||
|       "You can use this menu to navigate between classes and read informations about what abilities come with specific classes." | ||||
| ) | ||||
|  | ||||
|  | ||||
| minetest.after(0, function() | ||||
| 		  for cname, cdef in pairs(pclasses.classes) do | ||||
| 		     if cname ~= pclasses.conf.superuser_class then | ||||
| 			pbutton_form = pbutton_form .. ',' .. cname | ||||
| 			table.insert(pbuttons, cname) | ||||
| 		     end | ||||
| 		  end | ||||
| 		  pbutton_form = pbutton_form .. ";1]" | ||||
| 		  minetest.log("action", pbutton_form) | ||||
| end) | ||||
|  | ||||
| minetest.register_on_player_receive_fields(function(player, formname, fields) | ||||
|       if formname ~= "" then return end | ||||
|  | ||||
|       if fields.pmenu_header then | ||||
| 	 minetest.log(fields.pmenu_header) | ||||
| 	 if fields.pmenu_header + 0 == 1 then | ||||
| 	    player:set_inventory_formspec(pbutton_form .. pinfo) | ||||
| 	 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")) | ||||
| 	 end | ||||
| 	 return | ||||
|  | ||||
|       elseif fields.pmenu_leave then | ||||
| 	 player:set_inventory_formspec(pforms[player:get_player_name()]) | ||||
| 	 pforms[player:get_player_name()] = nil | ||||
|       end | ||||
| end) | ||||
|  | ||||
| unified_inventory.register_button("pclasses", { | ||||
| 				  type = "image", | ||||
| 				  image = "pclasses_inv.png", | ||||
| 				  tooltip = "Player Classes Descriptions", | ||||
| 				  action = function(player) | ||||
| 				      if not pforms[player:get_player_name()] then | ||||
| 					 pforms[player:get_player_name()] = player:get_inventory_formspec() | ||||
| 					 player:set_inventory_formspec(pbutton_form .. pinfo) | ||||
| 				      end | ||||
| 				   end | ||||
| }) | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								mods/pclasses/textures/pclasses_inv.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mods/pclasses/textures/pclasses_inv.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 598 B | 
		Reference in New Issue
	
	Block a user