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