sorcery  Diff

Differences From Artifact [021fb6f980]:

To Artifact [2352fa593a]:


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
...
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
...
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
	minetest.load_area(
		vector.add(pos, {x =  5, y =  1 + constants.portal_max_height, z =  5}),
		vector.add(pos, {x = -5, y = -1 - constants.portal_max_height, z = -5})
	)
	-- starting at a portal node, search connected blocks
	-- recursively to locate portal pads and their paired
	-- partners. return a table characterizing the portal
	-- return false if no portal found
	
	-- first search immediate neighbors. the portal node
	-- can be connected to either reflectors or pads
	local startpoint, startwithpads
	for _, d in pairs(sorcery.lib.node.offsets.neighbors) do
		local sum = vector.add(pos,d)
		local name = minetest.get_node(sum).name
................................................................................
		for _, d in pairs(n.caps.net.devices.consume) do
			if d.id == 'sorcery:portal_node' and portal_composition(d.pos) then
				circuit[#circuit+1] = {
					pos = d.pos;
					hops = n.hops;
					route = n.route;
				}
				print(' ! found portal node',d.pos)
			else
				print('   -- skipping node',d.pos,d.id)
			end
		end
	end
	return circuit
end

local portal_disposition = function(dev)
................................................................................
		local tune = sorcery.attunement.verify(pos)
		local partner -- raw position of partner node, if any
		if tune and tune.partner then
			minetest.load_area(tune.partner)
			-- we are attuned to a partner, but is it in the circuit?
			for _,v in pairs(crc) do
				if vector.equals(v.pos,tune.partner) then
					print('found partner in circuit')
					partner = tune.partner
					break
				end
			end
		end

		print("power reqs",cap.self.minpower,cap.self.powerdraw)
		if cap.self.minpower ~= cap.self.powerdraw then
			print("not enough power")
			return true
		end

		-- clean out user table
		for name,user in pairs(portal_context.users) do
................................................................................
					local user = portal_context.users[pname]
					if not vector.equals(pos,user.portal) then
						user.time = 0
						user.portal = pos
					end
					local cap = sorcery.ley.netcaps(pos,delta)
					local jc = (constants.portal_jump_cost_local*delta)
					print('free power',cap.freepower,jc)
					if not user.dest and cap.freepower >= jc  then
						user.dest = portal_pick_destination(dev,crc,partner)
					else
						print('powerdraw',cap.self.powerdraw)
					end
					if not user.dest then goto skippad else
						minetest.load_area(user.dest)
					end
					local fac = (user.time / constants.portal_jump_time);
					minetest.add_particlespawner {
						time = 1, amount = 100 + (fac * 200);
................................................................................
			mode = 'consume', affinity = {'mandatic'};
			power = function(pos,delta)
				-- return power use if device is currently in process
				-- of teleporting a player; otherwise, return 0
				local cost = constants.portal_node_power
				for _,u in pairs(portal_context.users) do
					if u.dest and vector.equals(u.portal, pos) then
						print('user is on pad',dump(pos))
						cost = cost + constants.portal_jump_cost_local
					end
				end
				return cost * delta
			end;
		};
		







|







 







<
<
<







 







<






<







 







<


<
<







 







<







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
...
158
159
160
161
162
163
164



165
166
167
168
169
170
171
...
285
286
287
288
289
290
291

292
293
294
295
296
297

298
299
300
301
302
303
304
...
325
326
327
328
329
330
331

332
333


334
335
336
337
338
339
340
...
436
437
438
439
440
441
442

443
444
445
446
447
448
449
	minetest.load_area(
		vector.add(pos, {x =  5, y =  1 + constants.portal_max_height, z =  5}),
		vector.add(pos, {x = -5, y = -1 - constants.portal_max_height, z = -5})
	)
	-- starting at a portal node, search connected blocks
	-- recursively to locate portal pads and their paired
	-- partners. return a table characterizing the portal
	-- or return false if no portal found
	
	-- first search immediate neighbors. the portal node
	-- can be connected to either reflectors or pads
	local startpoint, startwithpads
	for _, d in pairs(sorcery.lib.node.offsets.neighbors) do
		local sum = vector.add(pos,d)
		local name = minetest.get_node(sum).name
................................................................................
		for _, d in pairs(n.caps.net.devices.consume) do
			if d.id == 'sorcery:portal_node' and portal_composition(d.pos) then
				circuit[#circuit+1] = {
					pos = d.pos;
					hops = n.hops;
					route = n.route;
				}



			end
		end
	end
	return circuit
end

local portal_disposition = function(dev)
................................................................................
		local tune = sorcery.attunement.verify(pos)
		local partner -- raw position of partner node, if any
		if tune and tune.partner then
			minetest.load_area(tune.partner)
			-- we are attuned to a partner, but is it in the circuit?
			for _,v in pairs(crc) do
				if vector.equals(v.pos,tune.partner) then

					partner = tune.partner
					break
				end
			end
		end


		if cap.self.minpower ~= cap.self.powerdraw then
			print("not enough power")
			return true
		end

		-- clean out user table
		for name,user in pairs(portal_context.users) do
................................................................................
					local user = portal_context.users[pname]
					if not vector.equals(pos,user.portal) then
						user.time = 0
						user.portal = pos
					end
					local cap = sorcery.ley.netcaps(pos,delta)
					local jc = (constants.portal_jump_cost_local*delta)

					if not user.dest and cap.freepower >= jc  then
						user.dest = portal_pick_destination(dev,crc,partner)


					end
					if not user.dest then goto skippad else
						minetest.load_area(user.dest)
					end
					local fac = (user.time / constants.portal_jump_time);
					minetest.add_particlespawner {
						time = 1, amount = 100 + (fac * 200);
................................................................................
			mode = 'consume', affinity = {'mandatic'};
			power = function(pos,delta)
				-- return power use if device is currently in process
				-- of teleporting a player; otherwise, return 0
				local cost = constants.portal_node_power
				for _,u in pairs(portal_context.users) do
					if u.dest and vector.equals(u.portal, pos) then

						cost = cost + constants.portal_jump_cost_local
					end
				end
				return cost * delta
			end;
		};