init.lua 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. -- Home Decor mod by VanessaE
  2. --
  3. -- Mostly my own code, with bits and pieces lifted from Minetest's default
  4. -- lua files and from ironzorg's flowers mod. Many thanks to GloopMaster
  5. -- for helping me figure out the inventories used in the nightstands/dressers.
  6. --
  7. -- The code for ovens, nightstands, refrigerators are basically modified
  8. -- copies of the code for chests and furnaces.
  9. local S = minetest.get_translator("homedecor_misc")
  10. homedecor_misc = {}
  11. homedecor.register("ceiling_paint", {
  12. description = S("Textured Ceiling Paint"),
  13. drawtype = 'signlike',
  14. tiles = { 'homedecor_ceiling_paint.png' },
  15. inventory_image = 'homedecor_ceiling_paint_roller.png',
  16. wield_image = 'homedecor_ceiling_paint_roller.png',
  17. walkable = false,
  18. groups = { snappy = 3 },
  19. sounds = default.node_sound_leaves_defaults(),
  20. selection_box = { type = "wallmounted" },
  21. })
  22. homedecor.register("ceiling_tile", {
  23. description = S("Drop-Ceiling Tile"),
  24. drawtype = 'signlike',
  25. tiles = { 'homedecor_ceiling_tile.png' },
  26. wield_image = 'homedecor_ceiling_tile.png',
  27. inventory_image = 'homedecor_ceiling_tile.png',
  28. walkable = false,
  29. groups = { snappy = 3 },
  30. sounds = default.node_sound_leaves_defaults(),
  31. selection_box = { type = "wallmounted" },
  32. })
  33. local rug_types = {
  34. { "small", "homedecor_small_rug.obj" },
  35. { "large", homedecor.box.slab_y(0.0625) },
  36. { "persian", homedecor.box.slab_y(0.0625) },
  37. }
  38. for _, rt in ipairs(rug_types) do
  39. local s, m = unpack(rt)
  40. local mesh = m
  41. local nodebox = nil
  42. local tiles = { "homedecor_rug_"..s..".png", "wool_grey.png" }
  43. if type(m) == "table" then
  44. mesh = nil
  45. nodebox = {
  46. type = "fixed",
  47. fixed = m
  48. }
  49. tiles = {
  50. "homedecor_rug_"..s..".png",
  51. "wool_grey.png",
  52. "homedecor_rug_"..s..".png"
  53. }
  54. end
  55. homedecor.register("rug_"..s, {
  56. description = S("Rug (@1)", S(s)),
  57. mesh = mesh,
  58. tiles = tiles,
  59. node_box = nodebox,
  60. paramtype2 = "wallmounted",
  61. walkable = false,
  62. groups = {snappy = 3},
  63. sounds = default.node_sound_leaves_defaults(),
  64. selection_box = { type = "wallmounted" },
  65. })
  66. end
  67. local pot_colors = { "black", "green", "terracotta" }
  68. for _, p in ipairs(pot_colors) do
  69. homedecor.register("flower_pot_"..p, {
  70. description = S("Flower Pot (@1)", S(p)),
  71. mesh = "homedecor_flowerpot.obj",
  72. tiles = {
  73. "homedecor_flower_pot_"..p..".png",
  74. { name = "default_dirt.png", color = 0xff505050 },
  75. },
  76. groups = { snappy = 3, potting_soil=1 },
  77. sounds = default.node_sound_stone_defaults(),
  78. })
  79. end
  80. local flowers_list = {
  81. { S("Rose"), "rose", "flowers:rose" },
  82. { S("Tulip"), "tulip", "flowers:tulip" },
  83. { S("Yellow Dandelion"), "dandelion_yellow", "flowers:dandelion_yellow" },
  84. { S("White Dandelion"), "dandelion_white", "flowers:dandelion_white" },
  85. { S("Blue Geranium"), "geranium", "flowers:geranium" },
  86. { S("Viola"), "viola", "flowers:viola" },
  87. { S("Cactus"), "cactus", "default:cactus" },
  88. { S("Bonsai"), "bonsai", "default:sapling" }
  89. }
  90. for _, f in ipairs(flowers_list) do
  91. local flowerdesc, flower, craftwith = unpack(f)
  92. homedecor.register("potted_"..flower, {
  93. description = S("Potted flower (@1)", flowerdesc),
  94. mesh = "homedecor_potted_plant.obj",
  95. tiles = {
  96. "homedecor_flower_pot_terracotta.png",
  97. { name = "default_dirt.png", color = 0xff303030 },
  98. "flowers_"..flower..".png"
  99. },
  100. walkable = false,
  101. groups = {snappy = 3},
  102. sounds = default.node_sound_glass_defaults(),
  103. selection_box = {
  104. type = "fixed",
  105. fixed = { -0.2, -0.5, -0.2, 0.2, 0.3, 0.2 }
  106. }
  107. })
  108. minetest.register_craft({
  109. type = "shapeless",
  110. output = "homedecor:potted_"..flower,
  111. recipe = { craftwith, "homedecor:flower_pot_small" }
  112. })
  113. minetest.register_alias("flowers:flower_"..flower.."_pot", "homedecor:potted_"..flower)
  114. minetest.register_alias("flowers:potted_"..flower, "homedecor:potted_"..flower)
  115. minetest.register_alias("flowers:flower_pot", "homedecor:flower_pot_small")
  116. end
  117. homedecor.register("pole_brass", {
  118. description = S("Brass Pole"),
  119. mesh = "homedecor_round_pole.obj",
  120. tiles = {"homedecor_generic_metal_brass.png^homedecor_generic_metal_lines_overlay.png",},
  121. inventory_image = "homedecor_pole_brass_inv.png",
  122. wield_image = "homedecor_pole_brass_inv.png",
  123. selection_box = {
  124. type = "fixed",
  125. fixed = { -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 },
  126. },
  127. collision_box = {
  128. type = "fixed",
  129. fixed = { -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 },
  130. },
  131. groups = {snappy=3},
  132. sounds = default.node_sound_wood_defaults(),
  133. check_for_pole = true
  134. })
  135. homedecor.register("pole_wrought_iron", {
  136. description = S("Wrought Iron Pole"),
  137. tiles = { "homedecor_generic_metal_wrought_iron.png^homedecor_generic_metal_lines_overlay.png" },
  138. inventory_image = "homedecor_pole_wrought_iron_inv.png",
  139. wield_image = "homedecor_pole_wrought_iron_inv.png",
  140. selection_box = {
  141. type = "fixed",
  142. fixed = {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625}
  143. },
  144. node_box = {
  145. type = "fixed",
  146. fixed = {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625}
  147. },
  148. groups = {snappy=3},
  149. sounds = default.node_sound_wood_defaults(),
  150. })
  151. local ft_cbox = {
  152. type = "fixed",
  153. fixed = { -0.5, -0.5, -0.375, 0.5, 0.3125, 0.375 }
  154. }
  155. homedecor.register("fishtank", {
  156. description = S("Fishtank"),
  157. mesh = "homedecor_fishtank.obj",
  158. tiles = {
  159. { name = "homedecor_generic_plastic.png", color = homedecor.color_black },
  160. "homedecor_fishtank_filter.png",
  161. "homedecor_fishtank_fishes.png",
  162. "homedecor_fishtank_gravel.png",
  163. "homedecor_fishtank_water_top.png",
  164. "homedecor_fishtank_sides.png",
  165. },
  166. use_texture_alpha = true,
  167. selection_box = ft_cbox,
  168. collision_box = ft_cbox,
  169. groups = {cracky=3,oddly_breakable_by_hand=3},
  170. sounds = default.node_sound_glass_defaults(),
  171. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  172. minetest.set_node(pos, {name = "homedecor:fishtank_lighted", param2 = node.param2})
  173. return itemstack
  174. end
  175. })
  176. homedecor.register("fishtank_lighted", {
  177. description = S("Fishtank (lighted)"),
  178. mesh = "homedecor_fishtank.obj",
  179. tiles = {
  180. { name = "homedecor_generic_plastic.png", color = homedecor.color_black },
  181. "homedecor_fishtank_filter.png",
  182. "homedecor_fishtank_fishes_lighted.png",
  183. "homedecor_fishtank_gravel_lighted.png",
  184. "homedecor_fishtank_water_top_lighted.png",
  185. "homedecor_fishtank_sides_lighted.png",
  186. },
  187. light_source = default.LIGHT_MAX-4,
  188. use_texture_alpha = true,
  189. selection_box = ft_cbox,
  190. collision_box = ft_cbox,
  191. groups = {cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
  192. sounds = default.node_sound_glass_defaults(),
  193. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  194. minetest.set_node(pos, {name = "homedecor:fishtank", param2 = node.param2})
  195. return itemstack
  196. end,
  197. drop = "homedecor:fishtank",
  198. })
  199. homedecor.register("cardboard_box_big", {
  200. description = S("Cardboard box (big)"),
  201. tiles = {
  202. 'homedecor_cardbox_big_tb.png',
  203. 'homedecor_cardbox_big_tb.png',
  204. 'homedecor_cardbox_big_sides.png',
  205. },
  206. groups = { snappy = 3 },
  207. infotext=S("Cardboard box"),
  208. inventory = {
  209. size=24,
  210. },
  211. })
  212. homedecor.register("cardboard_box", {
  213. description = S("Cardboard box"),
  214. tiles = {
  215. 'homedecor_cardbox_tb.png',
  216. 'homedecor_cardbox_tb.png',
  217. 'homedecor_cardbox_sides.png',
  218. },
  219. node_box = {
  220. type = "fixed",
  221. fixed = {
  222. {-0.3125, -0.5, -0.3125, 0.3125, 0, 0.3125},
  223. }
  224. },
  225. groups = { snappy = 3 },
  226. infotext=S("Cardboard box"),
  227. inventory = {
  228. size=8,
  229. },
  230. })
  231. homedecor.register("dvd_cd_cabinet", {
  232. description = S("DVD/CD cabinet"),
  233. mesh = "homedecor_dvd_cabinet.obj",
  234. tiles = {
  235. "default_wood.png",
  236. "homedecor_dvdcd_cabinet_front.png",
  237. "homedecor_dvdcd_cabinet_back.png"
  238. },
  239. selection_box = homedecor.nodebox.slab_z(-0.5),
  240. groups = {choppy=2,oddly_breakable_by_hand=2},
  241. sounds = default.node_sound_wood_defaults(),
  242. })
  243. local pooltable_cbox = {
  244. type = "fixed",
  245. fixed = { -0.5, -0.5, -0.5, 0.5, 0.3125, 1.5 }
  246. }
  247. homedecor.register("pool_table", {
  248. mesh = "homedecor_pool_table.obj",
  249. tiles = {
  250. "homedecor_pool_table_cue.png",
  251. "homedecor_pool_table_baize.png",
  252. "homedecor_pool_table_pockets.png",
  253. "homedecor_pool_table_balls.png",
  254. homedecor.lux_wood,
  255. },
  256. description = S("Pool Table"),
  257. inventory_image = "homedecor_pool_table_inv.png",
  258. groups = {snappy=3},
  259. selection_box = pooltable_cbox,
  260. collision_box = pooltable_cbox,
  261. expand = { forward="placeholder" },
  262. sounds = default.node_sound_wood_defaults(),
  263. on_rotate = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil,
  264. })
  265. minetest.register_alias("homedecor:pool_table_2", "air")
  266. local piano_cbox = {
  267. type = "fixed",
  268. fixed = { -0.5, -0.5, -0.125, 1.5, 0.5, 0.5 }
  269. }
  270. homedecor.register("piano", {
  271. mesh = "homedecor_piano.obj",
  272. tiles = {
  273. { name = "homedecor_generic_wood_luxury.png", color = homedecor.color_black },
  274. "homedecor_piano_keys.png",
  275. "homedecor_generic_metal_brass.png",
  276. },
  277. inventory_image = "homedecor_piano_inv.png",
  278. description = S("Piano"),
  279. groups = { snappy = 3 },
  280. selection_box = piano_cbox,
  281. collision_box = piano_cbox,
  282. expand = { right="placeholder" },
  283. sounds = default.node_sound_wood_defaults(),
  284. on_rotate = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil,
  285. })
  286. minetest.register_alias("homedecor:piano_left", "homedecor:piano")
  287. minetest.register_alias("homedecor:piano_right", "air")
  288. local tr_cbox = {
  289. type = "fixed",
  290. fixed = { -0.3125, -0.5, -0.1875, 0.3125, 0.125, 0.1875 }
  291. }
  292. homedecor.register("trophy", {
  293. description = S("Trophy"),
  294. mesh = "homedecor_trophy.obj",
  295. tiles = {
  296. "default_wood.png",
  297. "homedecor_generic_metal_gold.png"
  298. },
  299. inventory_image = "homedecor_trophy_inv.png",
  300. groups = { snappy=3 },
  301. walkable = false,
  302. selection_box = tr_cbox,
  303. })
  304. local sb_cbox = {
  305. type = "fixed",
  306. fixed = { -0.4, -0.5, -0.5, 0.4, 0.375, 0.5 }
  307. }
  308. homedecor.register("sportbench", {
  309. description = S("Sport bench"),
  310. mesh = "homedecor_sport_bench.obj",
  311. tiles = {
  312. "homedecor_generic_metal_wrought_iron.png",
  313. "homedecor_generic_metal_bright.png",
  314. { name = "homedecor_generic_metal.png", color = homedecor.color_black },
  315. "wool_black.png"
  316. },
  317. inventory_image = "homedecor_sport_bench_inv.png",
  318. groups = { snappy=3 },
  319. selection_box = sb_cbox,
  320. walkable = false,
  321. sounds = default.node_sound_wood_defaults(),
  322. })
  323. local skate_cbox = {
  324. type = "fixed",
  325. fixed = { -0.5, -0.5, -0.15, 0.5, -0.3, 0.15 }
  326. }
  327. homedecor.register("skateboard", {
  328. drawtype = "mesh",
  329. mesh = "homedecor_skateboard.obj",
  330. tiles = { "homedecor_skateboard.png" },
  331. inventory_image = "homedecor_skateboard_inv.png",
  332. description = S("Skateboard"),
  333. groups = {snappy=3},
  334. selection_box = skate_cbox,
  335. walkable = false,
  336. sounds = default.node_sound_wood_defaults(),
  337. on_place = minetest.rotate_node
  338. })
  339. homedecor.register("tool_cabinet", {
  340. description = S("Metal tool cabinet and work table"),
  341. mesh = "homedecor_tool_cabinet.obj",
  342. tiles = {
  343. { name = "homedecor_generic_metal.png", color = 0xffd00000 },
  344. "homedecor_tool_cabinet_drawers.png",
  345. { name = "homedecor_generic_metal.png", color = 0xff006000 },
  346. { name = "homedecor_generic_metal.png", color = homedecor.color_med_grey },
  347. "homedecor_generic_metal_bright.png",
  348. "homedecor_tool_cabinet_misc.png",
  349. },
  350. inventory_image = "homedecor_tool_cabinet_inv.png",
  351. on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple or nil,
  352. groups = { snappy=3 },
  353. selection_box = homedecor.nodebox.slab_y(2),
  354. expand = { top="placeholder" },
  355. inventory = {
  356. size=24,
  357. }
  358. })
  359. minetest.register_alias("homedecor:tool_cabinet_bottom", "homedecor:tool_cabinet")
  360. minetest.register_alias("homedecor:tool_cabinet_top", "air")
  361. homedecor_misc.banister_materials = {
  362. {
  363. "wood",
  364. S("wood"),
  365. "default_wood.png",
  366. "default_wood.png",
  367. "group:wood",
  368. "group:stick",
  369. "",
  370. ""
  371. },
  372. {
  373. "white_dark",
  374. S("dark topped"),
  375. homedecor.white_wood,
  376. homedecor.dark_wood,
  377. "group:wood",
  378. "group:stick",
  379. "dye:brown",
  380. "dye:white"
  381. },
  382. {
  383. "brass",
  384. S("brass"),
  385. homedecor.white_wood,
  386. "homedecor_generic_metal_brass.png",
  387. "technic:brass_ingot",
  388. "group:stick",
  389. "",
  390. "dye:white"
  391. },
  392. {
  393. "wrought_iron",
  394. S("wrought iron"),
  395. "homedecor_generic_metal_wrought_iron.png",
  396. "homedecor_generic_metal_wrought_iron.png",
  397. "homedecor:pole_wrought_iron",
  398. "homedecor:pole_wrought_iron",
  399. "",
  400. ""
  401. }
  402. }
  403. for _, side in ipairs({"diagonal_left", "diagonal_right", "horizontal"}) do
  404. local sidedesc = side:match("^diagonal") and S("diagonal") or S("horizontal")
  405. for _, mat in ipairs(homedecor_misc.banister_materials) do
  406. local name, matdesc, tile1, tile2 = unpack(mat)
  407. local nodename = "banister_"..name.."_"..side
  408. local cbox = {
  409. type = "fixed",
  410. fixed = { -9/16, -3/16, 5/16, 9/16, 24/16, 8/16 }
  411. }
  412. if side == "horizontal" then
  413. cbox = {
  414. type = "fixed",
  415. fixed = { -8/16, -8/16, 5/16, 8/16, 8/16, 8/16 }
  416. }
  417. end
  418. local def = {
  419. description = S("Banister for Stairs (@1, @2)", matdesc, sidedesc),
  420. mesh = "homedecor_banister_"..side..".obj",
  421. tiles = {
  422. tile1,
  423. tile2,
  424. },
  425. inventory_image = "homedecor_banister_"..name.."_inv.png",
  426. selection_box = cbox,
  427. collision_box = cbox,
  428. groups = { snappy = 3},
  429. on_place = homedecor.place_banister,
  430. drop = "homedecor:banister_"..name.."_horizontal",
  431. }
  432. if side ~= "horizontal" then
  433. def.groups.not_in_creative_inventory = 1
  434. end
  435. if name == "wood" then
  436. def.palette = "unifieddyes_palette_greys.png"
  437. def.airbrush_replacement_node = "homedecor:banister_wood_"..side.."_grey"
  438. def.groups.ud_param2_colorable = 1
  439. def.paramtype2 = "colorfacedir"
  440. def.on_dig = unifieddyes.on_dig
  441. end
  442. homedecor.register(nodename, def)
  443. if name == "wood" then
  444. local nn = "homedecor:"..nodename
  445. local def2 = table.copy(minetest.registered_items[nn])
  446. def2.tiles = {
  447. homedecor.white_wood,
  448. homedecor.white_wood
  449. }
  450. def2.inventory_image = "homedecor_banister_wood_colored_inv.png"
  451. def2.groups.not_in_creative_inventory = 1
  452. unifieddyes.generate_split_palette_nodes(nn, def2, "homedecor:banister_"..name.."_horizontal")
  453. end
  454. end
  455. end
  456. homedecor.register("spiral_staircase", {
  457. description = "Spiral Staircase",
  458. mesh = "homedecor_spiral_staircase.obj",
  459. wield_scale = { x=0.4, y=0.4, z=0.4 },
  460. tiles = {
  461. "homedecor_generic_metal_wrought_iron.png",
  462. },
  463. selection_box = {
  464. type = "fixed",
  465. fixed = { -1.5, -0.5, -1.5, 0.5, 2.5, 0.5 }
  466. },
  467. node_box = {
  468. type = "fixed",
  469. fixed = {
  470. {-0.5625, -0.5, -0.5625, -0.4375, 2.5, -0.4375}, -- NodeBox9
  471. {-0.5, -0.5, -0.5, 0.5, -0.4375, 0}, -- NodeBox14
  472. {-0.5, -0.125, -0.5, -0.25, -0.0625, 0.5}, -- NodeBox15
  473. {-0.25, -0.125, -0.0625, 0, -0.0625, 0.5}, -- NodeBox16
  474. {-1, 0.25, -0.5, -0.5, 0.3125, 0.5}, -- NodeBox17
  475. {-1.5, 0.625, -0.5, -0.5, 0.6875, -0.25}, -- NodeBox18
  476. {-1.5, 0.625, -0.25, -0.9375, 0.6875, 0}, -- NodeBox19
  477. {-1.5, 1, -1, -0.5, 1.0625, -0.5}, -- NodeBox20
  478. {-0.75, 1.375, -1.5, -0.5, 1.4375, -0.5}, -- NodeBox21
  479. {-1, 1.375, -1.5, -0.75, 1.4375, -1}, -- NodeBox22
  480. {-0.5, 1.75, -1.5, 0.0625, 1.8125, -0.5}, -- NodeBox23
  481. {-0.5, 2.125, -0.8125, 0.5, 2.1875, -0.5}, -- NodeBox24
  482. {-0.0625, 2.125, -1.0625, 0.5, 2.1875, -0.75}, -- NodeBox25
  483. {-1.5, -0.125, 0.4375, 0.5, 1.625, 0.5}, -- NodeBox26
  484. {-1.5, 1.5625, -1.5, -1.4375, 2.875, 0.5}, -- NodeBox27
  485. {-1.5, 1.75, -1.5, 0.5, 3.3125, -1.4375}, -- NodeBox28
  486. {0.4375, -0.5, -0.5, 0.5, 0.875, 0.5}, -- NodeBox29
  487. {0.4375, 2.125, -1.5, 0.5, 3.3125, 0.5}, -- NodeBox30
  488. }
  489. },
  490. groups = {cracky = 1},
  491. sounds = default.node_sound_wood_defaults(),
  492. on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple or nil,
  493. after_place_node = function(pos, placer, itemstack, pointed_thing)
  494. local fdir = minetest.dir_to_facedir(placer:get_look_dir())
  495. local leftx = homedecor.fdir_to_left[fdir+1][1]
  496. local leftz = homedecor.fdir_to_left[fdir+1][2]
  497. local revx = -homedecor.fdir_to_fwd[fdir+1][1]
  498. local revz = -homedecor.fdir_to_fwd[fdir+1][2]
  499. local corner1 = { x = pos.x + leftx + revx, y = pos.y, z = pos.z + leftz + revz}
  500. local corner2 = { x = pos.x, y = pos.y + 2, z = pos.z }
  501. local minp = { x = math.min(corner1.x, corner2.x),
  502. y = math.min(corner1.y, corner2.y),
  503. z = math.min(corner1.z, corner2.z) }
  504. local maxp = { x = math.max(corner1.x, corner2.x),
  505. y = math.max(corner1.y, corner2.y),
  506. z = math.max(corner1.z, corner2.z) }
  507. if #minetest.find_nodes_in_area(minp, maxp, "air") < 11 then
  508. minetest.set_node(pos, {name = "air"})
  509. minetest.chat_send_player(placer:get_player_name(), S("not enough space"))
  510. return true
  511. end
  512. local belownode = minetest.get_node({ x = pos.x, y = pos.y - 1, z = pos.z })
  513. if belownode and belownode.name == "homedecor:spiral_staircase" then
  514. local newpos = { x = pos.x, y = pos.y + 2, z = pos.z }
  515. minetest.set_node(pos, { name = "air" })
  516. minetest.set_node(newpos, { name = "homedecor:spiral_staircase", param2 = belownode.param2 })
  517. end
  518. end
  519. })
  520. minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
  521. local belownode = minetest.get_node({ x = pos.x, y = pos.y - 1, z = pos.z })
  522. if newnode.name ~= "homedecor:spiral_staircase"
  523. and belownode
  524. and belownode.name == "homedecor:spiral_staircase" then
  525. minetest.set_node(pos, { name = "air" })
  526. local newpos = { x = pos.x, y = pos.y + 2, z = pos.z }
  527. local checknode = minetest.get_node(newpos)
  528. if checknode and checknode.name == "air" then
  529. local fdir = minetest.dir_to_facedir(placer:get_look_dir())
  530. minetest.set_node(newpos, { name = newnode.name, param2 = fdir })
  531. else
  532. return true
  533. end
  534. end
  535. end)
  536. minetest.register_node(":homedecor:tatami_mat", {
  537. tiles = {
  538. "homedecor_tatami.png",
  539. "homedecor_tatami.png",
  540. "homedecor_tatami.png",
  541. "homedecor_tatami.png",
  542. "homedecor_tatami.png",
  543. "homedecor_tatami.png"
  544. },
  545. description = S("Japanese tatami"),
  546. drawtype = "nodebox",
  547. paramtype = "light",
  548. groups = {snappy=3},
  549. node_box = {
  550. type = "fixed",
  551. fixed = {
  552. {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
  553. }
  554. }
  555. })
  556. homedecor.register("dartboard", {
  557. description = S("Dartboard"),
  558. mesh = "homedecor_dartboard.obj",
  559. tiles = { "homedecor_dartboard.png" },
  560. inventory_image = "homedecor_dartboard_inv.png",
  561. wield_image = "homedecor_dartboard_inv.png",
  562. paramtype2 = "wallmounted",
  563. walkable = false,
  564. selection_box = {
  565. type = "wallmounted",
  566. },
  567. groups = {choppy=2,dig_immediate=2,attached_node=1},
  568. legacy_wallmounted = true,
  569. sounds = default.node_sound_wood_defaults(),
  570. })
  571. -- crafting
  572. -- Crafting for homedecor mod (includes folding) by Vanessa Ezekowitz
  573. --
  574. -- Mostly my own code; overall template borrowed from game default
  575. minetest.register_craft( {
  576. output = "homedecor:flower_pot_terracotta",
  577. recipe = {
  578. { "homedecor:roof_tile_terracotta", "default:dirt", "homedecor:roof_tile_terracotta" },
  579. { "homedecor:roof_tile_terracotta", "homedecor:roof_tile_terracotta", "homedecor:roof_tile_terracotta" },
  580. },
  581. })
  582. minetest.register_craft( {
  583. output = "homedecor:flower_pot_green",
  584. recipe = {
  585. { "", "dye:dark_green", "" },
  586. { "basic_materials:plastic_sheet", "default:dirt", "basic_materials:plastic_sheet" },
  587. { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
  588. },
  589. })
  590. minetest.register_craft( {
  591. output = "homedecor:flower_pot_black",
  592. recipe = {
  593. { "dye:black", "dye:black", "dye:black" },
  594. { "basic_materials:plastic_sheet", "default:dirt", "basic_materials:plastic_sheet" },
  595. { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
  596. },
  597. })
  598. minetest.register_craft( {
  599. type = "shapeless",
  600. output = "homedecor:ceiling_paint 20",
  601. recipe = {
  602. "dye:white",
  603. "dye:white",
  604. "default:sand",
  605. "bucket:bucket_water",
  606. },
  607. replacements = { { "bucket:bucket_water","bucket:bucket_empty" } }
  608. })
  609. minetest.register_craft( {
  610. output = "homedecor:ceiling_tile 10",
  611. recipe = {
  612. { "", "dye:white", "" },
  613. { "default:steel_ingot", "default:stone", "default:steel_ingot" },
  614. },
  615. })
  616. minetest.register_craft( {
  617. output = "homedecor:drawer_small",
  618. recipe = {
  619. { "group:wood", "default:steel_ingot", "group:wood" },
  620. },
  621. })
  622. minetest.register_craft({
  623. type = "fuel",
  624. recipe = "homedecor:drawer_small",
  625. burntime = 30,
  626. })
  627. -- vertical poles/lampposts
  628. minetest.register_craft( {
  629. output = "homedecor:pole_brass 4",
  630. recipe = {
  631. { "", "basic_materials:brass_ingot", "" },
  632. { "", "basic_materials:brass_ingot", "" },
  633. { "", "basic_materials:brass_ingot", "" }
  634. },
  635. })
  636. minetest.register_craft( {
  637. output = "homedecor:pole_wrought_iron 4",
  638. recipe = {
  639. { "default:iron_lump", },
  640. { "default:iron_lump", },
  641. { "default:iron_lump", },
  642. },
  643. })
  644. -- ===========================================================
  645. -- Recipes that require materials from wool (cotton alternate)
  646. minetest.register_craft( {
  647. type = "shapeless",
  648. output = "homedecor:rug_small 8",
  649. recipe = {
  650. "wool:red",
  651. "wool:yellow",
  652. "wool:blue",
  653. "wool:black"
  654. },
  655. })
  656. minetest.register_craft( {
  657. output = "homedecor:rug_persian 8",
  658. recipe = {
  659. { "", "wool:yellow", "" },
  660. { "wool:red", "wool:blue", "wool:red" },
  661. { "", "wool:yellow", "" }
  662. },
  663. })
  664. -- cotton versions:
  665. minetest.register_craft( {
  666. type = "shapeless",
  667. output = "homedecor:rug_small 8",
  668. recipe = {
  669. "cotton:red",
  670. "cotton:yellow",
  671. "cotton:blue",
  672. "cotton:black"
  673. },
  674. })
  675. minetest.register_craft( {
  676. output = "homedecor:rug_persian 8",
  677. recipe = {
  678. { "", "cotton:yellow", "" },
  679. { "cotton:red", "cotton:blue", "cotton:red" },
  680. { "", "cotton:yellow", "" }
  681. },
  682. })
  683. -- fuel recipes for same
  684. minetest.register_craft({
  685. type = "fuel",
  686. recipe = "homedecor:rug_small",
  687. burntime = 30,
  688. })
  689. minetest.register_craft( {
  690. type = "shapeless",
  691. output = "homedecor:rug_large 2",
  692. recipe = {
  693. "homedecor:rug_small",
  694. "homedecor:rug_small",
  695. },
  696. })
  697. minetest.register_craft({
  698. type = "fuel",
  699. recipe = "homedecor:rug_large",
  700. burntime = 30,
  701. })
  702. minetest.register_craft({
  703. type = "fuel",
  704. recipe = "homedecor:rug_persian",
  705. burntime = 30,
  706. })
  707. -- more misc stuff here
  708. minetest.register_craft({
  709. output = "homedecor:fishtank",
  710. recipe = {
  711. { "basic_materials:plastic_sheet", "homedecor:glowlight_small_cube", "basic_materials:plastic_sheet" },
  712. { "default:glass", "bucket:bucket_water", "default:glass" },
  713. { "default:glass", "building_blocks:gravel_spread", "default:glass" },
  714. },
  715. replacements = { {"bucket:bucket_water", "bucket:bucket_empty"} }
  716. })
  717. minetest.register_craft({
  718. output = "homedecor:cardboard_box 2",
  719. recipe = {
  720. { "default:paper", "", "default:paper" },
  721. { "default:paper", "default:paper", "default:paper" },
  722. },
  723. })
  724. minetest.register_craft({
  725. output = "homedecor:cardboard_box_big 2",
  726. recipe = {
  727. { "default:paper", "", "default:paper" },
  728. { "default:paper", "", "default:paper" },
  729. { "default:paper", "default:paper", "default:paper" },
  730. },
  731. })
  732. minetest.register_craft( {
  733. output = "homedecor:openframe_bookshelf",
  734. recipe = {
  735. {"group:wood", "", "group:wood"},
  736. {"default:book", "default:book", "default:book"},
  737. {"group:wood", "", "group:wood"},
  738. },
  739. })
  740. -- japanese walls and mat
  741. minetest.register_craft( {
  742. output = "homedecor:japanese_wall_top",
  743. recipe = {
  744. {"group:stick", "default:paper"},
  745. {"default:paper", "group:stick"},
  746. {"group:stick", "default:paper"}
  747. },
  748. })
  749. minetest.register_craft( {
  750. output = "homedecor:japanese_wall_top",
  751. recipe = {
  752. {"default:paper", "group:stick"},
  753. {"group:stick", "default:paper"},
  754. {"default:paper", "group:stick"}
  755. },
  756. })
  757. minetest.register_craft( {
  758. output = "homedecor:japanese_wall_middle",
  759. recipe = {
  760. {"homedecor:japanese_wall_top"}
  761. },
  762. })
  763. minetest.register_craft( {
  764. output = "homedecor:japanese_wall_bottom",
  765. recipe = {
  766. {"homedecor:japanese_wall_middle"}
  767. },
  768. })
  769. minetest.register_craft( {
  770. output = "homedecor:japanese_wall_top",
  771. recipe = {
  772. {"homedecor:japanese_wall_bottom"}
  773. },
  774. })
  775. minetest.register_craft( {
  776. output = "homedecor:tatami_mat",
  777. recipe = {
  778. {"farming:wheat", "farming:wheat", "farming:wheat"}
  779. },
  780. })
  781. minetest.register_craft( {
  782. output = "homedecor:pool_table",
  783. recipe = {
  784. { "wool:dark_green", "wool:dark_green", "wool:dark_green" },
  785. { "building_blocks:hardwood", "building_blocks:hardwood", "building_blocks:hardwood" },
  786. { "building_blocks:slab_hardwood", "", "building_blocks:slab_hardwood" }
  787. },
  788. })
  789. minetest.register_craft({
  790. output = "homedecor:dartboard",
  791. recipe = {
  792. {"dye:black", "basic_materials:plastic_sheet", "dye:white"},
  793. {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"},
  794. {"dye:dark_green", "basic_materials:plastic_sheet", "dye:red"}
  795. },
  796. })
  797. minetest.register_craft({
  798. output = "homedecor:piano",
  799. recipe = {
  800. { "", "basic_materials:steel_wire", "building_blocks:hardwood" },
  801. { "basic_materials:plastic_strip", "basic_materials:steel_wire", "building_blocks:hardwood" },
  802. { "basic_materials:brass_ingot", "default:steelblock", "building_blocks:hardwood" }
  803. },
  804. })
  805. minetest.register_craft({
  806. output = "homedecor:wall_shelf 2",
  807. recipe = {
  808. { "homedecor:wood_table_small_square", "homedecor:curtainrod_wood", "homedecor:curtainrod_wood" },
  809. },
  810. })
  811. minetest.register_craft({
  812. output = "homedecor:trophy 3",
  813. recipe = {
  814. { "default:gold_ingot","","default:gold_ingot" },
  815. { "","default:gold_ingot","" },
  816. { "group:wood","default:gold_ingot","group:wood" }
  817. },
  818. })
  819. minetest.register_craft({
  820. output = "homedecor:sportbench",
  821. recipe = {
  822. { "stairs:slab_steelblock","basic_materials:steel_bar","stairs:slab_steelblock" },
  823. { "default:steel_ingot","wool:black","default:steel_ingot" },
  824. { "default:steel_ingot","wool:black","default:steel_ingot" }
  825. },
  826. })
  827. minetest.register_craft({
  828. output = "homedecor:skateboard",
  829. recipe = {
  830. { "dye:yellow","dye:green","dye:blue" },
  831. { "homedecor:wood_table_small_square","homedecor:wood_table_small_square","homedecor:wood_table_small_square" },
  832. { "default:steel_ingot","","default:steel_ingot" }
  833. },
  834. })
  835. minetest.register_craft({
  836. output = "homedecor:tool_cabinet",
  837. recipe = {
  838. { "basic_materials:motor", "default:axe_steel", "default:pick_steel" },
  839. { "default:steel_ingot", "homedecor:drawer_small", "default:steel_ingot" },
  840. { "default:steel_ingot", "homedecor:drawer_small", "default:steel_ingot" }
  841. },
  842. })
  843. minetest.register_craft({
  844. output = "homedecor:spiral_staircase",
  845. recipe = {
  846. { "default:steelblock", "homedecor:pole_wrought_iron", "" },
  847. { "", "homedecor:pole_wrought_iron", "default:steelblock" },
  848. { "default:steelblock", "homedecor:pole_wrought_iron", "" }
  849. },
  850. })
  851. minetest.register_craftitem(":homedecor:flower_pot_small", {
  852. description = S("Small Flower Pot"),
  853. inventory_image = "homedecor_flowerpot_small_inv.png"
  854. })
  855. minetest.register_craft( {
  856. output = "homedecor:flower_pot_small",
  857. recipe = {
  858. { "default:clay_brick", "", "default:clay_brick" },
  859. { "", "default:clay_brick", "" }
  860. }
  861. })
  862. minetest.register_craft( {
  863. output = "homedecor:flower_pot_small 3",
  864. recipe = { { "homedecor:flower_pot_terracotta" } }
  865. })
  866. for i in ipairs(homedecor_misc.banister_materials) do
  867. local name = homedecor_misc.banister_materials[i][1]
  868. local topmat = homedecor_misc.banister_materials[i][5]
  869. local vertmat = homedecor_misc.banister_materials[i][6]
  870. local dye1 = homedecor_misc.banister_materials[i][7]
  871. local dye2 = homedecor_misc.banister_materials[i][8]
  872. minetest.register_craft({
  873. output = "homedecor:banister_"..name.."_horizontal 2",
  874. recipe = {
  875. { topmat, "", dye1 },
  876. { vertmat, topmat, "" },
  877. { dye2, vertmat, topmat }
  878. },
  879. })
  880. end
  881. unifieddyes.register_color_craft({
  882. output = "",
  883. palette = "split",
  884. neutral_node = "homedecor:banister_wood_horizontal",
  885. type = "shapeless",
  886. output_prefix = "homedecor:banister_wood_horizontal_",
  887. output_suffix = "",
  888. recipe = {
  889. "NEUTRAL_NODE",
  890. "MAIN_DYE",
  891. }
  892. })
  893. -- Japanese-style wood/paper wall pieces and door
  894. local jp_cbox = {
  895. type = "fixed",
  896. fixed = {-0.5, -0.5, 0, 0.5, 0.5, 0.0625},
  897. }
  898. minetest.register_node(":homedecor:japanese_wall_top", {
  899. description = S("Japanese wall (top)"),
  900. drawtype = "mesh",
  901. mesh = "homedecor_wall_japanese_top.obj",
  902. tiles = {
  903. homedecor.lux_wood,
  904. "homedecor_japanese_paper.png"
  905. },
  906. paramtype = "light",
  907. paramtype2 = "facedir",
  908. groups = {snappy=3},
  909. selection_box = jp_cbox,
  910. collision_box = jp_cbox,
  911. sounds = default.node_sound_wood_defaults(),
  912. })
  913. minetest.register_node(":homedecor:japanese_wall_middle", {
  914. description = S("Japanese wall"),
  915. drawtype = "mesh",
  916. mesh = "homedecor_wall_japanese_middle.obj",
  917. tiles = {
  918. homedecor.lux_wood,
  919. "homedecor_japanese_paper.png"
  920. },
  921. paramtype = "light",
  922. paramtype2 = "facedir",
  923. groups = {snappy=3},
  924. selection_box = jp_cbox,
  925. collision_box = jp_cbox,
  926. sounds = default.node_sound_wood_defaults(),
  927. })
  928. minetest.register_node(":homedecor:japanese_wall_bottom", {
  929. description = S("Japanese wall (bottom)"),
  930. drawtype = "mesh",
  931. mesh = "homedecor_wall_japanese_bottom.obj",
  932. tiles = {
  933. homedecor.lux_wood,
  934. "homedecor_japanese_paper.png"
  935. },
  936. paramtype = "light",
  937. paramtype2 = "facedir",
  938. groups = {snappy=3},
  939. selection_box = jp_cbox,
  940. collision_box = jp_cbox,
  941. sounds = default.node_sound_wood_defaults(),
  942. })