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
76
77
78
79
80
81














82
83
84
85
86
87
88
89
90
91
92
93
94
	set = function(node,tune)
		local meta = minetest.get_meta(node)
		meta:set_string('sorcery:attune', sorcery.attunement.encode(tune))
		meta:mark_as_private('sorcery:attune')
	end;
	pair = function(reciprocal,src,dest)
		local d, code = sorcery.attunement.get(src)














		if reciprocal or not d then
			code = math.random(0,65536)
			sorcery.attunement.set(src, {
				code = code;
				partner = dest;
			})
		else code = d.code end
		sorcery.attunement.set(dest, {
			code = code;
			partner = src;
		})
	end;
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>













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

		local dsrc, dtgt = gdef(src), gdef(tgt)
		if not (dsrc and dtgt) then return nil end

		if not (dsrc.source and dtgt.target) then return nil end
		if dtgt.accepts ~= dsrc.class then return nil end
		
		if reciprocal or not d then
			code = math.random(0,65536)
			sorcery.attunement.set(src, {
				code = code;
				partner = dest;
			})
		else code = d.code end
		sorcery.attunement.set(dest, {
			code = code;
			partner = src;
		})
	end;
}