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