Screwdriver support.

This commit is contained in:
number Zero 2017-01-12 00:51:47 +03:00
parent cae64bf499
commit f07d379cb1
2 changed files with 41 additions and 0 deletions

View File

@ -41,6 +41,45 @@ digiline_routing.multiblock.build2 = function(node1, node2, itemstack, placer, p
return itemstack, true
end
digiline_routing.multiblock.rotate2 = function(pos, node, user, mode, new_param2)
local dir = minetest.facedir_to_dir(node.param2)
local p = vector.add(pos, dir)
local node2 = minetest.get_node_or_nil(p)
if not node2 or not node.param2 == node2.param2 then
return false
end
if minetest.is_protected(p, user:get_player_name()) then
minetest.record_protection_violation(p, user:get_player_name())
return false
end
if mode ~= screwdriver.ROTATE_FACE then
return false
end
local newp = vector.add(pos, minetest.facedir_to_dir(new_param2))
local node3 = minetest.get_node_or_nil(newp)
local node_def = node3 and minetest.registered_nodes[node3.name]
if not node_def or not node_def.buildable_to then
return false
end
if minetest.is_protected(newp, user:get_player_name()) then
minetest.record_protection_violation(newp, user:get_player_name())
return false
end
node.param2 = new_param2
minetest.set_node(p, {name = "air"})
minetest.set_node(pos, node)
minetest.set_node(newp, {name = node2.name, param2 = new_param2})
digiline:update_autoconnect(p)
digiline:update_autoconnect(pos)
digiline:update_autoconnect(newp)
return true
end
digiline_routing.multiblock.rotate2b = function(pos, node, user, mode, new_param2)
minetest.log("action", ("%s tries to rotate invisible node at %s"):format(user:get_player_name(), minetest.pos_to_string(pos)))
return false
end
local removing_head = false
digiline_routing.multiblock.dig2 = function(pos, node)

View File

@ -90,6 +90,7 @@ minetest.register_node("digiline_routing:splitter", {
},
on_place = splitter_place,
after_destruct = splitter_cleanup,
on_rotate = digiline_routing.multiblock.rotate2,
digiline = {
effector = {
action = splitter_in_action,
@ -118,6 +119,7 @@ minetest.register_node("digiline_routing:splitter_b", {
},
drop = "",
after_destruct = digiline_routing.multiblock.dig2b,
on_rotate = digiline_routing.multiblock.rotate2b,
digiline = {
effector = {
action = splitter_out_action,