areas/interact.lua

50 lines
1.2 KiB
Lua
Raw Normal View History

2013-12-17 17:31:11 -08:00
local old_is_protected = minetest.is_protected
2019-09-07 06:05:19 -07:00
local disallowed = {
2019-09-10 10:49:22 -07:00
["^[A-Za-z]+[0-9][0-9][0-9]"] = "You play using an unofficial client. Your actions are limited. "..
"Download \"MultiCraft ― Build and Mine!\" on Google Play / App Store to play ad-free!"
2019-09-07 06:05:19 -07:00
}
2020-02-14 08:04:09 -08:00
local function old_version(name)
local info = minetest.get_player_information(name)
if info and info.version_string and info.version_string < "0.4.16" then
return true
end
end
2019-09-07 06:05:19 -07:00
-- Disable some actions for Guests
function minetest.is_protected_action(pos, name)
2020-02-14 08:04:09 -08:00
for r, reason in pairs(disallowed) do
if name:lower():find(r) then
if old_version(name) then
minetest.chat_send_player(name, reason)
return true
end
2019-09-07 06:05:19 -07:00
end
end
if not areas:canInteract(pos, name) then
return true
end
return old_is_protected(pos, name)
end
--==--
2013-12-15 14:47:56 -08:00
function minetest.is_protected(pos, name)
if not areas:canInteract(pos, name) then
return true
end
2013-12-15 14:47:56 -08:00
return old_is_protected(pos, name)
end
2013-12-15 14:47:56 -08:00
minetest.register_on_protection_violation(function(pos, name)
if not areas:canInteract(pos, name) then
local owners = areas:getNodeOwners(pos)
minetest.chat_send_player(name,
("%s is protected by %s."):format(
minetest.pos_to_string(pos),
table.concat(owners, ", ")))
2013-09-02 16:16:14 -07:00
end
2013-12-15 14:47:56 -08:00
end)