]> git.lizzy.rs Git - xdecor.git/blob - nodes.lua
45689a8947c24dfb7b08e86a7767884105cc22c9
[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], "%W%l", string.upper):sub(2):gsub("_", " ").." 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 for _, l in pairs({"iron", "wooden"}) do
285         xdecor.register(l.."_lightbox", {
286                 description = l:gsub("^%l", string.upper).." Light Box",
287                 tiles = {"xdecor_"..l.."_lightbox.png"},
288                 groups = {cracky=3, choppy=3, oddly_breakable_by_hand=2},
289                 light_source = 13,
290                 sounds = default.node_sound_glass_defaults()
291         })
292 end
293
294 minetest.register_alias("xdecor:lightbox", "xdecor:wooden_lightbox")
295
296 xdecor.register("packed_ice", {
297         drawtype = "normal",
298         description = "Packed Ice",
299         tiles = {"xdecor_packed_ice.png"},
300         groups = {cracky=1, puts_out_fire=1},
301         sounds = default.node_sound_glass_defaults()
302 })
303
304 local flowers = {"dandelion_white", "dandelion_yellow", "geranium", "rose",
305                 "tulip", "viola"}
306
307 for _, f in pairs(flowers) do
308         xdecor.register("potted_"..f, {
309                 description = string.gsub("Potted Flowers ("..f..")", "_", " "),
310                 walkable = false,
311                 groups = {dig_immediate=3, flammable=3, plant=1, flower=1},
312                 tiles = {"xdecor_"..f.."_pot.png"},
313                 inventory_image = "xdecor_"..f.."_pot.png",
314                 drawtype = "plantlike",
315                 sounds = default.node_sound_leaves_defaults(),
316                 selection_box = xdecor.nodebox.slab_y(0.3)
317         })
318
319         minetest.register_craft({
320                 output = "xdecor:potted_"..f,
321                 recipe = {
322                         {"default:clay_brick", "flowers:"..f, "default:clay_brick"},
323                         {"", "default:clay_brick", ""}
324                 }
325         })
326 end
327
328 xdecor.register("painting_1", {
329         description = "Painting",
330         tiles = {"xdecor_painting_1.png"},
331         inventory_image = "xdecor_painting_empty.png",
332         wield_image = "xdecor_painting_empty.png",
333         paramtype2 = "wallmounted",
334         legacy_wallmounted = true,
335         wield_image = "xdecor_painting_empty.png",
336         sunlight_propagates = true,
337         groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1},
338         sounds = default.node_sound_wood_defaults(),
339         node_box = {
340                 type = "wallmounted",
341                 wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
342                 wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
343                 wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
344         },
345         on_construct = function(pos)
346                 local node = minetest.get_node(pos)
347                 local random = math.random(4)
348                 if random == 1 then return end
349                 minetest.set_node(pos, {name="xdecor:painting_"..random, param2=node.param2})
350         end
351 })
352
353 for i = 2, 4 do
354         xdecor.register("painting_"..i, {
355                 tiles = {"xdecor_painting_"..i..".png"},
356                 paramtype2 = "wallmounted",
357                 legacy_wallmounted = true,
358                 drop = "xdecor:painting_1",
359                 sunlight_propagates = true,
360                 groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1, not_in_creative_inventory=1},
361                 sounds = default.node_sound_wood_defaults(),
362                 node_box = {
363                         type = "wallmounted",
364                         wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
365                         wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
366                         wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
367                 }
368         })
369 end
370
371 for _, b in pairs({{"cactus", "cactus"}, {"moon", "stone"}}) do
372         xdecor.register(b[1].."brick", {
373                 drawtype = "normal",
374                 description = b[1]:gsub("^%l", string.upper).." Brick",
375                 tiles = {"xdecor_"..b[1].."brick.png"},
376                 groups = {cracky=2},
377                 sounds = default.node_sound_stone_defaults(),
378         })
379         
380         minetest.register_craft({
381         output = "xdecor:"..b[1].."brick",
382         recipe = {
383                 {"default:brick", "default:"..b[2]}
384         }
385 })
386 end
387
388 xdecor.register("multishelf", {
389         description = "Multi Shelf",
390         inventory = {size=24},
391         infotext = "Multi Shelf",
392         on_rotate = screwdriver.rotate_simple,
393         tiles = {"default_wood.png", "default_wood.png^xdecor_multishelf.png"},
394         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
395         sounds = default.node_sound_wood_defaults()
396 })
397
398 xpanes.register_pane("rust_bar", {
399         description = "Rust Bars",
400         tiles = {"xdecor_rust_bars.png"},
401         drawtype = "airlike",
402         paramtype = "light",
403         textures = {"xdecor_rust_bars.png", "xdecor_rust_bars.png", "xpanes_space.png"},
404         inventory_image = "xdecor_rust_bars.png",
405         wield_image = "xdecor_rust_bars.png",
406         groups = {cracky=3, oddly_breakable_by_hand=2, pane=1},
407         recipe = {
408                 {"", "default:dirt", ""},
409                 {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
410                 {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
411         }
412 })
413
414 xdecor.register("stonepath", {
415         description = "Garden Stone Path",
416         tiles = {"default_stone.png"},
417         groups = {snappy=3},
418         on_rotate = screwdriver.rotate_simple,
419         sounds = default.node_sound_stone_defaults(),
420         sunlight_propagates = true,
421         node_box = xdecor.pixelnodebox(16, {
422                 {8,  0,  8, 6, 0.5, 6},
423                 {1,  0,  1, 6, 0.5, 6},
424                 {1,  0, 10, 5, 0.5, 5},
425                 {10, 0,  2, 4, 0.5, 4}
426         }),
427         selection_box = xdecor.nodebox.slab_y(0.05)
428 })
429
430 local stonish = {"desertstone_tile", "stone_tile", "stone_rune",
431                 "coalstone_tile", "hard_clay"}
432
433 for _, t in pairs(stonish) do
434         xdecor.register(t, {
435                 drawtype = "normal",
436                 description = string.gsub(" "..t, "%W%l", string.upper):sub(2):gsub("_", " "),
437                 tiles = {"xdecor_"..t..".png"},
438                 groups = {cracky=1},
439                 sounds = default.node_sound_stone_defaults()
440         })
441 end
442
443 xdecor.register("table", {
444         description = "Table",
445         tiles = {"xdecor_wood.png"},
446         groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
447         sounds = default.node_sound_wood_defaults(),
448         node_box = xdecor.pixelnodebox(16, {
449                 {0, 14, 0, 16, 2, 16}, {5.5, 0, 5.5, 5, 14, 6}
450         })
451 })
452
453 xdecor.register("tatami", {
454         description = "Tatami",
455         tiles = {"xdecor_tatami.png"},
456         wield_image = "xdecor_tatami.png",
457         groups = {snappy=3, flammable=3},
458         node_box = xdecor.nodebox.slab_y(0.0625)
459 })
460
461 xdecor.register("tv", {
462         description = "Television",
463         light_source = 11,
464         groups = {snappy=3},
465         on_rotate = screwdriver.rotate_simple,
466         tiles = {
467                 "xdecor_television_left.png^[transformR270",
468                 "xdecor_television_left.png^[transformR90",
469                 "xdecor_television_left.png^[transformFX",
470                 "xdecor_television_left.png", "xdecor_television_back.png",
471                 { name = "xdecor_television_front_animated.png",
472                         animation = {type="vertical_frames", length=80.0} }
473         }
474 })
475
476 xpanes.register_pane("wood_frame", {
477         description = "Wood Frame",
478         tiles = {"xdecor_wood_frame.png"},
479         drawtype = "airlike",
480         paramtype = "light",
481         textures = {"xdecor_wood_frame.png", "xdecor_wood_frame.png", "xpanes_space.png"},
482         inventory_image = "xdecor_wood_frame.png",
483         wield_image = "xdecor_wood_frame.png",
484         groups = {choppy=3, oddly_breakable_by_hand=2, pane=1, flammable=3},
485         sounds = default.node_sound_wood_defaults(),
486         recipe = {
487                 {"group:wood", "group:stick", "group:wood"},
488                 {"group:stick", "group:stick", "group:stick"},
489                 {"group:wood", "group:stick", "group:wood"}
490         }
491 })
492
493 xdecor.register("woodframed_glass", {
494         description = "Wood Framed Glass",
495         drawtype = "glasslike_framed",
496         tiles = {"xdecor_woodframed_glass.png", "xdecor_woodframed_glass_detail.png"},
497         groups = {cracky=3, oddly_breakable_by_hand=2},
498         sounds = default.node_sound_glass_defaults()
499 })
500
501 xdecor.register("wood_tile", {
502         description = "Wood Tile",
503         tiles = {"xdecor_wood_tile.png"},
504         drawtype = "normal",
505         groups = {choppy=1, oddly_breakable_by_hand=1, wood=1, flammable=2},
506         sounds = default.node_sound_wood_defaults()
507 })