Minetest mod that adds scifi themed nodes https://content.minetest.net/packages/D00Med/scifi_nodes/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.1KB

  1. --the builder node
  2. local builder_formspec =
  3. "size[8,9]" ..
  4. default.gui_bg ..
  5. default.gui_bg_img ..
  6. default.gui_slots ..
  7. "list[current_name;input;1,1;1,1;]" ..
  8. "list[current_name;output;3,0;4,3;]" ..
  9. "list[current_player;main;0,4.85;8,1;]" ..
  10. "list[current_player;main;0,6.08;8,3;8]" ..
  11. "listring[current_name;input]" ..
  12. "listring[current_name;output]" ..
  13. "listring[current_player;main]" ..
  14. default.get_hotbar_bg(0,4.85)
  15. local input_items = {
  16. {
  17. "default:steel_ingot 1",
  18. "scifi_nodes:black",
  19. "scifi_nodes:blue",
  20. "scifi_nodes:rough",
  21. "scifi_nodes:rust",
  22. "scifi_nodes:white",
  23. "scifi_nodes:grey",
  24. "scifi_nodes:pplwll",
  25. "scifi_nodes:greenmetal",
  26. "scifi_nodes:wall",
  27. "scifi_nodes:blue_square",
  28. "scifi_nodes:mesh",
  29. "scifi_nodes:greytile"
  30. }
  31. }
  32. minetest.register_node("scifi_nodes:builder", {
  33. description = "Sci-fi Node Builder",
  34. tiles = {
  35. "scifi_nodes_builder.png",
  36. "scifi_nodes_builder.png",
  37. "scifi_nodes_builder_side.png",
  38. "scifi_nodes_builder_side.png",
  39. "scifi_nodes_builder_side.png",
  40. "scifi_nodes_builder_front.png"
  41. },
  42. on_construct = function(pos)
  43. --local meta = minetest.get_meta(pos)
  44. --meta:set_string("infotext", "Node Builder (currently does nothing)")
  45. local meta = minetest.get_meta(pos)
  46. meta:set_string("formspec", builder_formspec)
  47. meta:set_string("infotext", "Node Builder")
  48. local inv = meta:get_inventory()
  49. inv:set_size("output", 4 * 3)
  50. inv:set_size("input", 1 * 1)
  51. end,
  52. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  53. local meta = minetest.get_meta(pos)
  54. local inv = meta:get_inventory()
  55. local player_inv = player:get_inventory()
  56. if listname == "output" then
  57. player_inv:add_item("main", stack)
  58. inv:set_stack("output", index, "")
  59. end
  60. if listname == "input" then
  61. for _, row in ipairs(input_items) do
  62. local item = row[1]
  63. if inv:contains_item("input", item) then
  64. inv:set_stack("output", 1, row[2])
  65. inv:set_stack("output", 2, row[3])
  66. inv:set_stack("output", 3, row[4])
  67. inv:set_stack("output", 4, row[5])
  68. inv:set_stack("output", 5, row[6])
  69. inv:set_stack("output", 6, row[7])
  70. inv:set_stack("output", 7, row[8])
  71. inv:set_stack("output", 8, row[9])
  72. inv:set_stack("output", 9, row[10])
  73. inv:set_stack("output", 10, row[11])
  74. inv:set_stack("output", 11, row[12])
  75. inv:set_stack("output", 12, row[13])
  76. end
  77. end
  78. end
  79. end,
  80. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  81. local meta = minetest.get_meta(pos)
  82. local inv = meta:get_inventory()
  83. local istack = inv:get_stack("input", 1)
  84. local stack_name = istack:get_name()
  85. inv:remove_item("input", stack_name.." 1")
  86. inv:set_stack("output", 1, "")
  87. inv:set_stack("output", 2, "")
  88. inv:set_stack("output", 3, "")
  89. inv:set_stack("output", 4, "")
  90. inv:set_stack("output", 5, "")
  91. inv:set_stack("output", 6, "")
  92. inv:set_stack("output", 7, "")
  93. inv:set_stack("output", 8, "")
  94. inv:set_stack("output", 9, "")
  95. inv:set_stack("output", 10, "")
  96. inv:set_stack("output", 11, "")
  97. inv:set_stack("output", 12, "")
  98. end,
  99. paramtype = "light",
  100. paramtype2 = "facedir",
  101. groups = {cracky=1, oddly_breakable_by_hand=1}
  102. })