sorcery  Diff

Differences From Artifact [7144dd8474]:

To Artifact [b1f018643d]:

  • File lib/node.lua — part of check-in [96c5289a2a] at 2020-10-21 03:35:35 on branch trunk — add rune forges, runes, amulet frames, write sacrifice spell, touch up amulet graphics, enable enchantment of amulets (though spells cannot yet be cast), defuckulate syncresis core icon, unfuckitize sneaky leycalc bug that's probably been the cause of some long-standing wackiness, add item classes, add some more textures, disbungle various other asstastrophes, remove sneaky old debug code, improve library code, add utility for uploading merge requests (user: lexi, size: 4220) [annotate] [blame] [check-ins using]

    35     35   		{x =  0, y =  0, z = -1};
    36     36   	};
    37     37   }
    38     38   
    39     39   ofs.adjoining = sorcery.lib.tbl.append(sorcery.lib.tbl.append(
    40     40   	ofs.neighbors,ofs.planecorners),ofs.cubecorners)
    41     41   
    42         -return {
    43         -	offsets = ofs;
    44         -	purge_container = function(pos,node,meta,user)
    45         -		local offset = function(pos,range)
    46         -			local r = function(min,max)
    47         -				return (math.random() * (max - min)) + min
    48         -			end
    49         -			return {
    50         -				x = pos.x + r(0 - range, range);
    51         -				y = pos.y;
    52         -				z = pos.z + r(0 - range, range);
    53         -			}
           42  +local purge_container = function(only, pos,node,meta,user)
           43  +	local offset = function(pos,range)
           44  +		local r = function(min,max)
           45  +			return (math.random() * (max - min)) + min
    54     46   		end
    55         -		for name, inv in pairs(meta.inventory) do
    56         -			for _, item in pairs(inv) do
    57         -				if not item:is_empty() then
    58         -					minetest.add_item(offset(pos,0.4), item)
    59         -				end
           47  +		return {
           48  +			x = pos.x + r(0 - range, range);
           49  +			y = pos.y;
           50  +			z = pos.z + r(0 - range, range);
           51  +		}
           52  +	end
           53  +	for name, inv in pairs(meta.inventory) do
           54  +		if only and not sorcery.lib.tbl.has(only,name) then goto skip end
           55  +		for _, item in pairs(inv) do
           56  +			if not item:is_empty() then
           57  +				minetest.add_item(offset(pos,0.4), item)
    60     58   			end
    61     59   		end
    62         -	end;
           60  +	::skip::end
           61  +end;
           62  +return {
           63  +	offsets = ofs;
           64  +	purge_container = function(...) return purge_container(nil, ...) end;
           65  +	purge_only = function(lst)
           66  +		return function(...)
           67  +			return purge_container(lst, ...)
           68  +		end
           69  +	end; 
    63     70   
    64     71   	amass = function(startpoint,names,directions)
    65     72   		if not directions then directions = ofs.neighbors end
    66     73   		local nodes, positions, checked = {},{},{}
    67     74   		local checkedp = function(pos)
    68     75   			for _,v in pairs(checked) do
    69     76   				if vector.equals(pos,v) then return true end
................................................................................
   115    122   		minetest.load_area(pos)
   116    123   		return minetest.get_node(pos)
   117    124   	end;
   118    125   
   119    126   	-- when items have already been removed; notify cannot be relied on
   120    127   	-- to reach the entire network; this function accounts for the gap
   121    128   	notifyneighbors = function(pos)
   122         -		sorcery.lib.node.forneighbor(pos, sorcery.ley.txofs, function(pos,node)
          129  +		sorcery.lib.node.forneighbor(pos, sorcery.ley.txofs, function(sum,node)
   123    130   			if minetest.get_item_group(node.name,'sorcery_ley_device') ~= 0 then
   124    131   				sorcery.ley.notify(sum)
   125    132   			end
   126    133   		end)
   127    134   	end;
   128    135   
   129    136   	blockpos = function(pos)