Bugfixes and Improvments

This commit is contained in:
Extex101 2021-10-25 17:56:31 -07:00 committed by GitHub
parent b0927884ed
commit e4ea1c1a59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,12 @@ light_tool.light_beam = function(pos, dir, range)
for i = 0, math.floor(range / vector.length(normalized_dir)) do
local new_pos = vector.add(pos, vector.multiply(normalized_dir, i))
local node = minetest.get_node(new_pos)
local node = minetest.get_node_or_nil(new_pos)
if not node or not node.name then
return
end
local def = minetest.registered_nodes[node.name]
if not def then return end
local lightable = light_tool.check(light_tool.lightable_nodes, node.name)
local lightable_index = light_tool.check_index(light_tool.lightable_nodes, node.name)
local lit = light_tool.check(light_tool.lit_nodes, node.name)
@ -25,7 +30,7 @@ light_tool.light_beam = function(pos, dir, range)
local index = light_tool.check_index(light_tool.lightable_nodes, node.name)
minetest.set_node(new_pos, {name = light_tool.lightable_nodes[index].."_glowing"})
elseif node.name and minetest.registered_nodes[node.name].sunlight_propagates == false and not lightable and not lit then
elseif def and def.sunlight_propagates == false and not lightable and not lit then
break
end
end