From 4530cfad2934c38deab2946373ba20604893dbfe Mon Sep 17 00:00:00 2001 From: "0gb.us" <0gb.us@0gb.us> Date: Wed, 20 Mar 2013 02:02:26 -0700 Subject: [PATCH] Fixed slabfix_0gb_us to be compatible with Minetest 0.4.5. Minetest 0.4.5's minetest_game adds new upside down slabs and stairs, which I was unaware of. The old slab fix made using upside down slabs impossible. This new version fixes that incompatability. ... of course, Minetest 0.4.6's minetest_game fixes the root of the problem, by making the slab recipe yeild six slabs as it should. Once Minetest 0.4.6 is released, there will be no more need for the slab fix, as slabs will no longer be broken. --- .../mods/added/slabfix_0gb_us/init.lua | 49 +++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/0gb.us_game/mods/added/slabfix_0gb_us/init.lua b/0gb.us_game/mods/added/slabfix_0gb_us/init.lua index aba8478..b338f69 100644 --- a/0gb.us_game/mods/added/slabfix_0gb_us/init.lua +++ b/0gb.us_game/mods/added/slabfix_0gb_us/init.lua @@ -27,10 +27,10 @@ for _, subname in pairs({ slabnode = n0 end if slabpos then - -- Remove the slab at slabpos ---[[ minetest.env:remove_node(slabpos) + --[[ 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) + local fakestack = ItemStack("default:" .. subname) pointed_thing.above = slabpos fakestack = minetest.item_place(fakestack, placer, pointed_thing) -- If the item was taken from the fake stack, decrement original @@ -42,7 +42,48 @@ for _, subname in pairs({ end]] return itemstack end - + + -- Upside down slabs + if p0.y-1 == p1.y then + -- Turn into full block if pointing at a existing slab + if n0.name == "stairs:slab_" .. subname.."upside_down" then + --[[ Remove the slab at the position of the slab + minetest.env:remove_node(p0) + -- Make a fake stack of a single item and try to place it + local fakestack = ItemStack("default:" .. subname) + pointed_thing.above = p0 + 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(p0, n0) + end]] + return itemstack + end + + -- Place upside down slab + local fakestack = ItemStack("stairs:slab_" .. subname.."upside_down") + local ret = minetest.item_place(fakestack, placer, pointed_thing) + if ret:is_empty() then + itemstack:take_item() + return itemstack + end + end + + -- If pointing at the side of a upside down slab + if n0.name == "stairs:slab_" .. subname.."upside_down" and + p0.y+1 ~= p1.y then + -- Place upside down slab + local fakestack = ItemStack("stairs:slab_" .. subname.."upside_down") + local ret = minetest.item_place(fakestack, placer, pointed_thing) + if ret:is_empty() then + itemstack:take_item() + return itemstack + end + end + -- Otherwise place regularly return minetest.item_place(itemstack, placer, pointed_thing) end