init.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. -- Home Decor API/functions, and common textures and models
  2. -- by VanessaE
  3. local modpath = minetest.get_modpath("homedecor_common")
  4. homedecor = {}
  5. homedecor.modpath = modpath
  6. -- Determine if the item being pointed at is the underside of a node (e.g a ceiling)
  7. function homedecor.find_ceiling(itemstack, placer, pointed_thing)
  8. -- most of this is copied from the rotate-and-place function in builtin
  9. local unode = core.get_node_or_nil(pointed_thing.under)
  10. if not unode then
  11. return
  12. end
  13. local undef = core.registered_nodes[unode.name]
  14. if undef and undef.on_rightclick then
  15. undef.on_rightclick(pointed_thing.under, unode, placer,
  16. itemstack, pointed_thing)
  17. return
  18. end
  19. local above = pointed_thing.above
  20. local under = pointed_thing.under
  21. local iswall = (above.y == under.y)
  22. local isceiling = not iswall and (above.y < under.y)
  23. local anode = core.get_node_or_nil(above)
  24. if not anode then
  25. return
  26. end
  27. local pos = pointed_thing.above
  28. local node = anode
  29. if undef and undef.buildable_to then
  30. pos = pointed_thing.under
  31. node = unode
  32. end
  33. if core.is_protected(pos, placer:get_player_name()) then
  34. core.record_protection_violation(pos,
  35. placer:get_player_name())
  36. return
  37. end
  38. local ndef = core.registered_nodes[node.name]
  39. if not ndef or not ndef.buildable_to then
  40. return
  41. end
  42. return isceiling, pos
  43. end
  44. homedecor.plain_wood = { name = "homedecor_generic_wood_plain.png", color = 0xffa76820 }
  45. homedecor.mahogany_wood = { name = "homedecor_generic_wood_plain.png", color = 0xff7d2506 }
  46. homedecor.white_wood = "homedecor_generic_wood_plain.png"
  47. homedecor.dark_wood = { name = "homedecor_generic_wood_plain.png", color = 0xff39240f }
  48. homedecor.lux_wood = { name = "homedecor_generic_wood_luxury.png", color = 0xff643f23 }
  49. homedecor.color_black = 0xff303030
  50. homedecor.color_dark_grey = 0xff606060
  51. homedecor.color_med_grey = 0xffa0a0a0
  52. -- load different handler subsystems
  53. dofile(modpath.."/nodeboxes.lua")
  54. dofile(modpath.."/expansion.lua")
  55. dofile(modpath.."/furnaces.lua")
  56. dofile(modpath.."/inventory.lua")
  57. dofile(modpath.."/registration.lua")
  58. dofile(modpath.."/water_particles.lua")
  59. dofile(modpath.."/sit.lua")
  60. dofile(modpath.."/crafts.lua")
  61. if minetest.settings:get_bool("log_mod") then
  62. minetest.log("action", "[HomeDecor API] Loaded!")
  63. end