Skip to content
Permalink
Browse files

Update api.lua

added protection for seed placement and hoeing
  • Loading branch information
codeandfix authored and paramat committed Sep 2, 2014
1 parent 1f85f00 commit ff0973fa4fc3f7f5bfb4a79a1ee06df1c478e2b2
Showing with 20 additions and 0 deletions.
  1. +20 −0 mods/farming/api.lua
@@ -38,6 +38,16 @@ farming.hoe_on_use = function(itemstack, user, pointed_thing, uses)
return
end

if minetest.is_protected(pt.under, user:get_player_name()) then
minetest.record_protection_violation(pt.under, user:get_player_name())
return
end
if minetest.is_protected(pt.above, user:get_player_name()) then
minetest.record_protection_violation(pt.above, user:get_player_name())
return
end


-- turn the node into soil, wear out item and play sound
minetest.set_node(pt.under, {name = regN[under.name].soil.dry})
minetest.sound_play("default_dig_crumbly", {
@@ -123,6 +133,16 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname)
local under = minetest.get_node(pt.under)
local above = minetest.get_node(pt.above)

if minetest.is_protected(pt.under, placer:get_player_name()) then
minetest.record_protection_violation(pt.under, placer:get_player_name())
return
end
if minetest.is_protected(pt.above, placer:get_player_name()) then
minetest.record_protection_violation(pt.above, placer:get_player_name())
return
end


-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
return

0 comments on commit ff0973f

Please sign in to comment.
You can’t perform that action at this time.