]> git.lizzy.rs Git - xdecor.git/blob - nodes.lua
Work table nodeboxes : register stairs and slabs with 'stairs' mod from default game
[xdecor.git] / nodes.lua
1 screwdriver = screwdriver or {}
2
3 xpanes.register_pane("bamboo_frame", {
4         description = "Bamboo Frame",
5         tiles = {"xdecor_bamboo_frame.png"},
6         drawtype = "airlike",
7         paramtype = "light",
8         textures = {"xdecor_bamboo_frame.png", "xdecor_bamboo_frame.png", "xpanes_space.png"},
9         inventory_image = "xdecor_bamboo_frame.png",
10         wield_image = "xdecor_bamboo_frame.png",
11         groups = {choppy=3, oddly_breakable_by_hand=2, pane=1, flammable=2},
12         recipe = {
13                 {"default:papyrus", "default:papyrus", "default:papyrus"},
14                 {"default:papyrus", "farming:cotton", "default:papyrus"},
15                 {"default:papyrus", "default:papyrus", "default:papyrus"}
16         }
17 })
18
19 xdecor.register("baricade", {
20         description = "Baricade",
21         drawtype = "plantlike",
22         walkable = false,
23         inventory_image = "xdecor_baricade.png",
24         tiles = {"xdecor_baricade.png"},
25         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
26         damage_per_second = 4,
27         selection_box = xdecor.nodebox.slab_y(0.3)
28 })
29
30 xdecor.register("barrel", {
31         description = "Barrel",
32         inventory = {size=24},
33         infotext = "Barrel",
34         tiles = {"xdecor_barrel_top.png", "xdecor_barrel_sides.png"},
35         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
36         sounds = default.node_sound_wood_defaults()
37 })
38
39 xdecor.register("cabinet", {
40         description = "Wood Cabinet",
41         inventory = {size=24},
42         infotext = "Wood Cabinet",
43         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
44         sounds = default.node_sound_wood_defaults(),
45         on_rotate = screwdriver.rotate_simple,
46         tiles = {
47                 "xdecor_cabinet_sides.png", "xdecor_cabinet_sides.png",
48                 "xdecor_cabinet_sides.png", "xdecor_cabinet_sides.png",
49                 "xdecor_cabinet_sides.png", "xdecor_cabinet_front.png"
50         }
51 })
52
53 xdecor.register("cabinet_half", {
54         description = "Half Wood Cabinet",
55         inventory = {size=8},
56         infotext = "Half Wood Cabinet",
57         groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
58         sounds = default.node_sound_wood_defaults(),
59         node_box = xdecor.nodebox.slab_y(0.5, 0.5),
60         tiles = {
61                 "xdecor_cabinet_sides.png", "xdecor_cabinet_sides.png",
62                 "xdecor_half_cabinet_sides.png", "xdecor_half_cabinet_sides.png",
63                 "xdecor_half_cabinet_sides.png", "xdecor_half_cabinet_front.png"
64         }
65 })
66
67 xdecor.register("candle", {
68         description = "Candle",
69         light_source = 12,
70         drawtype = "torchlike",
71         inventory_image = "xdecor_candle_inv.png",
72         wield_image = "xdecor_candle_wield.png",
73         paramtype2 = "wallmounted",
74         legacy_wallmounted = true,
75         walkable = false,
76         groups = {dig_immediate=3, attached_node=1},
77         tiles = {
78                 { name = "xdecor_candle_floor.png",
79                         animation = {type="vertical_frames", length=1.5} },
80                 { name = "xdecor_candle_ceiling.png",
81                         animation = {type="vertical_frames", length=1.5} },
82                 { name = "xdecor_candle_wall.png",
83                         animation = {type="vertical_frames", length=1.5} }
84         },
85         selection_box = {
86                 type = "wallmounted",
87                 wall_top = {-0.3, -0.4, -0.3, 0.3, 0.5, 0.3},
88                 wall_bottom = {-0.25, -0.5, -0.25, 0.25, 0.1, 0.25},
89                 wall_side = {-0.5, -0.35, -0.15, -0.15, 0.4, 0.15}
90         }
91 })
92
93 xpanes.register_pane("chainlink", {
94         description = "Chain Link",
95         tiles = {"xdecor_chainlink.png"},
96         drawtype = "airlike",
97         paramtype = "light",
98         textures = {"xdecor_chainlink.png", "xdecor_chainlink.png", "xpanes_space.png"},
99         inventory_image = "xdecor_chainlink.png",
100         wield_image = "xdecor_chainlink.png",
101         groups = {cracky=3, oddly_breakable_by_hand=2, pane=1},
102         recipe = {
103                 {"default:steel_ingot", "", "default:steel_ingot"},
104                 {"", "default:steel_ingot", ""},
105                 {"default:steel_ingot", "", "default:steel_ingot"}
106         }
107 })
108
109 -- The following nodedef is licensed under WTFPL for granting a possible re-use
110 -- in Minetest Game (https://github.com/minetest/minetest_game). 
111 xdecor.register("cobweb", {
112         description = "Cobweb",
113         drawtype = "plantlike",
114         tiles = {"xdecor_cobweb.png"},
115         inventory_image = "xdecor_cobweb.png",
116         liquid_viscosity = 8,
117         liquidtype = "source",
118         liquid_alternative_flowing = "xdecor:cobweb",
119         liquid_alternative_source = "xdecor:cobweb",
120         liquid_renewable = false,
121         liquid_range = 0,
122         walkable = false,
123         selection_box = {type = "regular"},
124         groups = {dig_immediate=3, liquid=3, flammable=3},
125         sounds = default.node_sound_leaves_defaults()
126 })
127
128 for _, c in pairs({"red"}) do  -- Add more curtains colors simply here.
129         xdecor.register("curtain_"..c, {
130                 description = c:gsub("^%l", string.upper).." Curtain",
131                 walkable = false,
132                 tiles = {"wool_white.png^[colorize:"..c..":170"},
133                 inventory_image = "wool_white.png^[colorize:"..c..":170^xdecor_curtain_open_overlay.png^[makealpha:255,126,126",
134                 wield_image = "wool_white.png^[colorize:"..c..":170",
135                 drawtype = "signlike",
136                 paramtype2 = "wallmounted",
137                 groups = {dig_immediate=3, flammable=3},
138                 selection_box = {type="wallmounted"},
139                 on_rightclick = function(pos, node)
140                         minetest.set_node(pos, {name="xdecor:curtain_open_"..c, param2=node.param2})
141                 end
142         })
143
144         xdecor.register("curtain_open_"..c, {
145                 tiles = {"wool_white.png^[colorize:"..c..":170^xdecor_curtain_open_overlay.png^[makealpha:255,126,126"},
146                 drawtype = "signlike",
147                 paramtype2 = "wallmounted",
148                 walkable = false,
149                 groups = {dig_immediate=3, flammable=3, not_in_creative_inventory=1},
150                 selection_box = {type="wallmounted"},
151                 drop = "xdecor:curtain_"..c,
152                 on_rightclick = function(pos, node)
153                         minetest.set_node(pos, {name="xdecor:curtain_"..c, param2=node.param2})
154                 end
155         })
156
157         minetest.register_craft({
158                 output = "xdecor:curtain_"..c.." 4",
159                 recipe = {
160                         {"", "wool:"..c, ""},
161                         {"", "wool:"..c, ""}
162                 }
163         })
164 end
165
166 xdecor.register("crate", {
167         description = "Crate",
168         inventory = {size=24},
169         infotext = "Crate",
170         tiles = {"xdecor_crate.png"},
171         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
172         sounds = default.node_sound_wood_defaults()
173 })
174
175 xdecor.register("cushion_block", {
176         tiles = {"xdecor_cushion.png"},
177         groups = {snappy=3, flammable=3, fall_damage_add_percent=-75, not_in_creative_inventory=1},
178         drop = "xdecor:cushion 2"
179 })
180
181 local function door_access(door)
182         return door:find("prison")
183 end
184
185 local door_types = {
186         {"japanese", "brown"}, {"prison", "grey"}, {"prison_rust", "rust"},
187         {"screen", "brownb"}, {"slide", "brownc"}, {"woodglass", "brown"}
188 }
189
190 for _, d in pairs(door_types) do
191         doors.register_door("xdecor:"..d[1].."_door", {
192                 description = string.gsub(" "..d[1], "%W%l", string.upper):sub(2):gsub("_", " ").." Door",
193                 inventory_image = "xdecor_"..d[1].."_door_inv.png",
194                 groups = {choppy=3, cracky=3, oddly_breakable_by_hand=1, flammable=2, door=1},
195                 tiles_bottom = {"xdecor_"..d[1].."_door_b.png", "xdecor_"..d[2]..".png"},
196                 tiles_top = {"xdecor_"..d[1].."_door_a.png", "xdecor_"..d[2]..".png"},
197                 only_placer_can_open = door_access(d[1]),
198                 sounds = default.node_sound_wood_defaults(),
199                 sunlight = false
200         })
201 end
202
203 xdecor.register("empty_shelf", {
204         description = "Empty Shelf",
205         inventory = {size=24},
206         infotext = "Empty Shelf",
207         tiles = {"default_wood.png", "default_wood.png^xdecor_empty_shelf.png"},
208         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
209         sounds = default.node_sound_wood_defaults(),
210         on_rotate = screwdriver.rotate_simple
211 })
212
213 xdecor.register("enderchest", {
214         description = "Ender Chest",
215         tiles = {
216                 "xdecor_enderchest_top.png", "xdecor_enderchest_top.png",
217                 "xdecor_enderchest_side.png", "xdecor_enderchest_side.png",
218                 "xdecor_enderchest_side.png", "xdecor_enderchest_front.png"
219         },
220         groups = {cracky=1, choppy=1, oddly_breakable_by_hand=1},
221         sounds = default.node_sound_stone_defaults(),
222         on_rotate = screwdriver.rotate_simple,
223         on_construct = function(pos)
224                 local meta = minetest.get_meta(pos)
225                 meta:set_string("formspec", [[ size[8,9]
226                                 list[current_player;enderchest;0,0;8,4;]
227                                 list[current_player;main;0,5;8,4;]
228                                 listring[current_player;enderchest]
229                                 listring[current_player;main] ]]
230                                 ..xbg..default.get_hotbar_bg(0,5))
231                 meta:set_string("infotext", "Ender Chest")
232         end
233 })
234
235 minetest.register_on_joinplayer(function(player)
236         local inv = player:get_inventory()
237         inv:set_size("enderchest", 8*4)
238 end)
239
240 xdecor.register("fire", {
241         description = "Fancy Fire",
242         drawtype = "plantlike",
243         light_source = 14,
244         walkable = false,
245         tiles = {
246                 { name = "xdecor_fire_anim.png",
247                 animation = {type="vertical_frames", length=1.5} }
248         },
249         damage_per_second = 4,
250         drop = "",
251         selection_box = {
252                 type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, -0.3, 0.3}
253         },
254         groups = {dig_immediate=3, hot=3, not_in_creative_inventory=1}
255 })
256
257 xdecor.register("ivy", {
258         description = "Ivy",
259         drawtype = "signlike",
260         walkable = false,
261         climbable = true,
262         groups = {dig_immediate=3, flammable=3, plant=1},
263         paramtype2 = "wallmounted",
264         selection_box = {type="wallmounted"},
265         legacy_wallmounted = true,
266         tiles = {"xdecor_ivy.png"},
267         inventory_image = "xdecor_ivy.png",
268         wield_image = "xdecor_ivy.png",
269         sounds = default.node_sound_leaves_defaults()
270 })
271
272 xdecor.register("lantern", {
273         description = "Lantern",
274         light_source = 12,
275         drawtype = "torchlike",
276         inventory_image = "xdecor_lantern_floor.png",
277         wield_image = "xdecor_lantern_floor.png", 
278         paramtype2 = "wallmounted",
279         legacy_wallmounted = true,
280         walkable = false,
281         groups = {dig_immediate=3, attached_node=1},
282         tiles = {"xdecor_lantern_floor.png", "xdecor_lantern_ceiling.png",
283                         "xdecor_lantern.png"},
284         selection_box = {
285                 type = "wallmounted",
286                 wall_top = {-0.25, -0.4, -0.25, 0.25, 0.5, 0.25},
287                 wall_bottom = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25},
288                 wall_side = {-0.5, -0.5, -0.15, 0.5, 0.5, 0.15}
289         }
290 })
291
292 for _, l in pairs({"iron", "wooden"}) do
293         xdecor.register(l.."_lightbox", {
294                 description = l:gsub("^%l", string.upper).." Light Box",
295                 tiles = {"xdecor_"..l.."_lightbox.png"},
296                 groups = {cracky=3, choppy=3, oddly_breakable_by_hand=2},
297                 light_source = 13,
298                 sounds = default.node_sound_glass_defaults()
299         })
300 end
301
302 minetest.register_alias("xdecor:lightbox", "xdecor:wooden_lightbox")
303
304 xdecor.register("packed_ice", {
305         drawtype = "normal",
306         description = "Packed Ice",
307         tiles = {"xdecor_packed_ice.png"},
308         groups = {cracky=1, puts_out_fire=1},
309         sounds = default.node_sound_glass_defaults()
310 })
311
312 local flowers = {"dandelion_white", "dandelion_yellow", "geranium", "rose",
313                 "tulip", "viola"}
314
315 for _, f in pairs(flowers) do
316         xdecor.register("potted_"..f, {
317                 description = string.gsub("Potted Flowers ("..f..")", "_", " "),
318                 walkable = false,
319                 groups = {dig_immediate=3, flammable=3, plant=1, flower=1},
320                 tiles = {"xdecor_"..f.."_pot.png"},
321                 inventory_image = "xdecor_"..f.."_pot.png",
322                 drawtype = "plantlike",
323                 sounds = default.node_sound_leaves_defaults(),
324                 selection_box = xdecor.nodebox.slab_y(0.3)
325         })
326
327         minetest.register_craft({
328                 output = "xdecor:potted_"..f,
329                 recipe = {
330                         {"default:clay_brick", "flowers:"..f, "default:clay_brick"},
331                         {"", "default:clay_brick", ""}
332                 }
333         })
334 end
335
336 xdecor.register("painting_1", {
337         description = "Painting",
338         tiles = {"xdecor_painting_1.png"},
339         inventory_image = "xdecor_painting_empty.png",
340         wield_image = "xdecor_painting_empty.png",
341         paramtype2 = "wallmounted",
342         legacy_wallmounted = true,
343         wield_image = "xdecor_painting_empty.png",
344         sunlight_propagates = true,
345         groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1},
346         sounds = default.node_sound_wood_defaults(),
347         node_box = {
348                 type = "wallmounted",
349                 wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
350                 wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
351                 wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
352         },
353         on_construct = function(pos)
354                 local node = minetest.get_node(pos)
355                 local random = math.random(4)
356                 if random == 1 then return end
357                 minetest.set_node(pos, {name="xdecor:painting_"..random, param2=node.param2})
358         end
359 })
360
361 for i = 2, 4 do
362         xdecor.register("painting_"..i, {
363                 tiles = {"xdecor_painting_"..i..".png"},
364                 paramtype2 = "wallmounted",
365                 legacy_wallmounted = true,
366                 drop = "xdecor:painting_1",
367                 sunlight_propagates = true,
368                 groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1, not_in_creative_inventory=1},
369                 sounds = default.node_sound_wood_defaults(),
370                 node_box = {
371                         type = "wallmounted",
372                         wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
373                         wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
374                         wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
375                 }
376         })
377 end
378
379 for _, b in pairs({{"cactus", "cactus"}, {"moon", "stone"}}) do
380         xdecor.register(b[1].."brick", {
381                 drawtype = "normal",
382                 description = b[1]:gsub("^%l", string.upper).." Brick",
383                 tiles = {"xdecor_"..b[1].."brick.png"},
384                 groups = {cracky=2},
385                 sounds = default.node_sound_stone_defaults(),
386         })
387         
388         minetest.register_craft({
389         output = "xdecor:"..b[1].."brick",
390         recipe = {
391                 {"default:brick", "default:"..b[2]}
392         }
393 })
394 end
395
396 xdecor.register("multishelf", {
397         description = "Multi Shelf",
398         inventory = {size=24},
399         infotext = "Multi Shelf",
400         on_rotate = screwdriver.rotate_simple,
401         tiles = {"default_wood.png", "default_wood.png^xdecor_multishelf.png"},
402         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
403         sounds = default.node_sound_wood_defaults()
404 })
405
406 xpanes.register_pane("rust_bar", {
407         description = "Rust Bars",
408         tiles = {"xdecor_rust_bars.png"},
409         drawtype = "airlike",
410         paramtype = "light",
411         textures = {"xdecor_rust_bars.png", "xdecor_rust_bars.png", "xpanes_space.png"},
412         inventory_image = "xdecor_rust_bars.png",
413         wield_image = "xdecor_rust_bars.png",
414         groups = {cracky=3, oddly_breakable_by_hand=2, pane=1},
415         recipe = {
416                 {"", "default:dirt", ""},
417                 {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
418                 {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
419         }
420 })
421
422 xdecor.register("stonepath", {
423         description = "Garden Stone Path",
424         tiles = {"default_stone.png"},
425         groups = {snappy=3},
426         on_rotate = screwdriver.rotate_simple,
427         sounds = default.node_sound_stone_defaults(),
428         sunlight_propagates = true,
429         node_box = xdecor.pixelnodebox(16, {
430                 {8,  0,  8, 6, 0.5, 6},
431                 {1,  0,  1, 6, 0.5, 6},
432                 {1,  0, 10, 5, 0.5, 5},
433                 {10, 0,  2, 4, 0.5, 4}
434         }),
435         selection_box = xdecor.nodebox.slab_y(0.05)
436 })
437
438 local stonish = {"desertstone_tile", "stone_tile", "stone_rune",
439                 "coalstone_tile", "hard_clay"}
440
441 for _, t in pairs(stonish) do
442         xdecor.register(t, {
443                 drawtype = "normal",
444                 description = string.gsub(" "..t, "%W%l", string.upper):sub(2):gsub("_", " "),
445                 tiles = {"xdecor_"..t..".png"},
446                 groups = {cracky=1},
447                 sounds = default.node_sound_stone_defaults()
448         })
449 end
450
451 xdecor.register("table", {
452         description = "Table",
453         tiles = {"xdecor_wood.png"},
454         groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
455         sounds = default.node_sound_wood_defaults(),
456         node_box = xdecor.pixelnodebox(16, {
457                 {0, 14, 0, 16, 2, 16}, {5.5, 0, 5.5, 5, 14, 6}
458         })
459 })
460
461 xdecor.register("tatami", {
462         description = "Tatami",
463         tiles = {"xdecor_tatami.png"},
464         wield_image = "xdecor_tatami.png",
465         groups = {snappy=3, flammable=3},
466         node_box = xdecor.nodebox.slab_y(0.0625)
467 })
468
469 xdecor.register("tv", {
470         description = "Television",
471         light_source = 11,
472         groups = {snappy=3},
473         on_rotate = screwdriver.rotate_simple,
474         tiles = {
475                 "xdecor_television_left.png^[transformR270",
476                 "xdecor_television_left.png^[transformR90",
477                 "xdecor_television_left.png^[transformFX",
478                 "xdecor_television_left.png", "xdecor_television_back.png",
479                 { name = "xdecor_television_front_animated.png",
480                         animation = {type="vertical_frames", length=80.0} }
481         }
482 })
483
484 xpanes.register_pane("wood_frame", {
485         description = "Wood Frame",
486         tiles = {"xdecor_wood_frame.png"},
487         drawtype = "airlike",
488         paramtype = "light",
489         textures = {"xdecor_wood_frame.png", "xdecor_wood_frame.png", "xpanes_space.png"},
490         inventory_image = "xdecor_wood_frame.png",
491         wield_image = "xdecor_wood_frame.png",
492         groups = {choppy=3, oddly_breakable_by_hand=2, pane=1, flammable=3},
493         sounds = default.node_sound_wood_defaults(),
494         recipe = {
495                 {"group:wood", "group:stick", "group:wood"},
496                 {"group:stick", "group:stick", "group:stick"},
497                 {"group:wood", "group:stick", "group:wood"}
498         }
499 })
500
501 xdecor.register("woodframed_glass", {
502         description = "Wood Framed Glass",
503         drawtype = "glasslike_framed",
504         tiles = {"xdecor_woodframed_glass.png", "xdecor_woodframed_glass_detail.png"},
505         groups = {cracky=3, oddly_breakable_by_hand=2},
506         sounds = default.node_sound_glass_defaults()
507 })
508
509 xdecor.register("wood_tile", {
510         description = "Wood Tile",
511         tiles = {"xdecor_wood_tile.png"},
512         drawtype = "normal",
513         groups = {choppy=1, oddly_breakable_by_hand=1, wood=1, flammable=2},
514         sounds = default.node_sound_wood_defaults()
515 })