sorcery  Diff

Differences From Artifact [2352fa593a]:

To Artifact [5fb5b13994]:


   212    212   
   213    213   local portal_destination_evaluate = function(circuit,pos)
   214    214   	-- evaluation of the local network occurs before this function
   215    215   	-- is ever even called, so we only need to worry about the
   216    216   	-- farcaster-related transmission costs
   217    217   	for i,c in pairs(circuit) do
   218    218   		if vector.equals(c.pos,pos) then
   219         -			print('found destination in circuit table',i,dump(c))
   220    219   			-- the destination is listed in the circuit table
   221    220   			for j,r in pairs(c.route) do
   222    221   				local nc = sorcery.ley.netcaps(pos,1)
   223         -				print('checking route for sufficient energy to power farcasters', j, nc.freepower)
          222  +				-- print('checking route for sufficient energy to power farcasters', j, nc.freepower)
   224    223   				if nc.freepower < constants.portal_jump_cost_per_farcaster then
   225    224   					return false -- only one route to any given portal node
   226    225   					-- will be listed in the circuit table, so bail early
   227    226   					-- maybe in the future farcasters should charge up,
   228    227   					-- and power should be deducted when they are used?
   229    228   				end
   230    229   			end
................................................................................
   234    233   		end
   235    234   	end
   236    235   	return false
   237    236   end
   238    237   
   239    238   local portal_pick_destination = function(dev,circuit,partner)
   240    239   	if partner then
   241         -		print('paired: evaluating partner')
   242    240   		if portal_destination_evaluate(circuit,partner)
   243    241   			then return partner end
   244         -		print('partner failed eval')
   245    242   	end
   246    243   
   247    244   	local scrambled = sorcery.lib.tbl.scramble(circuit)
   248    245   	for i=1,#scrambled do
   249         -		print('evaluating destination',i,dump(scrambled[i]))
   250    246   		if portal_destination_evaluate(circuit,scrambled[i].pos)
   251    247   			then return scrambled[i].pos end
   252         -		print('eval failed')
   253    248   	end
   254         -	print('no viable destinations in net')
   255    249   end
   256    250   
   257    251   -- minetest.register_lbm {
   258    252   -- 	name = 'sorcery:activate_portals';
   259    253   -- 	label = 'activate portals';
   260    254   -- 	run_at_every_load = true;
   261    255   -- 	nodenames = { 'sorcery:portal_node' };
................................................................................
   292    286   					partner = tune.partner
   293    287   					break
   294    288   				end
   295    289   			end
   296    290   		end
   297    291   
   298    292   		if cap.self.minpower ~= cap.self.powerdraw then
   299         -			print("not enough power")
          293  +			-- print("not enough power")
   300    294   			return true
   301    295   		end
   302    296   
   303    297   		-- clean out user table
   304    298   		for name,user in pairs(portal_context.users) do
   305    299   			if user and vector.equals(user.portal, pos) then
   306    300   				local found = false
................................................................................
   327    321   						user.time = 0
   328    322   						user.portal = pos
   329    323   					end
   330    324   					local cap = sorcery.ley.netcaps(pos,delta)
   331    325   					local jc = (constants.portal_jump_cost_local*delta)
   332    326   					if not user.dest and cap.freepower >= jc  then
   333    327   						user.dest = portal_pick_destination(dev,crc,partner)
          328  +						sorcery.lib.node.preload(user.dest, u.object)
   334    329   					end
   335         -					if not user.dest then goto skippad else
   336         -						minetest.load_area(user.dest)
   337         -					end
          330  +					if not user.dest then goto skippad end
   338    331   					local fac = (user.time / constants.portal_jump_time);
   339    332   					minetest.add_particlespawner {
   340    333   						time = 1, amount = 100 + (fac * 200);
   341    334   						minsize = 0.2 + fac*0.7, maxsize = 0.4 + fac*0.9;
   342    335   						minvel = {y = 0.2, x=0,z=0}, maxvel = {y = 0.5, x=0,z=0};
   343    336   						minacc = {y = 0.0, x=0,z=0}, maxacc = {y = 0.3, x=0,z=0};
   344    337   						minpos = vector.add(n.pad,{x = -0.5, y = 0.5, z = -0.5});