use mesh nodes for standing lamp and "3dforniture" table lamp
rewrote the surrounding code a bit to clean it up all new textures, got rid of related, obsolete files.
| @@ -66,6 +66,35 @@ function homedecor.get_nodedef_field(nodename, fieldname) | ||||
| 	return minetest.registered_nodes[nodename][fieldname] | ||||
| end | ||||
|  | ||||
| -- Place a two-node-tall single object (e.g. a floor lamp) | ||||
|  | ||||
| function homedecor.place_twonode_vertical(itemstack, placer, pointed_thing, node) | ||||
| 	local pos = pointed_thing.under | ||||
| 	local pnode = minetest.get_node(pointed_thing.under) | ||||
| 	local rnodedef = minetest.registered_nodes[pnode.name] | ||||
|  | ||||
| 	if not rnodedef["buildable_to"] then | ||||
| 		pos = pointed_thing.above | ||||
| 	end | ||||
|  | ||||
| 	local fdir = minetest.dir_to_facedir(placer:get_look_dir()) | ||||
| 	local pos2 = { x = pos.x, y=pos.y + 1, z = pos.z } | ||||
|  | ||||
| 	local tnode = minetest.get_node(pos) | ||||
| 	local tnode2 = minetest.get_node(pos2) | ||||
|  | ||||
| 	if homedecor.get_nodedef_field(tnode.name, "buildable_to") | ||||
| 	  and homedecor.get_nodedef_field(tnode2.name, "buildable_to") | ||||
| 	  and not minetest.is_protected(pos, placer:get_player_name()) | ||||
| 	  and not minetest.is_protected(pos2, placer:get_player_name()) then | ||||
| 		minetest.add_node(pos, { name = node, param2 = fdir }) | ||||
| 		if not homedecor.expect_infinite_stacks then | ||||
| 			itemstack:take_item() | ||||
| 			return itemstack | ||||
| 		end | ||||
| 	end | ||||
| end | ||||
|  | ||||
| -- Stack one node above another | ||||
|  | ||||
| function homedecor.stack_vertically(itemstack, placer, pointed_thing, node1, node2) | ||||
|   | ||||
| @@ -400,44 +400,34 @@ minetest.register_node('homedecor:lattice_lantern_small', { | ||||
| local repl = { off="low", low="med", med="hi", hi="max", max="off", } | ||||
| local lamp_colors = { "", "blue", "green", "pink", "red", "violet" } | ||||
|  | ||||
| local tlamp_cbox = { | ||||
| 	type = "fixed", | ||||
| 	fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 } | ||||
| } | ||||
|  | ||||
| local slamp_cbox = { | ||||
| 	type = "fixed", | ||||
| 	fixed = { -0.25, -0.5, -0.25, 0.25, 1.5, 0.25 } | ||||
| } | ||||
|  | ||||
| local function reg_lamp(suffix, nxt, tilesuffix, light, color) | ||||
| 	local lampcolor = "_"..color | ||||
| 	local standingcolor = "_"..color | ||||
| 	local colordesc = " ("..color..")" | ||||
| 	if color == "" then | ||||
| 		lampcolor = "" | ||||
| 		standingcolor = "_white" | ||||
| 		colordesc  = " (white)" | ||||
| 	end | ||||
|  | ||||
| 	minetest.register_node("homedecor:table_lamp"..lampcolor.."_"..suffix, { | ||||
| 		description = S("Table Lamp "..colordesc), | ||||
| 	drawtype = "nodebox", | ||||
| 	tiles = { | ||||
| 		"forniture_table_lamp_s"..tilesuffix..".png", | ||||
| 		"forniture_table_lamp_s"..tilesuffix..".png", | ||||
| 		"forniture_table_lamp"..lampcolor.."_l"..tilesuffix..".png", | ||||
| 	}, | ||||
| 		drawtype = "mesh", | ||||
| 		mesh = "homedecor_table_lamp.obj", | ||||
| 		tiles = { "homedecor_table_standing_lamp"..lampcolor.."_"..suffix..".png" }, | ||||
| 		paramtype = "light", | ||||
| 	node_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = { | ||||
| 			{ -0.1500, -0.500, -0.1500,  0.1500, -0.45,  0.1500 }, | ||||
| 			{ -0.0500, -0.450, -0.0500,  0.0500, -0.40,  0.0500 }, | ||||
| 			{ -0.0250, -0.400, -0.0250,  0.0250, -0.10,  0.0250 }, | ||||
| 			{ -0.0125, -0.125, -0.2000,  0.0125, -0.10,  0.2000 }, | ||||
| 			{ -0.2000, -0.125, -0.0125,  0.2000, -0.10,  0.0125 }, | ||||
| 			{ -0.2000, -0.100, -0.2000, -0.1750,  0.30,  0.2000 }, | ||||
| 			{  0.1750, -0.100, -0.2000,  0.2000,  0.30,  0.2000 }, | ||||
| 			{ -0.1750, -0.100, -0.2000,  0.1750,  0.30, -0.1750 }, | ||||
| 			{ -0.1750, -0.100,  0.1750,  0.1750,  0.30,  0.2000 }, | ||||
| 		}, | ||||
| 	}, | ||||
| 		walkable = false, | ||||
| 		light_source = light, | ||||
| 	selection_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = { -0.2, -0.5, -0.2, 0.2, 0.30, 0.2 }, | ||||
| 	}, | ||||
| 		selection_box = tlamp_cbox, | ||||
| 		collision_box = tlamp_cbox, | ||||
| 		groups = {cracky=2,oddly_breakable_by_hand=1, | ||||
| 			not_in_creative_inventory=((light ~= nil) and 1) or nil, | ||||
| 		}, | ||||
| @@ -448,84 +438,42 @@ local function reg_lamp(suffix, nxt, tilesuffix, light, color) | ||||
| 			nodeupdate(pos) | ||||
| 		end, | ||||
| 	}) | ||||
| 	if lampcolor == "" then  | ||||
| 		minetest.register_alias("3dforniture:table_lamp_"..suffix, "homedecor:table_lamp_"..suffix) | ||||
| 	end | ||||
|  | ||||
| 	-- standing lamps | ||||
|  | ||||
| 	minetest.register_node("homedecor:standing_lamp_bottom"..lampcolor.."_"..suffix, { | ||||
| 	minetest.register_node("homedecor:standing_lamp"..lampcolor.."_"..suffix, { | ||||
| 		description = S("Standing Lamp"..colordesc), | ||||
| 	drawtype = "nodebox", | ||||
| 	tiles = { | ||||
| 		"forniture_table_lamp_s"..tilesuffix..".png", | ||||
| 		"homedecor_standing_lamp_bottom_sides.png", | ||||
| 	}, | ||||
| 	inventory_image = "homedecor_standing_lamp"..standingcolor.."_inv.png", | ||||
| 		drawtype = "mesh", | ||||
| 		mesh = "homedecor_standing_lamp.obj", | ||||
| 		tiles = { "homedecor_table_standing_lamp"..lampcolor.."_"..suffix..".png" }, | ||||
| 		inventory_image = "homedecor_standing_lamp"..lampcolor.."_inv.png", | ||||
| 		paramtype = "light", | ||||
| 	node_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = { | ||||
|                         { -0.1500, -0.500, -0.1500,  0.1500, -0.45,  0.1500 }, | ||||
| 			{ -0.0500, -0.450, -0.0500,  0.0500, -0.40,  0.0500 }, | ||||
| 			{ -0.0250, -0.400, -0.0250,  0.0250, 0.50,  0.0250 }, | ||||
| 		}, | ||||
| 	}, | ||||
| 		walkable = false, | ||||
| 		light_source = light, | ||||
| 	selection_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = { 0, 0, 0, 0, 0, 0} | ||||
| 	}, | ||||
| 		groups = {cracky=2,oddly_breakable_by_hand=1, | ||||
| 			not_in_creative_inventory=((light ~= nil) and 1) or nil, | ||||
| 		}, | ||||
| 		selection_box = slamp_cbox, | ||||
| 		collision_box = slamp_cbox, | ||||
| 		on_place = function(itemstack, placer, pointed_thing) | ||||
| 		return homedecor.stack_vertically(itemstack, placer, pointed_thing, | ||||
| 			"homedecor:standing_lamp_bottom"..lampcolor.."_"..suffix, "homedecor:standing_lamp_top"..lampcolor.."_"..suffix) | ||||
| 			return homedecor.place_twonode_vertical(itemstack, placer, pointed_thing, | ||||
| 				"homedecor:standing_lamp"..lampcolor.."_"..suffix) | ||||
| 		end, | ||||
| 	}) | ||||
| 	 | ||||
| 	minetest.register_node("homedecor:standing_lamp_top"..lampcolor.."_"..suffix, { | ||||
| 	drawtype = "nodebox", | ||||
| 	tiles = { | ||||
| 		"forniture_table_lamp_s"..tilesuffix..".png", | ||||
| 		"forniture_table_lamp_s"..tilesuffix..".png", | ||||
| 		"forniture_standing_lamp"..lampcolor.."_l"..tilesuffix..".png" | ||||
| 	}, | ||||
| 	paramtype = "light", | ||||
| 	node_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = { | ||||
| 			{ -0.0250, -0.500, -0.0250,  0.0250, 0.10,  0.0250 }, | ||||
| 			{ -0.0125, 0.0625, -0.2000,  0.0125, 0.10,  0.2000 }, | ||||
| 			{ -0.2000, 0.0625, -0.0125,  0.2000, 0.10,  0.0125 }, | ||||
| 			{ -0.2000, 0.100, -0.2000, -0.1750,  0.50,  0.2000 }, | ||||
| 			{  0.1750, 0.100, -0.2000,  0.2000,  0.50,  0.2000 }, | ||||
| 			{ -0.1750, 0.100, -0.2000,  0.1750,  0.50, -0.1750 }, | ||||
| 			{ -0.1750, 0.100,  0.1750,  0.1750,  0.50,  0.2000 }, | ||||
| 		}, | ||||
| 	}, | ||||
| 	walkable = false, | ||||
| 	light_source = light, | ||||
| 	selection_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = { -0.2, -1.5, -0.2, 0.2, 0.5, 0.2 }, | ||||
| 	}, | ||||
| 	groups = {snappy=3, not_in_creative_inventory=1}, | ||||
| 		on_punch = function(pos, node, puncher) | ||||
| 		node.name = "homedecor:standing_lamp_top"..lampcolor.."_"..repl[suffix] | ||||
| 			node.name = "homedecor:standing_lamp"..lampcolor.."_"..repl[suffix] | ||||
| 			minetest.set_node(pos, node) | ||||
| 			nodeupdate(pos) | ||||
| 		end, | ||||
| 	after_dig_node = function(pos, oldnode, oldmetadata, digger) | ||||
| 		local pos2 = { x = pos.x, y=pos.y - 1, z = pos.z } | ||||
| 		if minetest.get_node(pos2).name == "homedecor:standing_lamp_bottom"..lampcolor.."_off" then | ||||
| 			minetest.remove_node(pos2) | ||||
| 		end | ||||
| 	end, | ||||
| 	drop = "homedecor:standing_lamp_bottom"..lampcolor.."_off" | ||||
| 	}) | ||||
|  | ||||
| 	-- "bottom" in the node name is obsolete now, as "top" node doesn't exist anymore. | ||||
| 	minetest.register_alias("homedecor:standing_lamp_bottom"..lampcolor.."_"..suffix, "homedecor:standing_lamp"..lampcolor.."_"..suffix) | ||||
| 	minetest.register_alias("homedecor:standing_lamp_top"..lampcolor.."_"..suffix, "air") | ||||
|  | ||||
| 	-- for old maps that had 3dfornit`ure | ||||
| 	if lampcolor == "" then  | ||||
| 		minetest.register_alias("3dforniture:table_lamp_"..suffix, "homedecor:table_lamp_"..suffix) | ||||
| 	end | ||||
| end | ||||
|  | ||||
| for _, color in ipairs(lamp_colors) do | ||||
|   | ||||
							
								
								
									
										1999
									
								
								homedecor/models/homedecor_standing_lamp.obj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										1999
									
								
								homedecor/models/homedecor_table_lamp.obj
									
									
									
									
									
										Normal file
									
								
							
							
						
						| Before Width: | Height: | Size: 211 B | 
| Before Width: | Height: | Size: 215 B | 
| Before Width: | Height: | Size: 212 B | 
| Before Width: | Height: | Size: 213 B | 
| Before Width: | Height: | Size: 211 B | 
| Before Width: | Height: | Size: 237 B | 
| Before Width: | Height: | Size: 246 B | 
| Before Width: | Height: | Size: 304 B | 
| Before Width: | Height: | Size: 247 B | 
| Before Width: | Height: | Size: 243 B | 
| Before Width: | Height: | Size: 162 B | 
| Before Width: | Height: | Size: 168 B | 
| Before Width: | Height: | Size: 163 B | 
| Before Width: | Height: | Size: 161 B | 
| Before Width: | Height: | Size: 167 B | 
| Before Width: | Height: | Size: 271 B | 
| Before Width: | Height: | Size: 303 B | 
| Before Width: | Height: | Size: 268 B | 
| Before Width: | Height: | Size: 259 B | 
| Before Width: | Height: | Size: 236 B | 
| Before Width: | Height: | Size: 241 B | 
| Before Width: | Height: | Size: 246 B | 
| Before Width: | Height: | Size: 241 B | 
| Before Width: | Height: | Size: 245 B | 
| Before Width: | Height: | Size: 255 B | 
| Before Width: | Height: | Size: 249 B | 
| Before Width: | Height: | Size: 263 B | 
| Before Width: | Height: | Size: 254 B | 
| Before Width: | Height: | Size: 313 B | 
| Before Width: | Height: | Size: 248 B | 
| Before Width: | Height: | Size: 318 B | 
| Before Width: | Height: | Size: 325 B | 
| Before Width: | Height: | Size: 378 B | 
| Before Width: | Height: | Size: 316 B | 
| Before Width: | Height: | Size: 325 B | 
| Before Width: | Height: | Size: 394 B | 
| Before Width: | Height: | Size: 411 B | 
| Before Width: | Height: | Size: 325 B | 
| Before Width: | Height: | Size: 406 B | 
| Before Width: | Height: | Size: 334 B | 
| Before Width: | Height: | Size: 220 B | 
| Before Width: | Height: | Size: 267 B | 
| Before Width: | Height: | Size: 225 B | 
| Before Width: | Height: | Size: 261 B | 
| Before Width: | Height: | Size: 270 B | 
| Before Width: | Height: | Size: 434 B | 
| Before Width: | Height: | Size: 408 B | 
| Before Width: | Height: | Size: 430 B | 
| Before Width: | Height: | Size: 416 B | 
| Before Width: | Height: | Size: 343 B | 
| Before Width: | Height: | Size: 328 B | 
| Before Width: | Height: | Size: 375 B | 
| Before Width: | Height: | Size: 358 B | 
| Before Width: | Height: | Size: 364 B | 
| Before Width: | Height: | Size: 383 B | 
| Before Width: | Height: | Size: 311 B | 
| Before Width: | Height: | Size: 309 B | 
| Before Width: | Height: | Size: 309 B | 
| Before Width: | Height: | Size: 306 B | 
| Before Width: | Height: | Size: 309 B | 
| Before Width: | Height: | Size: 339 B | 
| Before Width: | Height: | Size: 420 B | 
| Before Width: | Height: | Size: 305 B | 
| Before Width: | Height: | Size: 410 B | 
| Before Width: | Height: | Size: 414 B | 
| Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.7 KiB | 
| Before Width: | Height: | Size: 82 B | 
| Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_standing_lamp_inv.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 1.7 KiB | 
| Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB | 
| Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB | 
| Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.7 KiB | 
| Before Width: | Height: | Size: 1.3 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_blue_hi.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 13 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_blue_low.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_blue_max.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 12 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_blue_med.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 13 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_blue_off.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_green_hi.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 13 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_green_low.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_green_max.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 12 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_green_med.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 13 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_green_off.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_hi.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 13 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_low.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_max.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 12 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_med.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_off.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_pink_hi.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_pink_low.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 15 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_pink_max.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_pink_med.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_pink_off.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_red_hi.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 13 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_red_low.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 14 KiB | 
							
								
								
									
										
											BIN
										
									
								
								homedecor/textures/homedecor_table_standing_lamp_red_max.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 12 KiB |