sorcery  Diff

Differences From Artifact [3bc7b721d2]:

To Artifact [f5a16abef1]:

  • File attunement.lua — part of check-in [ea6e475e44] at 2020-10-19 09:52:11 on branch trunk — continue dev on celestial mechanics, add melding+division spells (resonance), refine itemclasses, add keypunch and punchcards, add paper pulp, add a shitload of visuals, add convenience scripts for working with the wiki, make the flamebolt spell actually useful instead of just a pretty lightshow, add essences, inferno crystal, and other goodies; iterate on wands, lots of shit i can't remember, various bugfixes (user: lexi, size: 3041) [annotate] [blame] [check-ins using]

    75     75   	set = function(node,tune)
    76     76   		local meta = minetest.get_meta(node)
    77     77   		meta:set_string('sorcery:attune', sorcery.attunement.encode(tune))
    78     78   		meta:mark_as_private('sorcery:attune')
    79     79   	end;
    80     80   	pair = function(reciprocal,src,dest)
    81     81   		local d, code = sorcery.attunement.get(src)
           82  +		local gdef = function(n)
           83  +			local m = minetest.registered_nodes[minetest.get_node(n).name]
           84  +			if m and m._sorcery and m._sorcery.attune then
           85  +				return m._sorcery.attune
           86  +			end
           87  +			return nil
           88  +		end
           89  +
           90  +		local dsrc, dtgt = gdef(src), gdef(tgt)
           91  +		if not (dsrc and dtgt) then return nil end
           92  +
           93  +		if not (dsrc.source and dtgt.target) then return nil end
           94  +		if dtgt.accepts ~= dsrc.class then return nil end
           95  +		
    82     96   		if reciprocal or not d then
    83     97   			code = math.random(0,65536)
    84     98   			sorcery.attunement.set(src, {
    85     99   				code = code;
    86    100   				partner = dest;
    87    101   			})
    88    102   		else code = d.code end
    89    103   		sorcery.attunement.set(dest, {
    90    104   			code = code;
    91    105   			partner = src;
    92    106   		})
    93    107   	end;
    94    108   }