forked from luanti-org/minetest_game
		
	Add fancy inventories
This commit is contained in:
		| @@ -11,6 +11,30 @@ LIGHT_MAX = 14 | ||||
| -- Definitions made by this mod that other mods can use too | ||||
| default = {} | ||||
|  | ||||
| -- GUI related stuff | ||||
| gui_bg = "bgcolor[#0009;true]" | ||||
| gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]" | ||||
| gui_slots = "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]" | ||||
|  | ||||
| function default.get_hotbar_bg(x,y) | ||||
| 	local out = "" | ||||
| 	for i=0,7,1 do | ||||
| 		out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]" | ||||
| 	end | ||||
| 	return out | ||||
| end | ||||
|  | ||||
| gui_suvival_form = "size[8,8.5]".. | ||||
| 			gui_bg.. | ||||
| 			gui_bg_img.. | ||||
| 			gui_slots.. | ||||
| 			"list[current_player;main;0,4.25;8,1;]".. | ||||
| 			"list[current_player;main;0,5.5;8,3;8]".. | ||||
| 			"list[current_player;craft;1.75,0.5;3,3;]".. | ||||
| 			"list[current_player;craftpreview;5.75,1.5;1,1;]".. | ||||
| 			"image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]".. | ||||
| 			default.get_hotbar_bg(0,4.25) | ||||
|  | ||||
| -- Load files | ||||
| dofile(minetest.get_modpath("default").."/functions.lua") | ||||
| dofile(minetest.get_modpath("default").."/nodes.lua") | ||||
|   | ||||
| @@ -672,16 +672,26 @@ minetest.register_node("default:sign_wall", { | ||||
|  | ||||
| default.chest_formspec =  | ||||
| 	"size[8,9]".. | ||||
| 	"list[current_name;main;0,0;8,4;]".. | ||||
| 	"list[current_player;main;0,5;8,4;]" | ||||
| 	gui_bg.. | ||||
| 	gui_bg_img.. | ||||
| 	gui_slots.. | ||||
| 	"list[current_name;main;0,0.3;8,4;]".. | ||||
| 	"list[current_player;main;0,4.85;8,1;]".. | ||||
| 	"list[current_player;main;0,6.08;8,3;8]".. | ||||
| 	default.get_hotbar_bg(0,4.85) | ||||
|  | ||||
| function default.get_locked_chest_formspec(pos) | ||||
| 	local spos = pos.x .. "," .. pos.y .. "," ..pos.z | ||||
| 	local formspec = | ||||
| 		"size[8,9]".. | ||||
| 		"list[nodemeta:".. spos .. ";main;0,0;8,4;]".. | ||||
| 		"list[current_player;main;0,5;8,4;]" | ||||
| 	return formspec | ||||
| 		gui_bg.. | ||||
| 		gui_bg_img.. | ||||
| 		gui_slots.. | ||||
| 		"list[nodemeta:".. spos .. ";main;0,0.3;8,4;]".. | ||||
| 		"list[current_player;main;0,4.85;8,1;]".. | ||||
| 		"list[current_player;main;0,6.08;8,3;8]".. | ||||
| 		default.get_hotbar_bg(0,4.85) | ||||
|  return formspec | ||||
| end | ||||
|  | ||||
|  | ||||
| @@ -811,25 +821,54 @@ minetest.register_node("default:chest_locked", { | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
| function default.furnace_active(pos, percent, item_percent) | ||||
|     local formspec =  | ||||
| 	"size[8,8.5]".. | ||||
| 	gui_bg.. | ||||
| 	gui_bg_img.. | ||||
| 	gui_slots.. | ||||
| 	"list[current_name;src;2.75,0.5;1,1;]".. | ||||
| 	"list[current_name;fuel;2.75,2.5;1,1;]".. | ||||
| 	"image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:".. | ||||
| 	(100-percent)..":default_furnace_fire_fg.png]".. | ||||
|         "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:".. | ||||
|         (item_percent*100)..":gui_furnace_arrow_fg.png^[transformR270]".. | ||||
| 	"list[current_name;dst;4.75,0.96;2,2;]".. | ||||
| 	"list[current_player;main;0,4.25;8,1;]".. | ||||
| 	"list[current_player;main;0,5.5;8,3;8]".. | ||||
| 	default.get_hotbar_bg(0,4.25) | ||||
|     return formspec | ||||
|   end | ||||
|  | ||||
| function default.get_furnace_active_formspec(pos, percent) | ||||
| 	local formspec = | ||||
| 		"size[8,9]".. | ||||
| 		"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:".. | ||||
| 		(100-percent)..":default_furnace_fire_fg.png]".. | ||||
| 		"list[current_name;fuel;2,3;1,1;]".. | ||||
| 		"list[current_name;src;2,1;1,1;]".. | ||||
| 		"list[current_name;dst;5,1;2,2;]".. | ||||
| 		"list[current_player;main;0,5;8,4;]" | ||||
| 	return formspec | ||||
| 	local meta = minetest.get_meta(pos)local inv = meta:get_inventory() | ||||
| 	local srclist = inv:get_list("src") | ||||
| 	local cooked = nil | ||||
| 	local aftercooked = nil | ||||
| 	if srclist then | ||||
| 		cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) | ||||
| 	end | ||||
| 	local item_percent = 0 | ||||
| 	if cooked then | ||||
| 		item_percent = meta:get_float("src_time")/cooked.time | ||||
| 	end | ||||
|         | ||||
|         return default.furnace_active(pos, percent, item_percent) | ||||
| end | ||||
|  | ||||
| default.furnace_inactive_formspec = | ||||
| 	"size[8,9]".. | ||||
| 	"image[2,2;1,1;default_furnace_fire_bg.png]".. | ||||
| 	"list[current_name;fuel;2,3;1,1;]".. | ||||
| 	"list[current_name;src;2,1;1,1;]".. | ||||
| 	"list[current_name;dst;5,1;2,2;]".. | ||||
| 	"list[current_player;main;0,5;8,4;]" | ||||
| 	"size[8,8.5]".. | ||||
| 	gui_bg.. | ||||
| 	gui_bg_img.. | ||||
| 	gui_slots.. | ||||
| 	"list[current_name;src;2.75,0.5;1,1;]".. | ||||
| 	"list[current_name;fuel;2.75,2.5;1,1;]".. | ||||
| 	"image[2.75,1.5;1,1;default_furnace_fire_bg.png]".. | ||||
| 	"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]".. | ||||
| 	"list[current_name;dst;4.75,0.96;2,2;]".. | ||||
| 	"list[current_player;main;0,4.25;8,1;]".. | ||||
| 	"list[current_player;main;0,5.5;8,3;8]".. | ||||
| 	default.get_hotbar_bg(0,4.25) | ||||
|  | ||||
| minetest.register_node("default:furnace", { | ||||
| 	description = "Furnace", | ||||
|   | ||||
| @@ -142,6 +142,17 @@ end | ||||
| minetest.register_on_joinplayer(function(player) | ||||
| 	default.player_set_model(player, "character.x") | ||||
| 	player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30) | ||||
| 	 | ||||
| 	-- set GUI | ||||
| 	if minetest.setting_getbool("creative_mode") then | ||||
| 	--	creative.set_creative_formspec(player, 0, 1) | ||||
| 	else | ||||
| 		player:set_inventory_formspec(gui_suvival_form) | ||||
| 	end | ||||
| 	minetest.after(0.5,function() | ||||
| 		player:hud_set_hotbar_image("gui_hotbar.png") | ||||
| 		player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") | ||||
| 	end) | ||||
| end) | ||||
|  | ||||
| minetest.register_on_leaveplayer(function(player) | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/gui_formbg.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mods/default/textures/gui_formbg.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 3.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/gui_furnace_arrow_bg.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mods/default/textures/gui_furnace_arrow_bg.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 515 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/gui_furnace_arrow_fg.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mods/default/textures/gui_furnace_arrow_fg.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 301 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/gui_hb_bg.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mods/default/textures/gui_hb_bg.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 169 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/gui_hotbar.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mods/default/textures/gui_hotbar.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.1 KiB | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/gui_hotbar_selected.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mods/default/textures/gui_hotbar_selected.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 4.9 KiB | 
		Reference in New Issue
	
	Block a user