station_sewing.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. local sewing_table_functions = simplecrafting_lib.generate_table_functions('sewing', {
  2. show_guides = true,
  3. alphabetize_items = true,}
  4. )
  5. local sewing_table_def = {
  6. description = 'Sewing Station',
  7. drawtype = 'mesh',
  8. mesh = 'stations_sewing.obj',
  9. tiles = {'stations_sewing.png'},
  10. sounds = default.node_sound_wood_defaults(),
  11. paramtype2 = 'facedir',
  12. paramtype = 'light',
  13. selection_box = {
  14. type = 'fixed',
  15. fixed = {-.5, -.5, -.5, 1.5, .3, .5},
  16. },
  17. collision_box = {
  18. type = 'fixed',
  19. fixed = {-.5, -.5, -.5, 1.5, .3, .5},
  20. },
  21. groups = {oddly_breakable_by_hand = 1, choppy=3},
  22. after_place_node = function(pos, placer, itemstack)
  23. if not epic.space_to_side(pos) then
  24. minetest.remove_node(pos)
  25. return itemstack
  26. else
  27. local meta = minetest.get_meta(pos)
  28. meta:set_string('infotext', 'Sewing Station')
  29. end
  30. end,
  31. after_dig_node = function(pos, oldnode, oldmetadata, digger)
  32. epic.remove_side_node(pos, oldnode)
  33. end,
  34. on_rotate = function(pos, node)
  35. return false
  36. end,
  37. }
  38. for k, v in pairs(sewing_table_functions) do
  39. sewing_table_def[k] = v
  40. end
  41. minetest.register_node('stations:sewing', sewing_table_def)
  42. local sewing_locked_functions = simplecrafting_lib.generate_table_functions('sewing', {
  43. show_guides = true,
  44. alphabetize_items = true,}
  45. )
  46. local sewing_locked_def = {
  47. description = 'Sewing Station (locked)',
  48. drawtype = 'mesh',
  49. mesh = 'stations_sewing.obj',
  50. tiles = {'stations_sewing.png'},
  51. sounds = default.node_sound_wood_defaults(),
  52. paramtype2 = 'facedir',
  53. paramtype = 'light',
  54. selection_box = {
  55. type = 'fixed',
  56. fixed = {-.5, -.5, -.5, 1.5, .3, .5},
  57. },
  58. collision_box = {
  59. type = 'fixed',
  60. fixed = {-.5, -.5, -.5, 1.5, .3, .5},
  61. },
  62. groups = {oddly_breakable_by_hand = 1, choppy=3},
  63. after_place_node = function(pos, placer, itemstack)
  64. if not epic.space_to_side(pos) then
  65. minetest.remove_node(pos)
  66. return itemstack
  67. else
  68. local meta = minetest.get_meta(pos)
  69. meta:set_string('infotext', 'Sewing Station (locked)')
  70. end
  71. end,
  72. after_dig_node = function(pos, oldnode, oldmetadata, digger)
  73. epic.remove_side_node(pos, oldnode)
  74. end,
  75. on_rotate = function(pos, node)
  76. return false
  77. end,
  78. }
  79. for k, v in pairs(sewing_locked_functions) do
  80. sewing_locked_def[k] = v
  81. end
  82. minetest.register_node('stations:sewing_locked', sewing_locked_def)
  83. local is_uninv = minetest.global_exists("unified_inventory") or false
  84. if is_uninv then
  85. unified_inventory.register_craft_type("sewing", {
  86. description = "Sewing Station",
  87. icon = 'stations_sewing_icon.png',
  88. width = 4,
  89. height = 2,
  90. uses_crafting_grid = false
  91. })
  92. end