Hook: Object takes precedence on use
This commit is contained in:
parent
0337fa5172
commit
006a0a8f3c
@ -159,6 +159,23 @@ end
|
|||||||
-- 1: on_use parameters -> axis/amount/etc.
|
-- 1: on_use parameters -> axis/amount/etc.
|
||||||
-- 2: param2/axis/amount/etc. -> new param2
|
-- 2: param2/axis/amount/etc. -> new param2
|
||||||
function lzr_hook.use(itemstack, player, pointed_thing, is_right_click)
|
function lzr_hook.use(itemstack, player, pointed_thing, is_right_click)
|
||||||
|
-- Object interaction takes precedence
|
||||||
|
if pointed_thing.type == "object" then
|
||||||
|
local obj = pointed_thing.ref
|
||||||
|
local ent = obj:get_luaentity()
|
||||||
|
if ent then
|
||||||
|
if not is_right_click and ent.on_punch then
|
||||||
|
local dir = vector.direction(player:get_pos(), obj:get_pos())
|
||||||
|
ent:on_punch(player, 1000000, itemstack:get_tool_capabilities(), dir)
|
||||||
|
elseif is_rightclick and ent.right_click then
|
||||||
|
ent:right_click(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if pointed_thing.type ~= "node" then
|
||||||
|
return
|
||||||
|
end
|
||||||
local gs = lzr_gamestate.get_state()
|
local gs = lzr_gamestate.get_state()
|
||||||
if gs == lzr_gamestate.LEVEL_COMPLETE or gs == lzr_gamestate.LEVEL_TEST then
|
if gs == lzr_gamestate.LEVEL_COMPLETE or gs == lzr_gamestate.LEVEL_TEST then
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user