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;
}
|