chests.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. minetest.register_tool("lottblocks:lockpick", {
  2. description = "Lockpick",
  3. inventory_image = "lottblocks_steel_lockpick.png", --Made by HeroOfTheWinds
  4. --https://github.com/HeroOfTheWinds/lockpicks/blob/master/textures/steel_lockpick.png
  5. max_stack = 1,
  6. })
  7. minetest.register_craft({
  8. output = "lottblocks:lockpick",
  9. recipe = {
  10. {"", "default:steel_ingot", "default:steel_ingot"},
  11. {"", "default:steel_ingot", ""},
  12. {"", "group:stick", ""}
  13. }
  14. })
  15. local function lockpick(itemstack, pos, race, player)
  16. if math.random(1, 4) ~= 3 then
  17. itemstack:add_wear(65535/20)
  18. minetest.chat_send_player(player, "Lockpick failed")
  19. else
  20. itemstack:add_wear(65535/18)
  21. minetest.show_formspec(player,
  22. "lottblocks:" .. race .. "_chest",
  23. default.get_chest_formspec(pos, "gui_" .. race .. "bg.png"))
  24. lottachievements.unlock(player, "thief")
  25. end
  26. end
  27. minetest.register_node("lottblocks:hobbit_chest", {
  28. description = "Hobbit Chest",
  29. tiles = {"lottblocks_hobbit_chest_top.png", "lottblocks_hobbit_chest_top.png", "lottblocks_hobbit_chest_side.png",
  30. "lottblocks_hobbit_chest_side.png", "lottblocks_hobbit_chest_side.png", "lottblocks_hobbit_chest_front.png"},
  31. paramtype2 = "facedir",
  32. groups = {choppy=2,oddly_breakable_by_hand=2},
  33. legacy_facedir_simple = true,
  34. is_ground_content = false,
  35. sounds = default.node_sound_wood_defaults(),
  36. on_construct = function(pos, node, active_object_count, active_object_count_wider)
  37. local meta = minetest.get_meta(pos)
  38. meta:set_string("infotext", "Hobbit Chest")
  39. local inv = meta:get_inventory()
  40. inv:set_size("main", 8*4)
  41. end,
  42. on_rightclick = function(pos, node, clicker, itemstack)
  43. local player = clicker:get_player_name()
  44. local item = itemstack:get_name()
  45. if minetest.check_player_privs(player, {GAMEhobbit=true})
  46. or minetest.check_player_privs(player, {GAMEwizard=true}) then
  47. minetest.show_formspec(
  48. player, "lottblocks:hobbit_chest", default.get_chest_formspec(pos, "gui_hobbitbg.png")
  49. )
  50. elseif item == "lottblocks:lockpick" then
  51. lockpick(itemstack, pos, "hobbit", player)
  52. else
  53. minetest.chat_send_player(player, "Only Hobbits can open this kind of chest!")
  54. end
  55. end,
  56. can_dig = function(pos,player)
  57. local meta = minetest.get_meta(pos)
  58. local inv = meta:get_inventory()
  59. return inv:is_empty("main")
  60. end,
  61. on_punch = function(pos,player)
  62. local meta = minetest.get_meta(pos)
  63. meta:set_string("infotext", "Hobbit Chest")
  64. meta:set_string("formspec", "")
  65. end,
  66. })
  67. minetest.register_node("lottblocks:gondor_chest", {
  68. description = "Gondorian Chest",
  69. tiles = {"lottblocks_gondor_chest_top.png", "lottblocks_gondor_chest_bottom.png", "lottblocks_gondor_chest_side.png",
  70. "lottblocks_gondor_chest_side.png", "lottblocks_gondor_chest_side.png", "lottblocks_gondor_chest_front.png"},
  71. paramtype2 = "facedir",
  72. groups = {choppy=2,oddly_breakable_by_hand=2},
  73. legacy_facedir_simple = true,
  74. is_ground_content = false,
  75. sounds = default.node_sound_wood_defaults(),
  76. on_construct = function(pos, node, active_object_count, active_object_count_wider)
  77. local meta = minetest.get_meta(pos)
  78. meta:set_string("infotext", "Gondorian Chest")
  79. local inv = meta:get_inventory()
  80. inv:set_size("main", 8*4)
  81. end,
  82. on_rightclick = function(pos, node, clicker, itemstack)
  83. local player = clicker:get_player_name()
  84. local item = itemstack:get_name()
  85. if minetest.check_player_privs(player, {GAMEman=true})
  86. or minetest.check_player_privs(player, {GAMEwizard=true}) then
  87. minetest.show_formspec(
  88. player,
  89. "lottblocks:gondor_chest",
  90. default.get_chest_formspec(pos, "gui_gondorbg.png")
  91. )
  92. elseif item == "lottblocks:lockpick" then
  93. lockpick(itemstack, pos, "gondor", player)
  94. else
  95. minetest.chat_send_player(player, "Only Humans can open this kind of chest!")
  96. end
  97. end,
  98. can_dig = function(pos,player)
  99. local meta = minetest.get_meta(pos);
  100. local inv = meta:get_inventory()
  101. return inv:is_empty("main")
  102. end,
  103. on_punch = function(pos,player)
  104. local meta = minetest.get_meta(pos)
  105. meta:set_string("infotext", "Gondorian Chest")
  106. meta:set_string("formspec", "")
  107. end,
  108. })
  109. minetest.register_node("lottblocks:rohan_chest", {
  110. description = "Rohirrim Chest",
  111. tiles = {"lottblocks_rohan_chest_top.png", "lottblocks_rohan_chest_bottom.png", "lottblocks_rohan_chest_side.png",
  112. "lottblocks_rohan_chest_side.png", "lottblocks_rohan_chest_side.png", "lottblocks_rohan_chest_front.png"},
  113. paramtype2 = "facedir",
  114. groups = {choppy=2,oddly_breakable_by_hand=2},
  115. legacy_facedir_simple = true,
  116. is_ground_content = false,
  117. sounds = default.node_sound_wood_defaults(),
  118. on_construct = function(pos, node, active_object_count, active_object_count_wider)
  119. local meta = minetest.get_meta(pos)
  120. meta:set_string("infotext", "Rohirrim Chest")
  121. local inv = meta:get_inventory()
  122. inv:set_size("main", 8*4)
  123. end,
  124. on_rightclick = function(pos, node, clicker, itemstack)
  125. local player = clicker:get_player_name()
  126. local item = itemstack:get_name()
  127. if minetest.check_player_privs(player, {GAMEman=true})
  128. or minetest.check_player_privs(player, {GAMEwizard=true}) then
  129. minetest.show_formspec(
  130. player,
  131. "lottblocks:rohan_chest",
  132. default.get_chest_formspec(pos, "gui_rohanbg.png")
  133. )
  134. elseif item == "lottblocks:lockpick" then
  135. lockpick(itemstack, pos, "rohan", player)
  136. else
  137. minetest.chat_send_player(player, "Only Humans can open this kind of chest!")
  138. end
  139. end,
  140. can_dig = function(pos,player)
  141. local meta = minetest.get_meta(pos);
  142. local inv = meta:get_inventory()
  143. return inv:is_empty("main")
  144. end,
  145. on_punch = function(pos,player)
  146. local meta = minetest.get_meta(pos)
  147. meta:set_string("infotext", "Rohirrim Chest")
  148. meta:set_string("formspec", "")
  149. end,
  150. })
  151. minetest.register_node("lottblocks:elfloth_chest", {
  152. description = "Elven (Lorien) Chest",
  153. tiles = {"lottblocks_elf_chest_top.png", "lottblocks_elf_chest_bottom.png", "lottblocks_elf_chest_side.png",
  154. "lottblocks_elf_chest_side.png", "lottblocks_elf_chest_side.png", "lottblocks_elf_chest_front.png"},
  155. paramtype2 = "facedir",
  156. groups = {choppy=2,oddly_breakable_by_hand=2},
  157. legacy_facedir_simple = true,
  158. is_ground_content = false,
  159. sounds = default.node_sound_wood_defaults(),
  160. on_construct = function(pos, node, active_object_count, active_object_count_wider)
  161. local meta = minetest.get_meta(pos)
  162. meta:set_string("infotext", "Elven (Lorien) Chest")
  163. local inv = meta:get_inventory()
  164. inv:set_size("main", 8*4)
  165. end,
  166. on_rightclick = function(pos, node, clicker, itemstack)
  167. local player = clicker:get_player_name()
  168. local item = itemstack:get_name()
  169. if minetest.check_player_privs(player, {GAMEelf=true})
  170. or minetest.check_player_privs(player, {GAMEwizard=true}) then
  171. minetest.show_formspec(
  172. player,
  173. "lottblocks:elfloth_chest",
  174. default.get_chest_formspec(pos, "gui_elfbg.png")
  175. )
  176. elseif item == "lottblocks:lockpick" then
  177. lockpick(itemstack, pos, "elf", player)
  178. else
  179. minetest.chat_send_player(player, "Only Elves can open this kind of chest!")
  180. end
  181. end,
  182. can_dig = function(pos,player)
  183. local meta = minetest.get_meta(pos);
  184. local inv = meta:get_inventory()
  185. return inv:is_empty("main")
  186. end,
  187. on_punch = function(pos,player)
  188. local meta = minetest.get_meta(pos)
  189. meta:set_string("infotext", "Elven (Lorien) Chest")
  190. meta:set_string("formspec", "")
  191. end,
  192. })
  193. minetest.register_node("lottblocks:elfmirk_chest", {
  194. description = "Elven (Mirkwood) Chest",
  195. tiles = {"lottblocks_elf_chest_top.png", "lottblocks_elf_chest_bottom.png", "lottblocks_elf_chest_side.png",
  196. "lottblocks_elf_chest_side.png", "lottblocks_elf_chest_side.png", "lottblocks_elf_chest_front.png"},
  197. paramtype2 = "facedir",
  198. groups = {choppy=2,oddly_breakable_by_hand=2},
  199. legacy_facedir_simple = true,
  200. is_ground_content = false,
  201. sounds = default.node_sound_wood_defaults(),
  202. on_construct = function(pos, node, active_object_count, active_object_count_wider)
  203. local meta = minetest.get_meta(pos)
  204. meta:set_string("infotext", "Elven (Mirkwood) Chest")
  205. local inv = meta:get_inventory()
  206. inv:set_size("main", 8*4)
  207. end,
  208. on_rightclick = function(pos, node, clicker, itemstack)
  209. local player = clicker:get_player_name()
  210. local item = itemstack:get_name()
  211. if minetest.check_player_privs(player, {GAMEelf=true})
  212. or minetest.check_player_privs(player, {GAMEwizard=true}) then
  213. minetest.show_formspec(
  214. player,
  215. "lottblocks:elfmirk_chest",
  216. default.get_chest_formspec(pos, "gui_elfbg.png")
  217. )
  218. elseif item == "lottblocks:lockpick" then
  219. lockpick(itemstack, pos, "elf", player)
  220. else
  221. minetest.chat_send_player(player, "Only Elves can open this kind of chest!")
  222. end
  223. end,
  224. can_dig = function(pos,player)
  225. local meta = minetest.get_meta(pos);
  226. local inv = meta:get_inventory()
  227. return inv:is_empty("main")
  228. end,
  229. on_punch = function(pos,player)
  230. local meta = minetest.get_meta(pos)
  231. meta:set_string("infotext", "Elven (Mirkwood) Chest")
  232. meta:set_string("formspec", "")
  233. end,
  234. })
  235. minetest.register_node("lottblocks:mordor_chest", {
  236. description = "Mordor Chest",
  237. tiles = {"lottblocks_mordor_chest_top.png", "lottblocks_mordor_chest_top.png", "lottblocks_mordor_chest_side.png",
  238. "lottblocks_mordor_chest_side.png", "lottblocks_mordor_chest_side.png", "lottblocks_mordor_chest_front.png"},
  239. paramtype2 = "facedir",
  240. groups = {choppy=2,oddly_breakable_by_hand=2},
  241. legacy_facedir_simple = true,
  242. is_ground_content = false,
  243. sounds = default.node_sound_wood_defaults(),
  244. on_construct = function(pos, node, active_object_count, active_object_count_wider)
  245. local meta = minetest.get_meta(pos)
  246. meta:set_string("infotext", "Mordor Chest")
  247. local inv = meta:get_inventory()
  248. inv:set_size("main", 8*4)
  249. end,
  250. on_rightclick = function(pos, node, clicker, itemstack)
  251. local player = clicker:get_player_name()
  252. local item = itemstack:get_name()
  253. if minetest.check_player_privs(player, {GAMEorc=true})
  254. or minetest.check_player_privs(player, {GAMEwizard=true}) then
  255. minetest.show_formspec(
  256. player,
  257. "lottblocks:mordor_chest",
  258. default.get_chest_formspec(pos, "gui_mordorbg.png")
  259. )
  260. elseif item == "lottblocks:lockpick" then
  261. lockpick(itemstack, pos, "mordor", player)
  262. else
  263. minetest.chat_send_player(player, "Only Orcs can open this kind of chest!")
  264. end
  265. end,
  266. can_dig = function(pos,player)
  267. local meta = minetest.get_meta(pos);
  268. local inv = meta:get_inventory()
  269. return inv:is_empty("main")
  270. end,
  271. on_punch = function(pos,player)
  272. local meta = minetest.get_meta(pos)
  273. meta:set_string("infotext", "Mordor Chest")
  274. meta:set_string("formspec", "")
  275. end,
  276. })
  277. minetest.register_node("lottblocks:angmar_chest", {
  278. description = "Angmar Chest",
  279. tiles = {"lottblocks_angmar_chest_top.png", "lottblocks_angmar_chest_top.png", "lottblocks_angmar_chest_side.png",
  280. "lottblocks_angmar_chest_side.png", "lottblocks_angmar_chest_side.png", "lottblocks_angmar_chest_front.png"},
  281. paramtype2 = "facedir",
  282. groups = {choppy=2,oddly_breakable_by_hand=2},
  283. legacy_facedir_simple = true,
  284. is_ground_content = false,
  285. sounds = default.node_sound_wood_defaults(),
  286. on_construct = function(pos, node, active_object_count, active_object_count_wider)
  287. local meta = minetest.get_meta(pos)
  288. meta:set_string("infotext", "Angmar Chest")
  289. local inv = meta:get_inventory()
  290. inv:set_size("main", 8*4)
  291. end,
  292. on_rightclick = function(pos, node, clicker, itemstack)
  293. local player = clicker:get_player_name()
  294. local item = itemstack:get_name()
  295. if minetest.check_player_privs(player, {GAMEorc=true})
  296. or minetest.check_player_privs(player, {GAMEwizard=true}) then
  297. minetest.show_formspec(
  298. player,
  299. "lottblocks:angmar_chest",
  300. default.get_chest_formspec(pos, "gui_angmarbg.png")
  301. )
  302. elseif item == "lottblocks:lockpick" then
  303. lockpick(itemstack, pos, "angmar", player)
  304. else
  305. minetest.chat_send_player(player, "Only Orcs can open this kind of chest!")
  306. end
  307. end,
  308. can_dig = function(pos,player)
  309. local meta = minetest.get_meta(pos);
  310. local inv = meta:get_inventory()
  311. return inv:is_empty("main")
  312. end,
  313. --backwards compatibility: punch to set formspec
  314. on_punch = function(pos,player)
  315. local meta = minetest.get_meta(pos)
  316. meta:set_string("infotext", "Angmar Chest")
  317. meta:set_string("formspec", "")
  318. end,
  319. })
  320. minetest.register_node("lottblocks:dwarf_chest", {
  321. description = "Dwarf Chest",
  322. tiles = {"lottblocks_dwarf_chest_top.png", "lottblocks_dwarf_chest_top.png", "lottblocks_dwarf_chest_side.png",
  323. "lottblocks_dwarf_chest_side.png", "lottblocks_dwarf_chest_side.png", "lottblocks_dwarf_chest_front.png"},
  324. paramtype2 = "facedir",
  325. groups = {choppy=2,oddly_breakable_by_hand=2},
  326. legacy_facedir_simple = true,
  327. is_ground_content = false,
  328. sounds = default.node_sound_wood_defaults(),
  329. on_construct = function(pos, node, active_object_count, active_object_count_wider)
  330. local meta = minetest.get_meta(pos)
  331. meta:set_string("infotext", "Dwarf Chest")
  332. local inv = meta:get_inventory()
  333. inv:set_size("main", 8*4)
  334. end,
  335. on_rightclick = function(pos, node, clicker, itemstack)
  336. local player = clicker:get_player_name()
  337. local item = itemstack:get_name()
  338. if minetest.check_player_privs(player, {GAMEdwarf=true})
  339. or minetest.check_player_privs(player, {GAMEwizard=true}) then
  340. minetest.show_formspec(
  341. player,
  342. "lottblocks:dwarf_chest",
  343. default.get_chest_formspec(pos, "gui_dwarfbg.png")
  344. )
  345. elseif item == "lottblocks:lockpick" then
  346. lockpick(itemstack, pos, "dwarf", player)
  347. else
  348. minetest.chat_send_player(player, "Only Dwarfs can open this kind of chest!")
  349. end
  350. end,
  351. can_dig = function(pos,player)
  352. local meta = minetest.get_meta(pos);
  353. local inv = meta:get_inventory()
  354. return inv:is_empty("main")
  355. end,
  356. --backwards compatibility: punch to set formspec
  357. on_punch = function(pos,player)
  358. local meta = minetest.get_meta(pos)
  359. meta:set_string("infotext", "Dwarf Chest")
  360. meta:set_string("formspec", "")
  361. end,
  362. })
  363. minetest.register_craft({
  364. output = "lottblocks:hobbit_chest",
  365. recipe = {
  366. {"lottplants:birchwood", "lottplants:birchwood", "lottplants:birchwood"},
  367. {"lottplants:birchwood", "default:chest", "lottplants:birchwood"},
  368. {"lottplants:birchwood", "lottplants:birchwood", "lottplants:birchwood"},
  369. }
  370. })
  371. minetest.register_craft({
  372. output = "lottblocks:gondor_chest",
  373. recipe = {
  374. {"lottplants:alderwood", "lottplants:alderwood", "lottplants:alderwood"},
  375. {"lottplants:alderwood", "default:chest", "lottplants:alderwood"},
  376. {"lottplants:alderwood", "lottplants:alderwood", "lottplants:alderwood"},
  377. }
  378. })
  379. minetest.register_craft({
  380. output = "lottblocks:rohan_chest",
  381. recipe = {
  382. {"lottplants:lebethronwood", "lottplants:lebethronwood", "lottplants:lebethronwood"},
  383. {"lottplants:lebethronwood", "default:chest", "lottplants:lebethronwood"},
  384. {"lottplants:lebethronwood", "lottplants:lebethronwood", "lottplants:lebethronwood"},
  385. }
  386. })
  387. minetest.register_craft({
  388. output = "lottblocks:elfloth_chest",
  389. recipe = {
  390. {"lottplants:mallornwood", "lottplants:mallornwood", "lottplants:mallornwood"},
  391. {"lottplants:mallornwood", "default:chest", "lottplants:mallornwood"},
  392. {"lottplants:mallornwood", "lottplants:mallornwood", "lottplants:mallornwood"},
  393. }
  394. })
  395. minetest.register_craft({
  396. output = "lottblocks:elfmirk_chest",
  397. recipe = {
  398. {"default:junglewood", "default:junglewood", "default:junglewood"},
  399. {"default:junglewood", "default:chest", "default:junglewood"},
  400. {"default:junglewood", "default:junglewood", "default:junglewood"},
  401. }
  402. })
  403. minetest.register_craft({
  404. output = "lottblocks:mordor_chest",
  405. recipe = {
  406. {"lottmapgen:mordor_stone", "lottmapgen:mordor_stone", "lottmapgen:mordor_stone"},
  407. {"lottmapgen:mordor_stone", "default:chest", "lottmapgen:mordor_stone"},
  408. {"lottmapgen:mordor_stone", "lottmapgen:mordor_stone", "lottmapgen:mordor_stone"},
  409. }
  410. })
  411. minetest.register_craft({
  412. output = "lottblocks:angmar_chest",
  413. recipe = {
  414. {"lottplants:pinewood", "lottplants:pinewood", "lottplants:pinewood"},
  415. {"lottplants:pinewood", "default:chest", "lottplants:pinewood"},
  416. {"lottplants:pinewood", "lottplants:pinewood", "lottplants:pinewood"},
  417. }
  418. })
  419. minetest.register_craft({
  420. output = "lottblocks:dwarf_chest",
  421. recipe = {
  422. {"default:stone", "default:stone", "default:stone"},
  423. {"default:stone", "default:chest", "default:stone"},
  424. {"default:stone", "default:stone", "default:stone"},
  425. }
  426. })
  427. minetest.register_alias("lottmapgen:hobbit_chest", "lottblocks:hobbit_chest")
  428. minetest.register_alias("lottmapgen:gondor_chest", "lottblocks:gondor_chest")
  429. minetest.register_alias("lottmapgen:rohan_chest", "lottblocks:rohan_chest")
  430. minetest.register_alias("lottmapgen:elfloth_chest", "lottblocks:elfloth_chest")
  431. minetest.register_alias("lottmapgen:elfmirk_chest", "lottblocks:elfmirk_chest")
  432. minetest.register_alias("lottmapgen:mordor_chest", "lottblocks:mordor_chest")
  433. minetest.register_alias("lottmapgen:angmar_chest", "lottblocks:angmar_chest")