diff options
author | TenPlus1 <kinsellaja@yahoo.com> | 2018-06-19 18:36:00 +0100 |
---|---|---|
committer | TenPlus1 <kinsellaja@yahoo.com> | 2018-06-19 18:36:00 +0100 |
commit | 1018a558d2b92eb5cdba657c0f6367243c1b85a8 (patch) | |
tree | 30da8af5b06a526d5d1047b95a83f47330476c13 /crops/beans.lua | |
parent | 8a4ca846d90abf5732b436c1f31b72c6b52e61dc (diff) |
added player checks for crop placement
Diffstat (limited to 'crops/beans.lua')
-rw-r--r-- | crops/beans.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crops/beans.lua b/crops/beans.lua index 888a0a1..61b195b 100644 --- a/crops/beans.lua +++ b/crops/beans.lua @@ -27,12 +27,15 @@ local function place_beans(itemstack, placer, pointed_thing, plantname) -- am I right-clicking on something that has a custom on_place set? -- thanks to Krock for helping with this issue :) local def = minetest.registered_nodes[under.name] - if def and def.on_rightclick then + if placer and def and def.on_rightclick then return def.on_rightclick(pt.under, under, placer, itemstack) end + -- is player planting crop? + local name = placer:get_player_name() or "" + -- check for protection - if minetest.is_protected(pt.under, placer:get_player_name()) then + if minetest.is_protected(pt.under, name) then return end @@ -46,7 +49,7 @@ local function place_beans(itemstack, placer, pointed_thing, plantname) minetest.sound_play("default_place_node", {pos = pt.under, gain = 1.0}) - if not farming.is_creative(placer:get_player_name()) then + if placer or not farming.is_creative(placer:get_player_name()) then itemstack:take_item() |