init.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. -- Home decor seating
  2. -- forked from the previous lrfurn mod
  3. local S = minetest.get_translator("homedecor_seating")
  4. local modpath = minetest.get_modpath("homedecor_seating")
  5. lrfurn = {}
  6. lrfurn.fdir_to_right = {
  7. { 1, 0 },
  8. { 0, -1 },
  9. { -1, 0 },
  10. { 0, 1 },
  11. }
  12. lrfurn.colors = {
  13. "black",
  14. "brown",
  15. "blue",
  16. "cyan",
  17. "dark_grey",
  18. "dark_green",
  19. "green",
  20. "grey",
  21. "magenta",
  22. "orange",
  23. "pink",
  24. "red",
  25. "violet",
  26. "white",
  27. "yellow",
  28. }
  29. function lrfurn.check_right(pos, fdir, long, placer)
  30. if not fdir or fdir > 3 then fdir = 0 end
  31. local pos2 = {
  32. x = pos.x + lrfurn.fdir_to_right[fdir+1][1],
  33. y = pos.y, z = pos.z + lrfurn.fdir_to_right[fdir+1][2]
  34. }
  35. local pos3 = {
  36. x = pos.x + lrfurn.fdir_to_right[fdir+1][1] * 2,
  37. y = pos.y, z = pos.z + lrfurn.fdir_to_right[fdir+1][2] * 2
  38. }
  39. local node2 = minetest.get_node(pos2)
  40. if node2 and node2.name ~= "air" then
  41. return false
  42. elseif minetest.is_protected(pos2, placer:get_player_name()) then
  43. if not long then
  44. minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the other end goes!"))
  45. else
  46. minetest.chat_send_player(placer:get_player_name(),
  47. S("Someone else owns the spot where the middle or far end goes!"))
  48. end
  49. return false
  50. end
  51. if long then
  52. local node3 = minetest.get_node(pos3)
  53. if node3 and node3.name ~= "air" then
  54. return false
  55. elseif minetest.is_protected(pos3, placer:get_player_name()) then
  56. minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the other end goes!"))
  57. return false
  58. end
  59. end
  60. return true
  61. end
  62. function lrfurn.fix_sofa_rotation_nsew(pos, placer, itemstack, pointed_thing)
  63. local node = minetest.get_node(pos)
  64. local colorbits = node.param2 - (node.param2 % 8)
  65. local yaw = placer:get_look_yaw()
  66. local dir = minetest.yaw_to_dir(yaw-1.5)
  67. local fdir = minetest.dir_to_wallmounted(dir)
  68. minetest.swap_node(pos, { name = node.name, param2 = fdir+colorbits })
  69. end
  70. dofile(modpath.."/longsofas.lua")
  71. dofile(modpath.."/sofas.lua")
  72. dofile(modpath.."/armchairs.lua")
  73. dofile(modpath.."/misc.lua")