]> git.lizzy.rs Git - xdecor.git/blobdiff - nodes.lua
More cleanup
[xdecor.git] / nodes.lua
index 3dddd9eec4757b384a0e7d64195b6d231210aa64..aa3cc4b0b52ea2a984782c360474f926c94f46e0 100644 (file)
--- a/nodes.lua
+++ b/nodes.lua
@@ -1,5 +1,4 @@
 screwdriver = screwdriver or {}
-local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
 
 xpanes.register_pane("bamboo_frame", {
        description = "Bamboo Frame",
@@ -107,6 +106,8 @@ xpanes.register_pane("chainlink", {
        }
 })
 
+-- The following nodedef is licensed under WTFPL for granting a possible re-use
+-- in Minetest Game (https://github.com/minetest/minetest_game). 
 xdecor.register("cobweb", {
        description = "Cobweb",
        drawtype = "plantlike",
@@ -135,7 +136,7 @@ for _, c in pairs({"red"}) do  -- Add more curtains colors simply here.
                paramtype2 = "wallmounted",
                groups = {dig_immediate=3, flammable=3},
                selection_box = {type="wallmounted"},
-               on_rightclick = function(pos, node, _, _)
+               on_rightclick = function(pos, node)
                        minetest.set_node(pos, {name="xdecor:curtain_open_"..c, param2=node.param2})
                end
        })
@@ -148,7 +149,7 @@ for _, c in pairs({"red"}) do  -- Add more curtains colors simply here.
                groups = {dig_immediate=3, flammable=3, not_in_creative_inventory=1},
                selection_box = {type="wallmounted"},
                drop = "xdecor:curtain_"..c,
-               on_rightclick = function(pos, node, _, _)
+               on_rightclick = function(pos, node)
                        minetest.set_node(pos, {name="xdecor:curtain_"..c, param2=node.param2})
                end
        })
@@ -171,6 +172,12 @@ xdecor.register("crate", {
        sounds = default.node_sound_wood_defaults()
 })
 
+xdecor.register("cushion_block", {
+       tiles = {"xdecor_cushion.png"},
+       groups = {snappy=3, flammable=3, fall_damage_add_percent=-75, not_in_creative_inventory=1},
+       drop = "xdecor:cushion 2"
+})
+
 local function door_access(door)
        return door:find("prison")
 end
