Be more defensive in the recalc function (#16)

master
Oversword 2021-08-10 19:50:26 +01:00 committed by GitHub
parent ed795a1dc6
commit 93d0c8053d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -249,11 +249,20 @@ local function recalc_light(pos)
-- If the light level has changed, set the coresponding light node and initiate the cleanup timer
if old_value ~= max_light then
local node_name = lightable_nodes[name] and name or lighting_nodes[name].node
minetest.swap_node(pos_vec, {
name = lightable_nodes[node_name][max_light]
})
minetest.get_node_timer(pos_vec):start(cleanup_interval)
local node_name
if lightable_nodes[name] then
node_name = name
elseif lighting_nodes[name] then
node_name = lighting_nodes[name].node
end
if node_name then
minetest.swap_node(pos_vec, {
name = lightable_nodes[node_name][max_light]
})
minetest.get_node_timer(pos_vec):start(cleanup_interval)
else
active_lights[pos] = nil
end
end
end