mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-22 15:18:02 +02:00
added effect right-click a block
This commit is contained in:
parent
b60d5b03d0
commit
286a83af8c
@ -403,6 +403,8 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
|
||||
"block: Not loaded (nil) at pos "..pos_str..".")
|
||||
return false
|
||||
end
|
||||
-- TODO: add a blacklist of nodes that shall not be used this way
|
||||
-- TODO: if node has owner set: check if owner == npc owner
|
||||
-- "If there is air: Place a block so that it looks like now.", -- 2
|
||||
if(r.r_value and r.r_value == "place") then
|
||||
if(is_protected) then
|
||||
@ -478,7 +480,31 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
|
||||
return true
|
||||
-- "Right-click the block.", -- 5
|
||||
elseif(r.r_value and r.r_value == "right-click") then
|
||||
if(not(node) or not(node.name) or not(minetest.registered_nodes[node.name])) then
|
||||
return false
|
||||
end
|
||||
-- TODO: do not right-click nodes that have a metadata formspec string
|
||||
-- TODO: do not right-click nodes that have an inventory (they most likely show a formspec - which the NPC can't use anyway)
|
||||
-- is it a door?
|
||||
if(doors.registered_doors[node.name]) then
|
||||
doors.door_toggle( r.r_pos, node, nil) --, clicker)
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"block: Opened/closed door at "..pos_str..".")
|
||||
-- is it a normal trapdoor?
|
||||
elseif(doors.registered_trapdoors[node.name]) then
|
||||
doors.trapdoor_toggle(r.r_pos, node, nil) --, clicker)
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"block: Opened/closed trapdoor at "..pos_str..".")
|
||||
-- TODO: not sure if right-clicking a block (as an npc) is possible without bugs
|
||||
elseif(minetest.registered_nodes[node.name]
|
||||
and minetest.registered_nodes[node.name].on_rightclick(r.r_pos, node, nil)) then
|
||||
minetest.registered_nodes[node.name].on_rightclick(r.r_pos, node, nil)
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"block: right-clicked at at pos "..pos_str..".")
|
||||
else
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"block: right-click at at pos "..pos_str.." had no effect.")
|
||||
end
|
||||
end
|
||||
return false
|
||||
-- ""NPC crafts soemthing", -- 4
|
||||
|
Loading…
Reference in New Issue
Block a user