trophies.lua 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. -----------------------------------------------------------------------------------------------
  2. -- Fishing - crabman77's version
  3. -- Rewrited from original Fishing - Mossmanikin's version - Trophies 0.0.2
  4. -- License (code & textures): WTFPL
  5. -- Contains code from: default
  6. -- Supports: animal_clownfish, animal_fish_blue_white
  7. -----------------------------------------------------------------------------------------------
  8. local trophy = {
  9. -- mod item name icon
  10. {"fishing", "fish_raw", "Fish", "fishing_fish_raw.png"},
  11. {"fishing", "carp_raw", "Carp", "fishing_carp_raw.png"},
  12. {"fishing", "perch_raw", "Perch", "fishing_perch_raw.png"},
  13. {"fishing", "catfish_raw", "Catfish", "fishing_catfish_raw.png"},
  14. {"fishing", "pike_raw", "Northern Pike", "fishing_pike_raw.png"},
  15. {"fishing", "clownfish_raw", "Clownfish", "fishing_clownfish_raw.png"},
  16. {"fishing", "bluewhite_raw", "Bluewhite", "fishing_bluewhite_raw.png"},
  17. {"fishing", "exoticfish_raw", "Exoticfish", "fishing_exoticfish_raw.png"},
  18. {"fishing", "shark_raw", "Shark", "fishing_shark_raw.png"},
  19. }
  20. local function has_trophy_privilege(meta, player)
  21. if player:get_player_name() ~= meta:get_string("owner") then
  22. return false
  23. end
  24. return true
  25. end
  26. for i in pairs(trophy) do
  27. local mod = trophy[i][1]
  28. local item = trophy[i][2]
  29. local name = trophy[i][3]
  30. local icon = trophy[i][4]
  31. minetest.register_node("fishing:trophy_"..item, {
  32. description = fishing_setting.func.S(name.." Trophy"),
  33. inventory_image = "fishing_trophy_plank.png^"..icon.."^fishing_trophy_label.png",
  34. drawtype = "nodebox",
  35. tiles = {
  36. "fishing_trophy_plank.png", -- top
  37. "fishing_trophy_plank.png", -- bottom
  38. "fishing_trophy_plank.png", -- right
  39. "fishing_trophy_plank.png", -- left
  40. "fishing_trophy_plank.png", -- back
  41. "fishing_trophy_plank.png^"..icon.."^fishing_trophy_label.png", -- front
  42. },
  43. paramtype = "light",
  44. paramtype2 = "facedir",
  45. walkable = false,
  46. node_box = {
  47. type = "fixed",
  48. fixed = {
  49. -- { left , bottom , front , right , top , back }
  50. { -1/2 , -1/2 , 7/16 , 1/2 , 1/2 , 1/2 },
  51. }
  52. },
  53. selection_box = {
  54. type = "fixed",
  55. fixed = {
  56. { -1/2 , -1/2 , 7/16 , 1/2 , 1/2 , 1/2 },
  57. }
  58. },
  59. groups = {choppy=2,oddly_breakable_by_hand=3,flammable=2},
  60. sounds = default.node_sound_wood_defaults(),
  61. after_place_node = function(pos, placer)
  62. local meta = minetest.get_meta(pos)
  63. meta:set_string("owner", placer:get_player_name() or "")
  64. meta:set_string("infotext", fishing_setting.func.S("This Huge "..name.." was caught by the Famous Angler %s !"):format((placer:get_player_name() or "")))
  65. end,
  66. on_construct = function(pos)
  67. local meta = minetest.get_meta(pos)
  68. meta:set_string("infotext", name)
  69. meta:set_string("owner", "")
  70. end,
  71. can_dig = function(pos,player)
  72. local meta = minetest.get_meta(pos);
  73. return has_trophy_privilege(meta, player)
  74. end,
  75. })
  76. --[[
  77. minetest.register_craft({
  78. type = "shapeless",
  79. output = "fishing:trophy_"..item,
  80. recipe = {mod..":"..item, "default:sign_wall"},
  81. })
  82. --]]
  83. end