Skip to content

Commit

Permalink
func_area dup bugfix & cactus farm
Browse files Browse the repository at this point in the history
  • Loading branch information
Emojigit committed Mar 29, 2024
1 parent 261f511 commit f9cbc17
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions func_areas_limitations/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,43 @@

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()
local item_name = itemstack:get_name()

-- 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)

0 comments on commit f9cbc17

Please sign in to comment.