]> git.lizzy.rs Git - xdecor.git/blob - nodes.lua
Small simplifications
[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 minetest.register_alias("xdecor:painting", "xdecor:painting_1") -- legacy code
348
349 for i = 2, 4 do
350         xdecor.register("painting_"..i, {
351                 tiles = {"xdecor_painting_"..i..".png"},
352                 paramtype2 = "wallmounted",
353                 legacy_wallmounted = true,
354                 drop = "xdecor:painting_1",
355                 sunlight_propagates = true,
356                 groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3, attached_node=1, not_in_creative_inventory=1},
357                 sounds = default.node_sound_wood_defaults(),
358                 node_box = {
359                         type = "wallmounted",
360                         wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
361                         wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
362                         wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
363                 }
364         })
365 end
366
367 for _, b in pairs({{"cactus", "cactus"}, {"moon", "stone"}}) do
368         xdecor.register(b[1].."brick", {
369                 drawtype = "normal",
370                 description = b[1]:gsub("^%l", string.upper).." Brick",
371                 tiles = {"xdecor_"..b[1].."brick.png"},
372                 groups = {cracky=2},
373                 sounds = default.node_sound_stone_defaults(),
374         })
375         
376         minetest.register_craft({
377         output = "xdecor:"..b[1].."brick",
378         recipe = {
379                 {"default:brick", "default:"..b[2]}
380         }
381 })
382 end
383
384 xdecor.register("multishelf", {
385         description = "Multi Shelf",
386         inventory = {size=24},
387         infotext = "Multi Shelf",
388         on_rotate = screwdriver.rotate_simple,
389         tiles = {"default_wood.png", "default_wood.png^xdecor_multishelf.png"},
390         groups = {choppy=2, oddly_breakable_by_hand=1, flammable=3},
391         sounds = default.node_sound_wood_defaults()
392 })
393
394 xpanes.register_pane("rust_bar", {
395         description = "Rust Bars",
396         tiles = {"xdecor_rust_bars.png"},
397         drawtype = "airlike",
398         paramtype = "light",
399         textures = {"xdecor_rust_bars.png", "xdecor_rust_bars.png", "xpanes_space.png"},
400         inventory_image = "xdecor_rust_bars.png",
401         wield_image = "xdecor_rust_bars.png",
402         groups = {cracky=3, oddly_breakable_by_hand=2, pane=1},
403         recipe = {
404                 {"", "default:dirt", ""},
405                 {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
406                 {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
407         }
408 })
409
410 xdecor.register("stonepath", {
411         description = "Garden Stone Path",
412         tiles = {"default_stone.png"},
413         groups = {snappy=3},
414         on_rotate = screwdriver.rotate_simple,
415         sounds = default.node_sound_stone_defaults(),
416         sunlight_propagates = true,
417         node_box = {
418                 type = "fixed",
419                 fixed = {{0, -0.5, 0, 0.375, -0.47, 0.375},
420                         {-0.4375, -0.5, -0.4375, -0.0625, -0.47, -0.0625},
421                         {-0.4375, -0.5, 0.125, -0.125, -0.47, 0.4375},
422                         {0.125, -0.5, -0.375, 0.375, -0.47, -0.125}}
423         },
424         selection_box = xdecor.nodebox.slab_y(0.05)
425 })
426
427 local stonish = {"desertstone_tile", "stone_tile", "stone_rune",
428                 "coalstone_tile", "hard_clay"}
429
430 for _, t in pairs(stonish) do
431         xdecor.register(t, {
432                 drawtype = "normal",
433                 description = string.gsub(" "..t, "%W%l", string.upper):sub(2):gsub("_", " "),
434                 tiles = {"xdecor_"..t..".png"},
435                 groups = {cracky=1},
436                 sounds = default.node_sound_stone_defaults()
437         })
438 end
439
440 xdecor.register("table", {
441         description = "Table",
442         tiles = {"xdecor_wood.png"},
443         groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
444         sounds = default.node_sound_wood_defaults(),
445         node_box = {
446                 type = "fixed",
447                 fixed = {{-0.5, 0.4, -0.5, 0.5, 0.5, 0.5},
448                         {-0.15, -0.5, -0.15, 0.15, 0.4, 0.15}}
449         }
450 })
451
452 xdecor.register("tatami", {
453         description = "Tatami",
454         tiles = {"xdecor_tatami.png"},
455         wield_image = "xdecor_tatami.png",
456         groups = {snappy=3, flammable=3},
457         node_box = {
458                 type = "fixed", fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}}
459         }
460 })
461
462 xdecor.register("tv", {
463         description = "Television",
464         light_source = 11,
465         groups = {snappy=3},
466         on_rotate = screwdriver.rotate_simple,
467         tiles = {
468                 "xdecor_television_left.png^[transformR270",
469                 "xdecor_television_left.png^[transformR90",
470                 "xdecor_television_left.png^[transformFX",
471                 "xdecor_television_left.png", "xdecor_television_back.png",
472                 { name = "xdecor_television_front_animated.png",
473                         animation = {type="vertical_frames", length=80.0} }
474         }
475 })
476
477 xpanes.register_pane("wood_frame", {
478         description = "Wood Frame",
479         tiles = {"xdecor_wood_frame.png"},
480         drawtype = "airlike",
481         paramtype = "light",
482         textures = {"xdecor_wood_frame.png", "xdecor_wood_frame.png", "xpanes_space.png"},
483         inventory_image = "xdecor_wood_frame.png",
484         wield_image = "xdecor_wood_frame.png",
485         groups = {choppy=3, oddly_breakable_by_hand=2, pane=1, flammable=3},
486         sounds = default.node_sound_wood_defaults(),
487         recipe = {
488                 {"group:wood", "group:stick", "group:wood"},
489                 {"group:stick", "group:stick", "group:stick"},
490                 {"group:wood", "group:stick", "group:wood"}
491         }
492 })
493
494 xdecor.register("woodframed_glass", {
495         description = "Wood Framed Glass",
496         drawtype = "glasslike_framed",
497         tiles = {"xdecor_woodframed_glass.png", "xdecor_woodframed_glass_detail.png"},
498         groups = {cracky=3, oddly_breakable_by_hand=2},
499         sounds = default.node_sound_glass_defaults()
500 })
501
502 xdecor.register("wood_tile", {
503         description = "Wood Tile",
504         tiles = {"xdecor_wood_tile.png"},
505         drawtype = "normal",
506         groups = {choppy=1, oddly_breakable_by_hand=1, wood=1, flammable=2},
507         sounds = default.node_sound_wood_defaults()
508 })