Minetest mod that adds scifi themed 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.
 
 
 

109 lines
3.4 KiB

  1. --chest code from default(Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>)
  2. local chest_formspec =
  3. "size[8,9]" ..
  4. default.gui_bg ..
  5. default.gui_bg_img ..
  6. default.gui_slots ..
  7. "list[current_name;main;0,0.3;8,4;]" ..
  8. "list[current_player;main;0,4.85;8,1;]" ..
  9. "list[current_player;main;0,6.08;8,3;8]" ..
  10. "listring[current_name;main]" ..
  11. "listring[current_player;main]" ..
  12. default.get_hotbar_bg(0,4.85)
  13. -- Helper functions
  14. local function drop_chest_stuff()
  15. return function(pos, oldnode, oldmetadata, digger)
  16. local meta = minetest.get_meta(pos)
  17. meta:from_table(oldmetadata)
  18. local inv = meta:get_inventory()
  19. for i = 1, inv:get_size("main") do
  20. local stack = inv:get_stack("main", i)
  21. if not stack:is_empty() then
  22. local p = {
  23. x = pos.x + math.random(0, 5)/5 - 0.5,
  24. y = pos.y,
  25. z = pos.z + math.random(0, 5)/5 - 0.5}
  26. minetest.add_item(p, stack)
  27. end
  28. end
  29. end
  30. end
  31. --chest code Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
  32. minetest.register_node("scifi_nodes:crate", {
  33. description = "Crate",
  34. tiles = {"scifi_nodes_crate.png"},
  35. paramtype2 = "facedir",
  36. groups = {cracky = 1, oddly_breakable_by_hand = 2, fuel = 8},
  37. legacy_facedir_simple = true,
  38. is_ground_content = false,
  39. sounds = default.node_sound_wood_defaults(),
  40. after_dig_node = drop_chest_stuff(),
  41. on_construct = function(pos)
  42. local meta = minetest.get_meta(pos)
  43. meta:set_string("formspec", chest_formspec)
  44. meta:set_string("infotext", "Crate")
  45. local inv = meta:get_inventory()
  46. inv:set_size("main", 8 * 4)
  47. end,
  48. on_metadata_inventory_move = function(pos, from_list, from_index,
  49. to_list, to_index, count, player)
  50. minetest.log("action", player:get_player_name() ..
  51. " moves stuff in chest at " .. minetest.pos_to_string(pos))
  52. end,
  53. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  54. minetest.log("action", player:get_player_name() ..
  55. " moves stuff to chest at " .. minetest.pos_to_string(pos))
  56. end,
  57. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  58. minetest.log("action", player:get_player_name() ..
  59. " takes stuff from chest at " .. minetest.pos_to_string(pos))
  60. end,
  61. })
  62. minetest.register_node("scifi_nodes:box", {
  63. description = "Storage box",
  64. tiles = {
  65. "scifi_nodes_box_top.png",
  66. "scifi_nodes_box_top.png",
  67. "scifi_nodes_box.png",
  68. "scifi_nodes_box.png",
  69. "scifi_nodes_box.png",
  70. "scifi_nodes_box.png"
  71. },
  72. paramtype2 = "facedir",
  73. groups = {cracky = 1},
  74. legacy_facedir_simple = true,
  75. is_ground_content = false,
  76. sounds = default.node_sound_metal_defaults(),
  77. after_dig_node = drop_chest_stuff(),
  78. on_construct = function(pos)
  79. local meta = minetest.get_meta(pos)
  80. meta:set_string("formspec", chest_formspec)
  81. meta:set_string("infotext", "Box")
  82. local inv = meta:get_inventory()
  83. inv:set_size("main", 8 * 4)
  84. end,
  85. on_metadata_inventory_move = function(pos, from_list, from_index,
  86. to_list, to_index, count, player)
  87. minetest.log("action", player:get_player_name() ..
  88. " moves stuff in chest at " .. minetest.pos_to_string(pos))
  89. end,
  90. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  91. minetest.log("action", player:get_player_name() ..
  92. " moves stuff to chest at " .. minetest.pos_to_string(pos))
  93. end,
  94. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  95. minetest.log("action", player:get_player_name() ..
  96. " takes stuff from chest at " .. minetest.pos_to_string(pos))
  97. end,
  98. })
  99. --end of chest code