61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
-- complex algorithms that cut across namespaces or don't belong anywhere else
alg = {};
region = {
radiator = {
store = AreaStore();
emitters = {};
};
};
-- standardized effects
fx = {};
type = {};
................................................................................
if not chunk then error(err) end
return chunk(...)
end
function starlit.include(name, ...) -- semantic variant used for loading modules
return starlit.evaluate(name..'.lua', ...)
end
minetest.register_lbm {
label = 'build radiator index';
name = 'starlit:loadradiatorboxes';
nodenames = {'group:radiator'};
run_at_every_load = true;
action = function(pos, node, dt)
local R = starlit.region
local phash = minetest.hash_node_position(pos)
if R.radiator.sources[phash] then return end -- already loaded
local def = minetest.registered_nodes[node.name]
local cl = def._starlit.radiator
local min,max = cl.maxEffectArea(pos)
local id = R.radiator.store:insert_area(min,max, minetest.pos_to_string(pos))
R.radiator.sources[phash] = id
end;
-- NOTE: temp emitter nodes are responsible for decaching themselves in their on_destruct cb
}
function starlit.startJob(id, interval, job)
local lastRun
local function start()
starlit.jobs[id] = minetest.after(interval, function()
local t = minetest.get_gametime()
local d = lastRun and t - lastRun or nil
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<
<
<
<
>
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
-- complex algorithms that cut across namespaces or don't belong anywhere else
alg = {};
region = {
radiator = {
store = AreaStore();
sources = {};
};
};
-- standardized effects
fx = {};
type = {};
................................................................................
if not chunk then error(err) end
return chunk(...)
end
function starlit.include(name, ...) -- semantic variant used for loading modules
return starlit.evaluate(name..'.lua', ...)
end
function starlit.region.radiator.scan(pos,node)
local R = starlit.region
local phash = minetest.hash_node_position(pos)
if R.radiator.sources[phash] then return end -- already loaded
node = node or minetest.get_node(pos)
local def = minetest.registered_nodes[node.name]
local cl = def._starlit and def._starlit.radiator
if not cl then return nil end
local min,max = cl.maxEffectArea and cl.maxEffectArea(pos) or nil
if not min then
assert(cl.radius, 'no radius callback for radiator')
local r = cl.radius(pos)
local vr = vector.new(r,r,r)
min,max = pos-vr, pos+vr
end
local id = R.radiator.store:insert_area(min,max, minetest.pos_to_string(pos))
R.radiator.sources[phash] = id
end
function starlit.region.radiator.unload(pos)
local R = starlit.region
local phash = minetest.hash_node_position(pos)
local id = R.radiator.sources[phash]
R.radiator.store:remove_area(id)
R.radiator.sources[phash] = nil
end
minetest.register_lbm {
label = 'build radiator index';
name = 'starlit:loadradiatorboxes';
nodenames = {'group:radiator'};
run_at_every_load = true;
action = function(pos, node, dt)
starlit.region.radiator.scan(pos, node)
end;
-- NOTE: temp emitter nodes are responsible for decaching themselves in their on_destruct cb
}
function starlit.startJob(id, interval, job)
local lastRun
local function start()
starlit.jobs[id] = minetest.after(interval, function()
local t = minetest.get_gametime()
local d = lastRun and t - lastRun or nil
|