Add playfield check

master
Wuzzy 2021-12-28 04:31:46 +01:00
parent ee05696fd7
commit 6a4f6926f9
1 changed files with 6 additions and 0 deletions

View File

@ -4,6 +4,12 @@ local MAX_LASER_ITERATIONS = 10000
-- Add a laser node to pos with the direction `dir`.
-- Dir is a direction vector, and only one direction must be set
function lzr_laser.add_laser(pos, dir)
-- Check if laser is still within the playfield
if pos.x < lzr_globals.PLAYFIELD_START.x or pos.x > lzr_globals.PLAYFIELD_END.x or
pos.y < lzr_globals.PLAYFIELD_START.y or pos.y > lzr_globals.PLAYFIELD_END.y or
pos.z < lzr_globals.PLAYFIELD_START.z or pos.z > lzr_globals.PLAYFIELD_END.z then
return false
end
local node = minetest.get_node(pos)
-- Laser through air
if node.name == "air" then