Skip to content

Commit

Permalink
Let protector:tool handle param2 and owner
Browse files Browse the repository at this point in the history
  • Loading branch information
SX committed Jan 26, 2020
1 parent 7952fac commit 5fe8b7c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions protector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,16 @@ end
if has_protector_mod then
protector.tool:register_protector('xp_redo:protector', {
nodes = nil, -- Compatible nodes for protector tool, uses same on_place, radius, etc.
on_place = function(user, pos, source_pos, nodename)

-- place protector
minetest.set_node(pos, {name = nodename, param2 = 1})

local meta = minetest.get_meta(pos)
local name = user:get_player_name()

meta:set_string("owner", name)

param2 = nil, -- Default param2 for protector
on_place = nil, -- on_place callback, protector is about to be placed
after_place = function(user, meta, src_meta, nodename)
-- copy members across if holding sneak when using tool
if user:get_player_control().sneak then
-- get priv on source protector / set target protector metadata
local src_meta = minetest.get_meta(source_pos)
local xpthreshold = src_meta:get_int("xpthreshold") or 1000
meta:set_int("xpthreshold", xpthreshold)
else
local name = user:get_player_name()
meta:set_int("xpthreshold", get_last_player_user_xp(name))
end
update_formspec(meta)
Expand Down

0 comments on commit 5fe8b7c

Please sign in to comment.