@@ -182,7 +189,7 @@ local door_types = {
 
 for _, d in pairs(door_types) do
        doors.register_door("xdecor:"..d[1].."_door", {
-               description = string.gsub(d[1]:gsub("^%l", string.upper), "_r", " R").." Door",
+               description = string.gsub(" "..d[1], "%W%l", string.upper):sub(2):gsub("_", " ").." Door",
                inventory_image = "xdecor_"..d[1].."_door_inv.png",
                groups = {choppy=3, cracky=3, oddly_breakable_by_hand=1, flammable=2, door=1},
                tiles_bottom = {"xdecor_"..d[1].."_door_b.png", "xdecor_"..d[2]..".png"},
@@ -215,11 +222,12 @@ xdecor.register("enderchest", {
        on_rotate = screwdriver.rotate_simple,
        on_construct = function(pos)
                local meta = minetest.get_meta(pos)
-               meta:set_string("formspec", "size[8,9]"..xbg..default.get_hotbar_bg(0,5)..
-                               "list[current_player;enderchest;0,0;8,4;]"..
-                               "list[current_player;main;0,5;8,4;]"..
-                               "listring[current_player;enderchest]"..
-                               "listring[current_player;main]")
+               meta:set_string("formspec", [[ size[8,9]
+                               list[current_player;enderchest;0,0;8,4;]
+                               list[current_player;main;0,5;8,4;]
+                               listring[current_player;enderchest]
+                               listring[current_player;main] ]]
+                               ..xbg..default.get_hotbar_bg(0,5))
                meta:set_string("infotext", "Ender Chest")
        end
 })
@@ -246,35 +254,6 @@ xdecor.register("fire", {
        groups = {dig_immediate=3, hot=3, not_in_creative_inventory=1}
 })
 
-minetest.register_tool("xdecor:flint_steel", {
-       description = "Flint & Steel",
-       inventory_image = "xdecor_flint_steel.png",
-       tool_capabilities = {
-               groupcaps = { igniter = {uses=10, maxlevel=1} }
-       },
-       on_use = function(itemstack, user, pointed_thing)
-               local player = user:get_player_name()
-               if pointed_thing.type == "node" and
-                               minetest.get_node(pointed_thing.above).name == "air" then
-                       if not minetest.is_protected(pointed_thing.above, player) then
-                               minetest.set_node(pointed_thing.above, {name="xdecor:fire"})
-                       else
-                               minetest.chat_send_player(player, "This area is protected.")
-                       end
-               end
-
-               itemstack:add_wear(1000)
-               return itemstack
-       end
-})
-
-minetest.register_tool("xdecor:hammer", {
-       description = "Hammer",
-       inventory_image = "xdecor_hammer.png",
-       wield_image = "xdecor_hammer.png",
-       on_use = function(...) do return end end
-})
-
 xdecor.register("ivy", {
        description = "Ivy",
        drawtype = "signlike",
@@ -310,13 +289,17 @@ xdecor.register("lantern", {
        }
 })
 
-xdecor.register("lightbox", {
-       description = "Light Box",
-       tiles = {"xdecor_lightbox.png"},
-       groups = {cracky=3, choppy=3, oddly_breakable_by_hand=2},
-       light_source = 13,
-       sounds = default.node_sound_glass_defaults()
-})
+for _, l in pairs({"iron", "wooden"}) do
+       xdecor.register(l.."_lightbox", {
+               description = l:gsub("^%l", string.upper).." Light Box",
+               tiles = {"xdecor_"..l.."_lightbox.png"},
+               groups = {cracky=3, choppy=3, oddly_breakable_by_hand=2},
+               light_source = 13,
+               sounds = default.node_sound_glass_defaults()
+       })
+end
+
+minetest.register_alias("xdecor:lightbox", "xdecor:wooden_lightbox")
 
 xdecor.register("packed_ice", {
        drawtype = "normal",
@@ -360,20 +343,21 @@ xdecor.register("painting_1", {
        wield_image = "xdecor_painting_empty.png",
        sunlight_propagates = true,
        groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1},
+       sounds = default.node_sound_wood_defaults(),
        node_box = {
                type = "wallmounted",
                wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
                wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
                wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
        },
-       after_place_node = function(pos, _, _, _)
+       on_construct = function(pos)
                local node = minetest.get_node(pos)
-               minetest.set_node(pos, {name="xdecor:painting_"..math.random(1,4), param2=node.param2})
+               local random = math.random(4)
+               if random == 1 then return end
+               minetest.set_node(pos, {name="xdecor:painting_"..random, param2=node.param2})
        end
 })
 
-minetest.register_alias("xdecor:painting", "xdecor:painting_1")
-
 for i = 2, 4 do
        xdecor.register("painting_"..i, {
                tiles = {"xdecor_painting_"..i..".png"},
@@ -382,6 +366,7 @@ for i = 2, 4 do
                drop = "xdecor:painting_1",
                sunlight_propagates = true,
                groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1, not_in_creative_inventory=1},
+               sounds = default.node_sound_wood_defaults(),
                node_box = {
                        type = "wallmounted",
                        wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
@@ -441,24 +426,22 @@ xdecor.register("stonepath", {
        on_rotate = screwdriver.rotate_simple,
        sounds = default.node_sound_stone_defaults(),
        sunlight_propagates = true,
-       node_box = {
-               type = "fixed",
-               fixed = {{0, -0.5, 0, 0.375, -0.47, 0.375},
-                       {-0.4375, -0.5, -0.4375, -0.0625, -0.47, -0.0625},
-                       {-0.4375, -0.5, 0.125, -0.125, -0.47, 0.4375},
-                       {0.125, -0.5, -0.375, 0.375, -0.47, -0.125}}
-       },
+       node_box = xdecor.pixelnodebox(16, {
+               {8,  0,  8, 6, 0.5, 6},
+               {1,  0,  1, 6, 0.5, 6},
+               {1,  0, 10, 5, 0.5, 5},
+               {10, 0,  2, 4, 0.5, 4}
+       }),
        selection_box = xdecor.nodebox.slab_y(0.05)
 })
 
-local stonish = {"desertstone_tile", "stone_tile", "stone_rune", "coalstone_tile",
-               "hard_clay"}
+local stonish = {"desertstone_tile", "stone_tile", "stone_rune",
+               "coalstone_tile", "hard_clay"}
 
 for _, t in pairs(stonish) do
        xdecor.register(t, {
                drawtype = "normal",
-               description = string.sub(t:gsub("^%l", string.upper), 1, -6)
-                               .." "..t:sub(-4):gsub("^%l", string.upper),
+               description = string.gsub(" "..t, "%W%l", string.upper):sub(2):gsub("_", " "),
                tiles = {"xdecor_"..t..".png"},
                groups = {cracky=1},
                sounds = default.node_sound_stone_defaults()
@@ -470,11 +453,9 @@ xdecor.register("table", {
        tiles = {"xdecor_wood.png"},
        groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
        sounds = default.node_sound_wood_defaults(),
-       node_box = {
-               type = "fixed",
-               fixed = {{-0.5, 0.4, -0.5, 0.5, 0.5, 0.5},
-                       {-0.15, -0.5, -0.15, 0.15, 0.4, 0.15}}
-       }
+       node_box = xdecor.pixelnodebox(16, {
+               {0, 14, 0, 16, 2, 16}, {5.5, 0, 5.5, 5, 14, 6}
+       })
 })
 
 xdecor.register("tatami", {
@@ -482,9 +463,7 @@ xdecor.register("tatami", {
        tiles = {"xdecor_tatami.png"},
        wield_image = "xdecor_tatami.png",
        groups = {snappy=3, flammable=3},
-       node_box = {
-               type = "fixed", fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}}
-       }
+       node_box = xdecor.nodebox.slab_y(0.0625)
 })
 
 xdecor.register("tv", {