Fix biactive lens instability.

When lenses face one another and are each fed light to
become active, they now prefer the active state over the
shining state.

Interestingly, inline vs. angled configurations have different
numbers of stable configurations...
This commit is contained in:
Aaron Suen 2019-11-23 08:52:12 -05:00
parent fc2d139e9f
commit a208893e07
2 changed files with 16 additions and 9 deletions

View File

@ -9,9 +9,6 @@ ISSUES: Bugs, Cleanup and Refinements
# # # # # # # # # # # #
#### # #### # ###### ###### # # ####
- Active lenses facing each other go apeshit.
- They also totally bog the game down with lighting recalcs.
- Optics should be blockable by things in item form.
- If sunlight_propagates on the node, and it's groups.visinv,
then also check sunlight_propagates of the item def if the

View File

@ -8,16 +8,21 @@ local modname = minetest.get_current_modname()
local function lens_check(pos, node, check)
local face = nodecore.facedirs[node.param2]
if check(face.k) then
local backfed = check(face.k)
if backfed and node.name == modname .. ":lens" then
return modname .. ":lens_glow"
end
local fore = vector.add(pos, face.f)
local on
if face.f.y == 1 then
local ll = minetest.get_node_light(fore)
if not ll then return end
if ll then
local lt = 15
if node and node.name == modname .. ":lens_on" then lt = 14 end
local on = ll >= lt and face.f.y == 1
on = ll >= lt and face.f.y == 1
end
end
if not on then
local nnode = minetest.get_node(fore)
local def = minetest.registered_items[nnode.name] or {}
@ -26,6 +31,11 @@ local function lens_check(pos, node, check)
if on then
return modname .. ":lens_on", {face.k}
end
if backfed then
return modname .. ":lens_glow"
end
return modname .. ":lens"
end