diff --git a/func_areas_limitations/init.lua b/func_areas_limitations/init.lua index 78b7dd3..a2c4db7 100644 --- a/func_areas_limitations/init.lua +++ b/func_areas_limitations/init.lua @@ -24,6 +24,13 @@ local S = minetest.get_translator("func_areas_limitations") +local function rm_chat_send(pos, name, msg) + if minetest.get_node(pos).name ~= "air" then + minetest.remove_node(pos) + end + minetest.chat_send_player(name, msg) +end + minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) if not placer:is_player() then return end local name = placer:get_player_name() @@ -31,25 +38,29 @@ minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack -- Public Tree farm top [41] if func_areas.is_in_func_area(pos, 41) then - minetest.remove_node(pos) - minetest.chat_send_player(name, + rm_chat_send(pos, name, S("You can only place down apple tree saplings in the Public Tree Farm.")) return true end -- Public Tree farm bottom [225] if func_areas.is_in_func_area(pos, 225) and item_name ~= "default:sapling" then - minetest.remove_node(pos) - minetest.chat_send_player(name, + rm_chat_send(pos, name, S("You can only place down apple tree saplings in the Public Tree Farm.")) return true end -- Public farm [13] if func_areas.is_in_func_area(pos, 13) and minetest.get_item_group(item_name, "seed") == 0 then - minetest.remove_node(pos) - minetest.chat_send_player(name, + rm_chat_send(pos, name, S("You can only place down plant seeds in the Public Farm.")) return true end + + -- Cactus Farm [136] + if func_areas.is_in_func_area(pos, 136) then + rm_chat_send(pos, name, + S("You are not allowed to place blocks in the Public Cactus Farm.")) + return true + end end)