forked from luanti-org/minetest_game
		
	Add flipped stair recipe for silly minecrafters and make slabs convert to full cubes when placed on each other
This commit is contained in:
		| @@ -30,6 +30,16 @@ function stairs.register_stair(subname, recipeitem, groups, images, description) | ||||
| 			{recipeitem, recipeitem, recipeitem}, | ||||
| 		}, | ||||
| 	}) | ||||
|  | ||||
| 	-- Flipped recipe for the silly minecrafters | ||||
| 	minetest.register_craft({ | ||||
| 		output = 'stairs:stair_' .. subname .. ' 4', | ||||
| 		recipe = { | ||||
| 			{"", "", recipeitem}, | ||||
| 			{"", recipeitem, recipeitem}, | ||||
| 			{recipeitem, recipeitem, recipeitem}, | ||||
| 		}, | ||||
| 	}) | ||||
| end | ||||
|  | ||||
| -- Node will be called stairs:slab_<subname> | ||||
| @@ -49,6 +59,46 @@ function stairs.register_slab(subname, recipeitem, groups, images, description) | ||||
| 			type = "fixed", | ||||
| 			fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, | ||||
| 		}, | ||||
| 		on_place = function(itemstack, placer, pointed_thing) | ||||
| 			if pointed_thing.type ~= "node" then | ||||
| 				return itemstack | ||||
| 			end | ||||
|  | ||||
| 			-- If it's being placed on an another similar one, replace it with | ||||
| 			-- a full block | ||||
| 			local slabpos = nil | ||||
| 			local slabnode = nil | ||||
| 			local p0 = pointed_thing.under | ||||
| 			local p1 = pointed_thing.above | ||||
| 			local n0 = minetest.env:get_node(p0) | ||||
| 			local n1 = minetest.env:get_node(p1) | ||||
| 			if n0.name == "stairs:slab_" .. subname then | ||||
| 				slabpos = p0 | ||||
| 				slabnode = n0 | ||||
| 			elseif n1.name == "stairs:slab_" .. subname then | ||||
| 				slabpos = p1 | ||||
| 				slabnode = n1 | ||||
| 			end | ||||
| 			if slabpos then | ||||
| 				-- Remove the slab at slabpos | ||||
| 				minetest.env:remove_node(slabpos) | ||||
| 				-- Make a fake stack of a single item and try to place it | ||||
| 				local fakestack = ItemStack(recipeitem) | ||||
| 				pointed_thing.above = slabpos | ||||
| 				fakestack = minetest.item_place(fakestack, placer, pointed_thing) | ||||
| 				-- If the item was taken from the fake stack, decrement original | ||||
| 				if not fakestack or fakestack:is_empty() then | ||||
| 					itemstack:take_item(1) | ||||
| 				-- Else put old node back | ||||
| 				else | ||||
| 					minetest.env:set_node(slabpos, slabnode) | ||||
| 				end | ||||
| 				return itemstack | ||||
| 			end | ||||
| 			 | ||||
| 			-- Otherwise place regularly | ||||
| 			return minetest.item_place(itemstack, placer, pointed_thing) | ||||
| 		end, | ||||
| 	}) | ||||
|  | ||||
| 	minetest.register_craft({ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user