Differences From
Artifact [3ae145b117]:
69 69 if vector.equals(pos,v) then return true end
70 70 end
71 71 return false
72 72 end
73 73 local i,stack = 1,{startpoint} repeat
74 74 local pos = stack[i]
75 75 local n = minetest.get_node(pos).name
76 + if n == 'ignore' then
77 + minetest.load_area(pos)
78 + n = minetest.get_node(pos).name
79 + end
76 80 if sorcery.lib.tbl.has(names, n) then -- match found
77 81 -- record the find
78 82 nodes[pos] = n
79 83 if positions[n] then positions[n][#positions[n]] = pos
80 84 else positions[n] = {pos} end
81 85
82 86 -- check selected neighbors to see if any need scanning
................................................................................
92 96 until i > #stack
93 97 return nodes, positions
94 98 end;
95 99
96 100 forneighbor = function(pos, n, fn)
97 101 for _,p in pairs(n) do
98 102 local sum = vector.add(pos, p)
99 - fn(sum, minetest.get_node(sum))
103 + local n = minetest.get_node(sum)
104 + if n.name == 'ignore' then
105 + minetest.load_area(sum)
106 + n = minetest.get_node(sum)
107 + end
108 + fn(sum, n)
109 + end
110 + end;
111 +
112 + force = function(pos,preload_for)
113 + local n = minetest.get_node_or_nil(pos)
114 + if n then return n end
115 + if preload_for then
116 + sorcery.lib.node.preload(pos,preload_for)
117 + else
118 + minetest.load_area(pos)
100 119 end
120 + return minetest.get_node(pos)
101 121 end;
102 122
103 123 -- when items have already been removed; notify cannot be relied on
104 124 -- to reach the entire network; this function accounts for the gap
105 125 notifyneighbors = function(pos)
106 126 sorcery.lib.node.forneighbor(pos, sorcery.ley.txofs, function(pos,node)
107 127 if minetest.get_item_group(node.name,'sorcery_ley_device') ~= 0 then
................................................................................
118 138 }
119 139 end;
120 140
121 141 preload = function(pos, user)
122 142 minetest.load_area(pos)
123 143 user:send_mapblock(sorcery.lib.node.blockpos(pos))
124 144 end;
145 +
146 + discharger = function(pos)
147 + local below = sorcery.lib.node.force(vector.subtract(pos,{x=0,y=1,z=0}))
148 + if below.name == 'hopper:hopper'
149 + or below.name == 'hopper:hopper_side' then
150 + local hopper = minetest.get_meta(below):get_inventory()
151 + return function(i)
152 + if hopper:room_for_item('main',i) then
153 + return hopper:add_item('main',i), true
154 + end
155 + return i, false
156 + end
157 + else
158 + return function(i) return i, false end
159 + end
160 + end;
125 161 }