sorcery  Diff

Differences From Artifact [021fb6f980]:

To Artifact [2352fa593a]:


    58     58   	minetest.load_area(
    59     59   		vector.add(pos, {x =  5, y =  1 + constants.portal_max_height, z =  5}),
    60     60   		vector.add(pos, {x = -5, y = -1 - constants.portal_max_height, z = -5})
    61     61   	)
    62     62   	-- starting at a portal node, search connected blocks
    63     63   	-- recursively to locate portal pads and their paired
    64     64   	-- partners. return a table characterizing the portal
    65         -	-- return false if no portal found
           65  +	-- or return false if no portal found
    66     66   	
    67     67   	-- first search immediate neighbors. the portal node
    68     68   	-- can be connected to either reflectors or pads
    69     69   	local startpoint, startwithpads
    70     70   	for _, d in pairs(sorcery.lib.node.offsets.neighbors) do
    71     71   		local sum = vector.add(pos,d)
    72     72   		local name = minetest.get_node(sum).name
................................................................................
   158    158   		for _, d in pairs(n.caps.net.devices.consume) do
   159    159   			if d.id == 'sorcery:portal_node' and portal_composition(d.pos) then
   160    160   				circuit[#circuit+1] = {
   161    161   					pos = d.pos;
   162    162   					hops = n.hops;
   163    163   					route = n.route;
   164    164   				}
   165         -				print(' ! found portal node',d.pos)
   166         -			else
   167         -				print('   -- skipping node',d.pos,d.id)
   168    165   			end
   169    166   		end
   170    167   	end
   171    168   	return circuit
   172    169   end
   173    170   
   174    171   local portal_disposition = function(dev)
................................................................................
   288    285   		local tune = sorcery.attunement.verify(pos)
   289    286   		local partner -- raw position of partner node, if any
   290    287   		if tune and tune.partner then
   291    288   			minetest.load_area(tune.partner)
   292    289   			-- we are attuned to a partner, but is it in the circuit?
   293    290   			for _,v in pairs(crc) do
   294    291   				if vector.equals(v.pos,tune.partner) then
   295         -					print('found partner in circuit')
   296    292   					partner = tune.partner
   297    293   					break
   298    294   				end
   299    295   			end
   300    296   		end
   301    297   
   302         -		print("power reqs",cap.self.minpower,cap.self.powerdraw)
   303    298   		if cap.self.minpower ~= cap.self.powerdraw then
   304    299   			print("not enough power")
   305    300   			return true
   306    301   		end
   307    302   
   308    303   		-- clean out user table
   309    304   		for name,user in pairs(portal_context.users) do
................................................................................
   330    325   					local user = portal_context.users[pname]
   331    326   					if not vector.equals(pos,user.portal) then
   332    327   						user.time = 0
   333    328   						user.portal = pos
   334    329   					end
   335    330   					local cap = sorcery.ley.netcaps(pos,delta)
   336    331   					local jc = (constants.portal_jump_cost_local*delta)
   337         -					print('free power',cap.freepower,jc)
   338    332   					if not user.dest and cap.freepower >= jc  then
   339    333   						user.dest = portal_pick_destination(dev,crc,partner)
   340         -					else
   341         -						print('powerdraw',cap.self.powerdraw)
   342    334   					end
   343    335   					if not user.dest then goto skippad else
   344    336   						minetest.load_area(user.dest)
   345    337   					end
   346    338   					local fac = (user.time / constants.portal_jump_time);
   347    339   					minetest.add_particlespawner {
   348    340   						time = 1, amount = 100 + (fac * 200);
................................................................................
   444    436   			mode = 'consume', affinity = {'mandatic'};
   445    437   			power = function(pos,delta)
   446    438   				-- return power use if device is currently in process
   447    439   				-- of teleporting a player; otherwise, return 0
   448    440   				local cost = constants.portal_node_power
   449    441   				for _,u in pairs(portal_context.users) do
   450    442   					if u.dest and vector.equals(u.portal, pos) then
   451         -						print('user is on pad',dump(pos))
   452    443   						cost = cost + constants.portal_jump_cost_local
   453    444   					end
   454    445   				end
   455    446   				return cost * delta
   456    447   			end;
   457    448   		};
   458    449