storage.lua 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. -------------------------------------------------------------
  2. local function is_owner(pos, name)
  3. local owner = minetest.get_meta(pos):get_string("owner")
  4. if owner == "" or owner == name or minetest.check_player_privs(name, "protection_bypass") then
  5. return true
  6. end
  7. return false
  8. end
  9. ---------------------------------------------------
  10. local function get_storage_formspec(pos)
  11. local formspec ="size[8,7]" ..
  12. default.gui_bg ..
  13. default.gui_bg_img ..
  14. default.gui_slots ..
  15. "list[current_name;main;0,0.3;8,2]" ..
  16. "list[current_player;main;0,2.85;8,1]" ..
  17. "list[current_player;main;0,4.08;8,3;8]" ..
  18. "listring[current_name;main]" ..
  19. "listring[current_player;main]"
  20. return formspec
  21. end
  22. -------------------------------------------------------------
  23. --Storage Pot
  24. --Unfired pot (not usuable... must be cooked)
  25. minetest.register_craftitem("earthbuild:storage_pot_unfired", {
  26. description = "Unfired Clay Storage Pot",
  27. inventory_image = "earthbuild_storage_pot_unfired.png",
  28. stack_max = 99,
  29. })
  30. --Finished Pot
  31. minetest.register_node("earthbuild:storage_pot", {
  32. description = "Clay Storage Pot",
  33. tiles = {"earthbuild_storage_pot_top.png",
  34. "earthbuild_storage_pot_top.png",
  35. "earthbuild_storage_pot.png",
  36. "earthbuild_storage_pot.png",
  37. "earthbuild_storage_pot.png"},
  38. drawtype = "nodebox",
  39. paramtype = "light",
  40. node_box = {
  41. type = "fixed",
  42. fixed = {
  43. {-0.375, -0.5, -0.375, 0.375, -0.375, 0.375},
  44. {-0.375, 0.375, -0.375, 0.375, 0.5, 0.375},
  45. {-0.4375, -0.375, -0.4375, 0.4375, -0.25, 0.4375},
  46. {-0.4375, 0.25, -0.4375, 0.4375, 0.375, 0.4375},
  47. {-0.5, -0.25, -0.5, 0.5, 0.25, 0.5},
  48. }
  49. },
  50. groups = {oddly_breakable_by_hand = 3},
  51. sounds = default.node_sound_stone_defaults(),
  52. on_construct = function(pos)
  53. local meta = minetest.get_meta(pos)
  54. meta:set_string("formspec", get_storage_formspec(pos, 8, 2))
  55. local inv = meta:get_inventory()
  56. inv:set_size("main", 8*3)
  57. meta:set_string("infotext", "Clay Storage Pot")
  58. end,
  59. can_dig = function(pos, player)
  60. local inv = minetest.get_meta(pos):get_inventory()
  61. local name = ""
  62. if player then
  63. name = player:get_player_name()
  64. end
  65. return is_owner(pos, name) and inv:is_empty("main")
  66. end,
  67. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  68. if is_owner(pos, player:get_player_name()) then
  69. return count
  70. end
  71. return 0
  72. end,
  73. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  74. if is_owner(pos, player:get_player_name())
  75. and not string.match(stack:get_name(), "backpacks:") then
  76. return stack:get_count()
  77. end
  78. return 0
  79. end,
  80. allow_metadata_inventory_take = function(pos, listname, index, stack, player)
  81. if is_owner(pos, player:get_player_name()) then
  82. return stack:get_count()
  83. end
  84. return 0
  85. end,
  86. on_blast = function(pos)
  87. end,
  88. })
  89. --Craft unfired pot
  90. minetest.register_craft({
  91. output = "earthbuild:storage_pot_unfired",
  92. recipe = {
  93. {"default:clay_lump", "default:clay_lump", "default:clay_lump"},
  94. {"default:clay_lump", "", "default:clay_lump"},
  95. {"default:clay_lump", "default:clay_lump", "default:clay_lump"},
  96. }
  97. })
  98. --Recycle unfired pot
  99. minetest.register_craft({
  100. output = "default:clay_lump 8",
  101. recipe = {
  102. {"earthbuild:storage_pot_unfired"}}
  103. })
  104. --Cook unfired pot to give the useable pot
  105. minetest.register_craft({
  106. type = "cooking",
  107. output = "earthbuild:storage_pot",
  108. recipe = "earthbuild:storage_pot_unfired",
  109. cooktime = 10,
  110. })
  111. --------------------------------------------
  112. --Basket
  113. minetest.register_node("earthbuild:basket", {
  114. description = "Basket",
  115. tiles = {"earthbuild_basket_top.png",
  116. "earthbuild_basket_top.png",
  117. "earthbuild_basket.png",
  118. "earthbuild_basket.png",
  119. "earthbuild_basket.png"},
  120. drawtype = "nodebox",
  121. paramtype = "light",
  122. node_box = {
  123. type = "fixed",
  124. fixed = {
  125. {-0.25, 0.375, -0.25, 0.25, 0.5, 0.25},
  126. {-0.375, -0.25, -0.375, 0.375, 0.3125, 0.375},
  127. {-0.3125, -0.375, -0.3125, 0.3125, -0.25, 0.3125},
  128. {-0.25, -0.5, -0.25, 0.25, -0.375, 0.25},
  129. {-0.3125, 0.3125, -0.3125, 0.3125, 0.375, 0.3125},
  130. }
  131. },
  132. groups = {oddly_breakable_by_hand = 3},
  133. sounds = default.node_sound_leaves_defaults(),
  134. on_construct = function(pos)
  135. local meta = minetest.get_meta(pos)
  136. meta:set_string("formspec", get_storage_formspec(pos, 8, 2))
  137. local inv = meta:get_inventory()
  138. inv:set_size("main", 8*2)
  139. meta:set_string("infotext", "Basket")
  140. end,
  141. can_dig = function(pos, player)
  142. local inv = minetest.get_meta(pos):get_inventory()
  143. local name = ""
  144. if player then
  145. name = player:get_player_name()
  146. end
  147. return is_owner(pos, name) and inv:is_empty("main")
  148. end,
  149. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  150. if is_owner(pos, player:get_player_name()) then
  151. return count
  152. end
  153. return 0
  154. end,
  155. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  156. if is_owner(pos, player:get_player_name())
  157. and not string.match(stack:get_name(), "backpacks:") then
  158. return stack:get_count()
  159. end
  160. return 0
  161. end,
  162. allow_metadata_inventory_take = function(pos, listname, index, stack, player)
  163. if is_owner(pos, player:get_player_name()) then
  164. return stack:get_count()
  165. end
  166. return 0
  167. end,
  168. on_blast = function(pos)
  169. end,
  170. })
  171. --Craft basket
  172. minetest.register_craft({
  173. output = "earthbuild:basket",
  174. recipe = {
  175. {"earthbuild:woven_mat", "earthbuild:woven_mat", "earthbuild:woven_mat"},
  176. {"earthbuild:woven_mat", "", "earthbuild:woven_mat"},
  177. {"earthbuild:woven_mat", "earthbuild:woven_mat", "earthbuild:woven_mat"},
  178. }
  179. })
  180. --burn basket
  181. minetest.register_craft({
  182. type = "fuel",
  183. recipe = "earthbuild:basket",
  184. burntime = 8,
  185. })
  186. -----------------------------------------------------
  187. --Gourd Container
  188. --Vessel
  189. minetest.register_node("earthbuild:bottlegourd_container", {
  190. description = "Bottlegourd Container",
  191. drawtype = "nodebox",
  192. tiles = { "earthbuild_bottlegourd_container_top.png",
  193. "earthbuild_bottlegourd_bot.png",
  194. "earthbuild_bottlegourd_container.png",
  195. "earthbuild_bottlegourd_container.png",
  196. "earthbuild_bottlegourd_container.png",
  197. "earthbuild_bottlegourd_container.png",
  198. "earthbuild_bottlegourd_container.png",
  199. "earthbuild_bottlegourd_container.png",
  200. },
  201. inventory_image = "earthbuild_bottlegourd_container.png",
  202. wield_image = "earthbuild_bottlegourd_container.png",
  203. paramtype = "light",
  204. node_box = {
  205. type = "fixed",
  206. fixed = {
  207. {-0.25, -0.5, -0.25, 0.25, -0.0, 0.25},
  208. }
  209. },
  210. selection_box = {
  211. type = "fixed",
  212. fixed = {
  213. {-0.25, -0.5, -0.25, 0.25, -0.0, 0.25},
  214. }
  215. },
  216. groups = {dig_immediate = 3,},
  217. sounds = default.node_sound_wood_defaults(),
  218. on_construct = function(pos)
  219. local meta = minetest.get_meta(pos)
  220. meta:set_string("formspec", get_storage_formspec(pos, 8, 2))
  221. local inv = meta:get_inventory()
  222. inv:set_size("main", 1*1)
  223. meta:set_string("infotext", "Bottle Gourd")
  224. end,
  225. can_dig = function(pos, player)
  226. local inv = minetest.get_meta(pos):get_inventory()
  227. local name = ""
  228. if player then
  229. name = player:get_player_name()
  230. end
  231. return is_owner(pos, name) and inv:is_empty("main")
  232. end,
  233. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  234. if is_owner(pos, player:get_player_name()) then
  235. return count
  236. end
  237. return 0
  238. end,
  239. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  240. if is_owner(pos, player:get_player_name())
  241. and not string.match(stack:get_name(), "backpacks:") then
  242. return stack:get_count()
  243. end
  244. return 0
  245. end,
  246. allow_metadata_inventory_take = function(pos, listname, index, stack, player)
  247. if is_owner(pos, player:get_player_name()) then
  248. return stack:get_count()
  249. end
  250. return 0
  251. end,
  252. on_blast = function(pos)
  253. end,
  254. })
  255. minetest.register_craft({
  256. output = 'earthbuild:bottlegourd_container',
  257. recipe = {
  258. {'earthbuild:bottlegourd_cup', 'earthbuild:bottlegourd_cup'},
  259. }
  260. })
  261. minetest.register_craft({
  262. type = "fuel",
  263. recipe = "earthbuild:bottlegourd_container",
  264. burntime = 1,
  265. })