139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
}
local rune_set = function(stack,r)
local m = stack:get_meta()
local def = stack:get_definition()._proto.data
local grade
if r.grade then grade = r.grade
elseif m:contains('rune_grade') then grade = m:get_int('rune_grade') end
local qpfx = constants.rune_grades[grade]
local title = sorcery.lib.color(def.tone):readable():fmt(string.format('%s %s Rune',qpfx,def.name))
m:set_int('rune_grade',grade)
m:set_string('description',title)
end
sorcery.amulet = {}
sorcery.amulet.setrune = function(stack,rune,user)
local m = stack:get_meta()
if rune then
local rp = rune:get_definition()._proto
local rg = rune:get_meta():get_int('rune_grade')
m:set_string('amulet_rune', rp.id)
m:set_int('amulet_rune_grade', rg)
local spell = sorcery.amulet.getspell(stack)
if not spell then return nil end
local name
if spell.mingrade and spell.mingrade > 0 then -- indicating quality makes less sense if it's restricted
name = string.format('Amulet of %s', spell.name)
................................................................................
local wear = 65535 / wrench.powers[cap]
s:add_wear(wear)
inv:set_stack('wrench',1,s)
end
if fl == 'active' then
inv:set_stack('amulet',1,sorcery.amulet.setrune(inv:get_stack('amulet',1),nil,user))
-- only special wrenches can extract runes intact
if wrench.powers.extract then wwear('extract')
minetest.sound_play('sorcery_chime', { pos = pos, gain = 0.5 })
elseif wrench.powers.purge then wwear('purge')
inv:set_stack(tl,ti,ItemStack(nil))
minetest.sound_play('sorcery_disjoin', { pos = pos, gain = 0.5 })
end
elseif tl == 'active' and wrench.powers.imbue then
local amulet = sorcery.amulet.setrune(inv:get_stack('amulet',1), inv:get_stack(tl,ti), user)
local spell = sorcery.amulet.getspell(amulet)
sorcery.vfx.enchantment_sparkle({
under = pos;
above = vector.add(pos,{x=0,y=1,z=0});
}, spell.tone:brighten(1.2):hex())
minetest.sound_play('xdecor_enchanting', { pos = pos, gain = 0.5 })
inv:set_stack('amulet',1,amulet)
wwear('imbue')
end
-- trigger the update early to clean up the ghost image :/
-- minetest needs a cleaner way to handle these
runeforge_update(pos)
end;
on_metadata_inventory_put = function(pos, list, idx, stack, user)
local inv = minetest.get_meta(pos):get_inventory()
|
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
}
local rune_set = function(stack,r)
local m = stack:get_meta()
local def = stack:get_definition()._proto.data
local grade
if r.grade then grade = r.grade
elseif m:contains 'rune_grade' then grade = m:get_int 'rune_grade' end
local qpfx = constants.rune_grades[grade]
local title = sorcery.lib.color(def.tone):readable():fmt(string.format('%s %s Rune',qpfx,def.name))
m:set_int('rune_grade',grade)
m:set_string('description',title)
end
sorcery.amulet = {}
sorcery.amulet.setrune = function(stack,rune,user)
local m = stack:get_meta()
if rune then
local rp = rune:get_definition()._proto
local rg = rune:get_meta():get_int 'rune_grade'
m:set_string('amulet_rune', rp.id)
m:set_int('amulet_rune_grade', rg)
local spell = sorcery.amulet.getspell(stack)
if not spell then return nil end
local name
if spell.mingrade and spell.mingrade > 0 then -- indicating quality makes less sense if it's restricted
name = string.format('Amulet of %s', spell.name)
................................................................................
local wear = 65535 / wrench.powers[cap]
s:add_wear(wear)
inv:set_stack('wrench',1,s)
end
if fl == 'active' then
inv:set_stack('amulet',1,sorcery.amulet.setrune(inv:get_stack('amulet',1),nil,user))
-- only special wrenches can extract runes intact
if wrench.powers.extract then wwear 'extract'
minetest.sound_play('sorcery_chime', { pos = pos, gain = 0.5 })
elseif wrench.powers.purge then wwear 'purge'
inv:set_stack(tl,ti,ItemStack(nil))
minetest.sound_play('sorcery_disjoin', { pos = pos, gain = 0.5 })
end
elseif tl == 'active' and wrench.powers.imbue then
local amulet = sorcery.amulet.setrune(inv:get_stack('amulet',1), inv:get_stack(tl,ti), user)
local spell = sorcery.amulet.getspell(amulet)
sorcery.vfx.enchantment_sparkle({
under = pos;
above = vector.add(pos,{x=0,y=1,z=0});
}, spell.tone:brighten(1.2):hex())
minetest.sound_play('xdecor_enchanting', { pos = pos, gain = 0.5 })
inv:set_stack('amulet',1,amulet)
wwear 'imbue'
end
-- trigger the update early to clean up the ghost image :/
-- minetest needs a cleaner way to handle these
runeforge_update(pos)
end;
on_metadata_inventory_put = function(pos, list, idx, stack, user)
local inv = minetest.get_meta(pos):get_inventory()
|