Differences From
Artifact [3ea00fa42e]:
64 64 local slot_ingot = inv:get_stack('ingot',1)
65 65 local slot_gem = inv:get_stack('gem',1)
66 66 local metalname, gemname
67 67 local coincount
68 68 if not inv:is_empty('ingot') then
69 69 local id = slot_ingot:get_name()
70 70 for name,metal in pairs(sorcery.data.metals) do
71 - if id == metal.parts.ingot then
71 + if id == metal.parts.ingot or
72 + id == minetest.registered_aliases[metal.parts.ingot] then
72 73 metalname = name
73 74 coincount = slot_ingot:get_count()
74 75 goto foundmetal
75 76 end
76 77 end
77 78 end
78 79 inv:set_stack('output',1,ItemStack(nil))
................................................................................
146 147 listring[current_player;main]
147 148 ]])
148 149 end;
149 150 allow_metadata_inventory_put = function(pos,list,idx,stack,user)
150 151 local id = stack:get_name()
151 152 if list == 'ingot' then
152 153 for name,metal in pairs(sorcery.data.metals) do
153 - if id == metal.parts.ingot then goto okay end
154 + if id == metal.parts.ingot or
155 + id == minetest.registered_aliases[metal.parts.ingot]
156 + then goto okay end
154 157 end
155 158 elseif list == 'gem' then
156 159 for name,gem in pairs(sorcery.data.gems) do
157 160 if gem.foreign then
158 - if id == gem.foreign then goto okay end
161 + if id == gem.foreign or
162 + id == minetest.registered_aliases[gem.foreign]
163 + then goto okay end
159 164 else
160 165 if id == 'sorcery:gem_' .. name then goto okay end
161 166 end
162 167 end
163 168 end
164 169 do return 0 end
165 170 ::okay:: return max_components
................................................................................
179 184 on_metadata_inventory_take = function(pos,list,idx,stack,user)
180 185 local meta = minetest.get_meta(pos)
181 186 if list == 'output' then
182 187 local items_used = math.floor(stack:get_count() / coins_per_ingot)
183 188 local inv = meta:get_inventory()
184 189 local reduce_slot = function(slot)
185 190 local i = inv:get_stack(slot,1)
191 + local s = i:get_name()
186 192 i:take_item(items_used) inv:set_stack(slot,1,i)
193 + if slot == 'gem' then
194 + for k,v in pairs(sorcery.data.gems) do
195 + if v.parts.item == s then
196 + local repl = ItemStack {
197 + name = v.parts.shard;
198 + count = items_used;
199 + }
200 + u.node.insert(repl, 'gem', pos, user, inv)
201 + break
202 + end
203 + end
204 + end
187 205 end
188 206 reduce_slot('ingot')
189 207 if not inv:is_empty('gem') then reduce_slot('gem') end
190 208 minetest.sound_play('sorcery_coins', { pos = pos, gain = 0.7 })
191 209 end
192 210 update_press_output(meta)
193 211 end;