ownership.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --[[
  2. More Blocks: ownership handling
  3. Copyright © 2011-2019 Hugo Locurcio and contributors.
  4. Licensed under the zlib license. See LICENSE.md for more information.
  5. --]]
  6. local S = moreblocks.S
  7. function moreblocks.node_is_owned(pos, placer)
  8. local ownername = false
  9. if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
  10. if HasOwner(pos, placer) then -- returns true if the node is owned
  11. if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
  12. if type(getLastOwner) == "function" then -- ...is an old version
  13. ownername = getLastOwner(pos)
  14. elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
  15. ownername = GetNodeOwnerName(pos)
  16. else
  17. ownername = S("someone")
  18. end
  19. end
  20. end
  21. elseif type(isprotect)=="function" then -- glomie's protection mod
  22. if not isprotect(5, pos, placer) then
  23. ownername = S("someone")
  24. end
  25. elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod
  26. if not protector.can_dig(5, pos, placer) then
  27. ownername = S("someone")
  28. end
  29. end
  30. if ownername ~= false then
  31. minetest.chat_send_player( placer:get_player_name(), S("Sorry, @1 owns that spot.", ownername) )
  32. return true
  33. else
  34. return false
  35. end
  36. end