trophies.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. -----------------------------------------------------------------------------------------------
  2. -- Fishing - Mossmanikin's version - Trophies 0.0.2
  3. -- License (code & textures): WTFPL
  4. -- Contains code from: default
  5. -- Supports: animal_clownfish, animal_fish_blue_white
  6. -----------------------------------------------------------------------------------------------
  7. local TRoPHY = {
  8. -- MoD iTeM NaMe iCoN
  9. {"fishing", "fish_raw", "Fish", "fishing_fish.png"},
  10. {"fishing", "pike", "Northern Pike", "fishing_pike.png"},
  11. {"fishing", "shark", "Shark", "fishing_shark.png"},
  12. {"animal_clownfish", "clownfish", "Clownfish", "animal_clownfish_clownfish_item.png"},
  13. {"animal_fish_blue_white", "fish_blue_white", "Blue white fish", "animal_fish_blue_white_fish_blue_white_item.png"},
  14. }
  15. local function has_trophy_privilege(meta, player)
  16. if player:get_player_name() ~= meta:get_string("owner") then
  17. return false
  18. end
  19. return true
  20. end
  21. for i in pairs(TRoPHY) do
  22. local MoD = TRoPHY[i][1]
  23. local iTeM = TRoPHY[i][2]
  24. local NaMe = TRoPHY[i][3]
  25. local iCoN = TRoPHY[i][4]
  26. minetest.register_node("fishing:trophy_"..iTeM, {
  27. description = NaMe.." Trophy",
  28. inventory_image = "default_chest_top.png^"..iCoN.."^fishing_trophy_label.png",
  29. drawtype = "nodebox",
  30. tiles = {
  31. "default_chest_top.png", -- top
  32. "default_chest_top.png", -- bottom
  33. "default_chest_top.png", -- right
  34. "default_chest_top.png", -- left
  35. "default_chest_top.png", -- back
  36. "default_chest_top.png^"..iCoN.."^fishing_trophy_label.png", -- front
  37. },
  38. paramtype = "light",
  39. paramtype2 = "facedir",
  40. walkable = false,
  41. node_box = {
  42. type = "fixed",
  43. fixed = {
  44. -- { left , bottom , front , right , top , back }
  45. { -1/2 , -1/2 , 7/16 , 1/2 , 1/2 , 1/2 },
  46. }
  47. },
  48. selection_box = {
  49. type = "fixed",
  50. fixed = {
  51. { -1/2 , -1/2 , 7/16 , 1/2 , 1/2 , 1/2 },
  52. }
  53. },
  54. groups = {choppy=2,oddly_breakable_by_hand=3,flammable=2},
  55. sounds = default.node_sound_wood_defaults(),
  56. after_place_node = function(pos, placer)
  57. local meta = minetest.get_meta(pos)
  58. meta:set_string("owner", placer:get_player_name() or "")
  59. meta:set_string("infotext", "This Huge "..NaMe.." was caught by the Famous Angler "..
  60. meta:get_string("owner").."!")
  61. end,
  62. on_construct = function(pos)
  63. local meta = minetest.get_meta(pos)
  64. meta:set_string("infotext", NaMe)
  65. meta:set_string("owner", "")
  66. end,
  67. can_dig = function(pos,player)
  68. local meta = minetest.get_meta(pos);
  69. return has_trophy_privilege(meta, player)
  70. end,
  71. })
  72. minetest.register_craft({
  73. type = "shapeless",
  74. output = "fishing:trophy_"..iTeM,
  75. recipe = {MoD..":"..iTeM, "default:sign_wall"},
  76. })
  77. end