defer to the target node's on_rightclick, if defined
This commit is contained in:
parent
38eb8b8f59
commit
41625bdf6f
8
init.lua
8
init.lua
@ -8,6 +8,14 @@ streetlights.concrete = "basic_materials:concrete_block"
|
||||
streetlights.distributor = "streets:digiline_distributor"
|
||||
streetlights.vert_digiline = "digistuff:vertical_bottom"
|
||||
|
||||
function streetlights.rightclick_pointed_thing(pos, placer, itemstack, pointed_thing)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if not node then return false end
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if not def or not def.on_rightclick then return false end
|
||||
return def.on_rightclick(pos, node, placer, itemstack, pointed_thing) or itemstack
|
||||
end
|
||||
|
||||
dofile(modpath.."/simple.lua")
|
||||
if minetest.get_modpath("homedecor_lighting") and minetest.get_modpath("streetspoles") then
|
||||
dofile(modpath.."/minedot.lua")
|
||||
|
19
simple.lua
19
simple.lua
@ -69,10 +69,7 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa
|
||||
local controls = placer:get_player_control()
|
||||
if not placer then return end
|
||||
local playername = placer:get_player_name()
|
||||
if not minetest.check_player_privs(placer, "streetlight") then
|
||||
minetest.chat_send_player(playername, "*** You don't have permission to use a streetlight spawner.")
|
||||
return
|
||||
end
|
||||
|
||||
local player_name = placer:get_player_name()
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
|
||||
@ -81,14 +78,18 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa
|
||||
if not node1 or node1.name == "ignore" then return end
|
||||
local def1 = minetest.registered_items[node1.name]
|
||||
|
||||
print(dump(pos1))
|
||||
print(node1.name)
|
||||
print(dump(def1))
|
||||
|
||||
|
||||
if (def1 and def1.buildable_to) then
|
||||
pos1.y = pos1.y-1
|
||||
end
|
||||
|
||||
local rc = streetlights.rightclick_pointed_thing(pos1, placer, itemstack, pointed_thing)
|
||||
if rc then return rc end
|
||||
|
||||
if not minetest.check_player_privs(placer, "streetlight") then
|
||||
minetest.chat_send_player(playername, "*** You don't have permission to use a streetlight spawner.")
|
||||
return
|
||||
end
|
||||
|
||||
local node1 = minetest.get_node(pos1)
|
||||
|
||||
local node2, node3, node4
|
||||
|
Loading…
x
Reference in New Issue
Block a user