sorcery  Diff

Differences From Artifact [3ea00fa42e]:

To Artifact [f621f46631]:


64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
...
146
147
148
149
150
151
152
153


154
155
156
157
158


159
160
161
162
163
164
165
...
179
180
181
182
183
184
185

186












187
188
189
190
191
192
193
	local slot_ingot = inv:get_stack('ingot',1)
	local slot_gem   = inv:get_stack('gem',1)
	local metalname, gemname
	local coincount
	if not inv:is_empty('ingot') then
		local id = slot_ingot:get_name()
		for name,metal in pairs(sorcery.data.metals) do
			if id == metal.parts.ingot then

				metalname = name
				coincount = slot_ingot:get_count()
				goto foundmetal
			end
		end
	end
	inv:set_stack('output',1,ItemStack(nil))
................................................................................
					listring[current_player;main]
		]])
	end;
	allow_metadata_inventory_put = function(pos,list,idx,stack,user)
		local id = stack:get_name()
		if list == 'ingot' then
			for name,metal in pairs(sorcery.data.metals) do
				if id == metal.parts.ingot then goto okay end


			end
		elseif list == 'gem' then
			for name,gem in pairs(sorcery.data.gems) do
				if gem.foreign then
					if id == gem.foreign then goto okay end


				else
					if id == 'sorcery:gem_' .. name then goto okay end
				end
			end
		end
		do return 0 end
		::okay:: return max_components
................................................................................
	on_metadata_inventory_take = function(pos,list,idx,stack,user)
		local meta = minetest.get_meta(pos)
		if list == 'output' then
			local items_used = math.floor(stack:get_count() / coins_per_ingot)
			local inv = meta:get_inventory()
			local reduce_slot = function(slot)
				local i = inv:get_stack(slot,1)

				i:take_item(items_used) inv:set_stack(slot,1,i)












			end
			reduce_slot('ingot')
			if not inv:is_empty('gem') then reduce_slot('gem') end
			minetest.sound_play('sorcery_coins', { pos = pos, gain = 0.7 })
		end
		update_press_output(meta)
	end;







|
>







 







|
>
>




|
>
>







 







>

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







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