]> git.lizzy.rs Git - xdecor.git/blob - nodes.lua
5153996645e772e112a2398360de2ef9225f3363
[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 local function door_access(door)
176         return door:find("prison")
177 end
178
179 local door_types = {
180         {"japanese", "brown"}, {"prison", "grey"}, {"prison_rust", "rust"},
181         {"screen", "brownb"}, {"slide", "brownc"}, {"woodglass", "brown"}
182 }
183
184 for _, d in pairs(door_types) do
185         doors.register_door("xdecor:"..d[1].."_door", {
186                 description = string.gsub(" "..d[1], "%W%l", string.upper):sub(2):gsub("_", " ").." Door",
187                 inventory_image = "xdecor_"..d[1].."_door_inv.png",
188                 groups = {choppy=3, cracky=3, oddly_breakable_by_hand=1, flammable=2, door=1},
189                 tiles_bottom = {"xdecor_"..d[1].."_door_b.png", "xdecor_"..d[2]..".png"},
190                 tiles_top = {"xdecor_"..d[1].."_door_a.png", "xdecor_"..d[2]..".png"},
191                 only_placer_can_open = door_access(d[1]),
192                 sounds = default.node_sound_wood_defaults(),
193                 sunlight = false
194         })
195 end
196
197 xdecor.register("empty_shelf", {
198         description = "Empty Shelf",
199         inventory = {size=24},
200         infotext = "Empty Shelf",
201         tiles = {"default_wood.png", "default_wood.png^xdecor_empty_shelf.png"},
202         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
203         sounds = default.node_sound_wood_defaults(),
204         on_rotate = screwdriver.rotate_simple
205 })
206
207 xdecor.register("enderchest", {
208         description = "Ender Chest",
209         tiles = {
210                 "xdecor_enderchest_top.png", "xdecor_enderchest_top.png",
211                 "xdecor_enderchest_side.png", "xdecor_enderchest_side.png",
212                 "xdecor_enderchest_side.png", "xdecor_enderchest_front.png"
213         },
214         groups = {cracky=1, choppy=1, oddly_breakable_by_hand=1},
215         sounds = default.node_sound_stone_defaults(),
216         on_rotate = screwdriver.rotate_simple,
217         on_construct = function(pos)
218                 local meta = minetest.get_meta(pos)
219                 meta:set_string("formspec", [[ size[8,9]
220                                 list[current_player;enderchest;0,0;8,4;]
221                                 list[current_player;main;0,5;8,4;]
222                                 listring[current_player;enderchest]
223                                 listring[current_player;main] ]]
224                                 ..xbg..default.get_hotbar_bg(0,5))
225                 meta:set_string("infotext", "Ender Chest")
226         end
227 })
228
229 minetest.register_on_joinplayer(function(player)
230         local inv = player:get_inventory()
231         inv:set_size("enderchest", 8*4)
232 end)
233
234 xdecor.register("fire", {
235         description = "Fancy Fire",
236         drawtype = "plantlike",
237         light_source = 14,
238         walkable = false,
239         tiles = {
240                 { name = "xdecor_fire_anim.png",
241                 animation = {type="vertical_frames", length=1.5} }
242         },
243         damage_per_second = 4,
244         drop = "",
245         selection_box = {
246                 type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, -0.3, 0.3}
247         },
248         groups = {dig_immediate=3, hot=3, not_in_creative_inventory=1}
249 })
250
251 xdecor.register("ivy", {
252         description = "Ivy",
253         drawtype = "signlike",
254         walkable = false,
255         climbable = true,
256         groups = {dig_immediate=3, flammable=3, plant=1},
257         paramtype2 = "wallmounted",
258         selection_box = {type="wallmounted"},
259         legacy_wallmounted = true,
260         tiles = {"xdecor_ivy.png"},
261         inventory_image = "xdecor_ivy.png",
262         wield_image = "xdecor_ivy.png",
263         sounds = default.node_sound_leaves_defaults()
264 })
265
266 xdecor.register("lantern", {
267         description = "Lantern",
268         light_source = 12,
269         drawtype = "torchlike",
270         inventory_image = "xdecor_lantern_floor.png",
271         wield_image = "xdecor_lantern_floor.png", 
272         paramtype2 = "wallmounted",
273         legacy_wallmounted = true,
274         walkable = false,
275         groups = {dig_immediate=3, attached_node=1},
276         tiles = {"xdecor_lantern_floor.png", "xdecor_lantern_ceiling.png",
277                         "xdecor_lantern.png"},
278         selection_box = {
279                 type = "wallmounted",
280                 wall_top = {-0.25, -0.4, -0.25, 0.25, 0.5, 0.25},
281                 wall_bottom = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25},
282                 wall_side = {-0.5, -0.5, -0.15, 0.5, 0.5, 0.15}
283         }
284 })
285
286 for _, l in pairs({"iron", "wooden"}) do
287         xdecor.register(l.."_lightbox", {
288                 description = l:gsub("^%l", string.upper).." Light Box",
289                 tiles = {"xdecor_"..l.."_lightbox.png"},
290                 groups = {cracky=3, choppy=3, oddly_breakable_by_hand=2},
291                 light_source = 13,
292                 sounds = default.node_sound_glass_defaults()
293         })
294 end
295
296 minetest.register_alias("xdecor:lightbox", "xdecor:wooden_lightbox")
297
298 xdecor.register("packed_ice", {
299         drawtype = "normal",
300         description = "Packed Ice",
301         tiles = {"xdecor_packed_ice.png"},
302         groups = {cracky=1, puts_out_fire=1},
303         sounds = default.node_sound_glass_defaults()
304 })
305
306 local flowers = {"dandelion_white", "dandelion_yellow", "geranium", "rose",
307                 "tulip", "viola"}
308
309 for _, f in pairs(flowers) do
310         xdecor.register("potted_"..f, {
311                 description = string.gsub("Potted Flowers ("..f..")", "_", " "),
312                 walkable = false,
313                 groups = {dig_immediate=3, flammable=3, plant=1, flower=1},
314                 tiles = {"xdecor_"..f.."_pot.png"},
315                 inventory_image = "xdecor_"..f.."_pot.png",
316                 drawtype = "plantlike",
317                 sounds = default.node_sound_leaves_defaults(),
318                 selection_box = xdecor.nodebox.slab_y(0.3)
319         })
320
321         minetest.register_craft({
322                 output = "xdecor:potted_"..f,
323                 recipe = {
324                         {"default:clay_brick", "flowers:"..f, "default:clay_brick"},
325                         {"", "default:clay_brick", ""}
326                 }
327         })
328 end
329
330 xdecor.register("painting_1", {
331         description = "Painting",
332         tiles = {"xdecor_painting_1.png"},
333         inventory_image = "xdecor_painting_empty.png",
334         wield_image = "xdecor_painting_empty.png",
335         paramtype2 = "wallmounted",
336         legacy_wallmounted = true,
337         wield_image = "xdecor_painting_empty.png",
338         sunlight_propagates = true,
339         groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1},
340         sounds = default.node_sound_wood_defaults(),
341         node_box = {
342                 type = "wallmounted",
343                 wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
344                 wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
345                 wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
346         },
347         on_construct = function(pos)
348                 local node = minetest.get_node(pos)
349                 local random = math.random(4)
350                 if random == 1 then return end
351                 minetest.set_node(pos, {name="xdecor:painting_"..random, param2=node.param2})
352         end
353 })
354
355 for i = 2, 4 do
356         xdecor.register("painting_"..i, {
357                 tiles = {"xdecor_painting_"..i..".png"},
358                 paramtype2 = "wallmounted",
359                 legacy_wallmounted = true,
360                 drop = "xdecor:painting_1",
361                 sunlight_propagates = true,
362                 groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1, not_in_creative_inventory=1},
363                 sounds = default.node_sound_wood_defaults(),
364                 node_box = {
365                         type = "wallmounted",
366                         wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
367                         wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
368                         wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
369                 }
370         })
371 end
372
373 for _, b in pairs({{"cactus", "cactus"}, {"moon", "stone"}}) do
374         xdecor.register(b[1].."brick", {
375                 drawtype = "normal",
376                 description = b[1]:gsub("^%l", string.upper).." Brick",
377                 tiles = {"xdecor_"..b[1].."brick.png"},
378                 groups = {cracky=2},
379                 sounds = default.node_sound_stone_defaults(),
380         })
381         
382         minetest.register_craft({
383         output = "xdecor:"..b[1].."brick",
384         recipe = {
385                 {"default:brick", "default:"..b[2]}
386         }
387 })
388 end
389
390 xdecor.register("multishelf", {
391         description = "Multi Shelf",
392         inventory = {size=24},
393         infotext = "Multi Shelf",
394         on_rotate = screwdriver.rotate_simple,
395         tiles = {"default_wood.png", "default_wood.png^xdecor_multishelf.png"},
396         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
397         sounds = default.node_sound_wood_defaults()
398 })
399
400 xpanes.register_pane("rust_bar", {
401         description = "Rust Bars",
402         tiles = {"xdecor_rust_bars.png"},
403         drawtype = "airlike",
404         paramtype = "light",
405         textures = {"xdecor_rust_bars.png", "xdecor_rust_bars.png", "xpanes_space.png"},
406         inventory_image = "xdecor_rust_bars.png",
407         wield_image = "xdecor_rust_bars.png",
408         groups = {cracky=3, oddly_breakable_by_hand=2, pane=1},
409         recipe = {
410                 {"", "default:dirt", ""},
411                 {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
412                 {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
413         }
414 })
415
416 xdecor.register("stonepath", {
417         description = "Garden Stone Path",
418         tiles = {"default_stone.png"},
419         groups = {snappy=3},
420         on_rotate = screwdriver.rotate_simple,
421         sounds = default.node_sound_stone_defaults(),
422         sunlight_propagates = true,
423         node_box = xdecor.pixelnodebox(16, {
424                 {8,  0,  8, 6, 0.5, 6},
425                 {1,  0,  1, 6, 0.5, 6},
426                 {1,  0, 10, 5, 0.5, 5},
427                 {10, 0,  2, 4, 0.5, 4}
428         }),
429         selection_box = xdecor.nodebox.slab_y(0.05)
430 })
431
432 local stonish = {"desertstone_tile", "stone_tile", "stone_rune",
433                 "coalstone_tile", "hard_clay"}
434
435 for _, t in pairs(stonish) do
436         xdecor.register(t, {
437                 drawtype = "normal",
438                 description = string.gsub(" "..t, "%W%l", string.upper):sub(2):gsub("_", " "),
439                 tiles = {"xdecor_"..t..".png"},
440                 groups = {cracky=1},
441                 sounds = default.node_sound_stone_defaults()
442         })
443 end
444
445 xdecor.register("table", {
446         description = "Table",
447         tiles = {"xdecor_wood.png"},
448         groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
449         sounds = default.node_sound_wood_defaults(),
450         node_box = xdecor.pixelnodebox(16, {
451                 {0, 14, 0, 16, 2, 16}, {5.5, 0, 5.5, 5, 14, 6}
452         })
453 })
454
455 xdecor.register("tatami", {
456         description = "Tatami",
457         tiles = {"xdecor_tatami.png"},
458         wield_image = "xdecor_tatami.png",
459         groups = {snappy=3, flammable=3},
460         node_box = xdecor.nodebox.slab_y(0.0625)
461 })
462
463 xdecor.register("tv", {
464         description = "Television",
465         light_source = 11,
466         groups = {snappy=3},
467         on_rotate = screwdriver.rotate_simple,
468         tiles = {
469                 "xdecor_television_left.png^[transformR270",
470                 "xdecor_television_left.png^[transformR90",
471                 "xdecor_television_left.png^[transformFX",
472                 "xdecor_television_left.png", "xdecor_television_back.png",
473                 { name = "xdecor_television_front_animated.png",
474                         animation = {type="vertical_frames", length=80.0} }
475         }
476 })
477
478 xpanes.register_pane("wood_frame", {
479         description = "Wood Frame",
480         tiles = {"xdecor_wood_frame.png"},
481         drawtype = "airlike",
482         paramtype = "light",
483         textures = {"xdecor_wood_frame.png", "xdecor_wood_frame.png", "xpanes_space.png"},
484         inventory_image = "xdecor_wood_frame.png",
485         wield_image = "xdecor_wood_frame.png",
486         groups = {choppy=3, oddly_breakable_by_hand=2, pane=1, flammable=3},
487         sounds = default.node_sound_wood_defaults(),
488         recipe = {
489                 {"group:wood", "group:stick", "group:wood"},
490                 {"group:stick", "group:stick", "group:stick"},
491                 {"group:wood", "group:stick", "group:wood"}
492         }
493 })
494
495 xdecor.register("woodframed_glass", {
496         description = "Wood Framed Glass",
497         drawtype = "glasslike_framed",
498         tiles = {"xdecor_woodframed_glass.png", "xdecor_woodframed_glass_detail.png"},
499         groups = {cracky=3, oddly_breakable_by_hand=2},
500         sounds = default.node_sound_glass_defaults()
501 })
502
503 xdecor.register("wood_tile", {
504         description = "Wood Tile",
505         tiles = {"xdecor_wood_tile.png"},
506         drawtype = "normal",
507         groups = {choppy=1, oddly_breakable_by_hand=1, wood=1, flammable=2},
508         sounds = default.node_sound_wood_defaults()
509 })