Refactor laser blocks
parent
9f46b215f1
commit
e046d0b1ed
|
@ -34,7 +34,10 @@ local mirror_out = {
|
|||
|
||||
local movement_gravity = tonumber(minetest.settings:get("movement_gravity")) or 9.81
|
||||
|
||||
lzr_laser.get_detector_dir = function(param2)
|
||||
lzr_laser.get_front_dir = function(param2)
|
||||
if not param2 then
|
||||
return
|
||||
end
|
||||
local dir_input = minetest.facedir_to_dir(param2)
|
||||
if not dir_input then
|
||||
return
|
||||
|
@ -44,21 +47,26 @@ lzr_laser.get_detector_dir = function(param2)
|
|||
return dir_input
|
||||
end
|
||||
|
||||
lzr_laser.check_front = function(node_pos, laser_dir)
|
||||
local node = minetest.get_node(node_pos)
|
||||
local node_dir_in = lzr_laser.get_front_dir(node.param2)
|
||||
if not node_dir_in then
|
||||
return false
|
||||
end
|
||||
local reverse_laser_dir = vector.multiply(laser_dir, -1)
|
||||
if vector.equals(reverse_laser_dir, node_dir_in) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
lzr_laser.check_detector = function(detector_pos, laser_dir)
|
||||
local detector = minetest.get_node(detector_pos)
|
||||
local detector_group = minetest.get_item_group(detector.name, "detector")
|
||||
if detector_group == 0 then
|
||||
return false
|
||||
end
|
||||
local reverse_laser_dir = vector.multiply(laser_dir, -1)
|
||||
local detector_dir_in = lzr_laser.get_detector_dir(detector.param2)
|
||||
if not detector_dir_in then
|
||||
return false
|
||||
end
|
||||
if vector.equals(reverse_laser_dir, detector_dir_in) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return lzr_laser.check_front(detector_pos, laser_dir)
|
||||
end
|
||||
|
||||
lzr_laser.get_mirror_dirs = function(param2)
|
||||
|
|
Loading…
Reference in New Issue