Page Menu
Home
1F616EMO Bugtracker
Search
Configure Global Search
Log In
Files
F172431
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/func_areas_limitations/init.lua b/func_areas_limitations/init.lua
index fe53c35..edc12c3 100644
--- a/func_areas_limitations/init.lua
+++ b/func_areas_limitations/init.lua
@@ -1,67 +1,62 @@
-- twi_mods/func_areas_limitations/init.lua
-- func area limitations
--[[
Copyright © 2024 1F616EMO
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
]]
local S = minetest.get_translator("func_areas_limitations")
-local function rm_chat_send(pos, player, name, msg)
- minetest.chat_send_player(name, msg)
- if minetest.features.node_interaction_actor then -- https://github.com/minetest/minetest/pull/14505
- minetest.after(0, minetest.dig_node, pos, player)
- else
- if minetest.get_node(pos).name ~= "air" then
- minetest.remove_node(pos)
- return true
- end
- end
-end
-
-minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
+local old_item_place_node_is_protected = extended_protection.item_place_node_is_protected
+function extended_protection.item_place_node_is_protected(itemstack, placer, pointed_thing)
if not placer:is_player() then return end
local name = placer:get_player_name()
local item_name = itemstack:get_name()
+ local pos = extended_protection.pointed_thing_to_pos(pointed_thing)
- -- Public Tree farm top [41]
if func_areas.is_in_func_area(pos, 41) then
- return rm_chat_send(pos, placer, name,
- S("You can only place down apple tree saplings in the Public Tree Farm."))
+ return true
+ elseif func_areas.is_in_func_area(pos, 225) and item_name ~= "default:sapling" then
+ return true
+ elseif func_areas.is_in_func_area(pos, 13) and minetest.get_item_group(item_name, "seed") == 0 then
+ return true
+ elseif func_areas.is_in_func_area(pos, 136) then
+ return true
end
- -- Public Tree farm bottom [225]
- if func_areas.is_in_func_area(pos, 225) and item_name ~= "default:sapling" then
- return rm_chat_send(pos, placer, name,
- S("You can only place down apple tree saplings in the Public Tree Farm."))
- end
+ return old_item_place_node_is_protected(itemstack, placer, pointed_thing)
+end
- -- Public farm [13]
- if func_areas.is_in_func_area(pos, 13) and minetest.get_item_group(item_name, "seed") == 0 then
- return rm_chat_send(pos, placer, name,
- S("You can only place down plant seeds in the Public Farm."))
- end
+extended_protection.register_on_item_place_node_protection_violation(function(itemstack, placer, pointed_thing)
+ if not placer:is_player() then return end
+ local name = placer:get_player_name()
+ local item_name = itemstack:get_name()
+ local pos = extended_protection.pointed_thing_to_pos(pointed_thing)
- -- Cactus Farm [136]
- if func_areas.is_in_func_area(pos, 136) then
- return rm_chat_send(pos, placer, name,
- S("You are not allowed to place blocks in the Public Cactus Farm."))
+ if func_areas.is_in_func_area(pos, 41) then
+ minetest.chat_send_player(name, S("You can only place down apple tree saplings in the Public Tree Farm."))
+ elseif func_areas.is_in_func_area(pos, 225) and item_name ~= "default:sapling" then
+ minetest.chat_send_player(name, S("You can only place down apple tree saplings in the Public Tree Farm."))
+ elseif func_areas.is_in_func_area(pos, 13) and minetest.get_item_group(item_name, "seed") == 0 then
+ minetest.chat_send_player(name, S("You can only place down plant seeds in the Public Farm."))
+ elseif func_areas.is_in_func_area(pos, 136) then
+ minetest.chat_send_player(name, S("You are not allowed to place blocks in the Public Cactus Farm."))
end
end)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Apr 14, 2:13 PM (4 d, 13 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
32/79/ec63eac2c4af28d9e34d664968de
Default Alt Text
(4 KB)
Attached To
Mode
rTWIMODS Survival Server Custom Modifications
Attached
Detach File
Event Timeline
Log In to Comment