sorcery  Diff

Differences From Artifact [f0ca6bd16e]:

To Artifact [5af73c1767]:


54
55
56
57
58
59
60







61
62
63
64
65
66
67
...
162
163
164
165
166
167
168
169
170
171
172
173










174
175
176
177
178
179
180
		if not inv:is_empty('preview') then
			for i=1, inv:get_size('preview') do
				inv:set_stack('preview',i,ItemStack())
			end
		end
		return
	end








	local tech = sorcery.lathe.tooltech(tool)
	local rec = R[wkpc:get_name()][tech]
	tech = sorcery.lathe.techs[tech]

	-- fill in the preview slots
	local j = 1
................................................................................
			else return 0 end
		else return stack:get_count() end
	end;
	on_metadata_inventory_put = sorcery.lathe.update;
	on_metadata_inventory_take = function(pos, list, idx, stack, user)
		if list == 'preview' then
			local l = sorcery.lathe.get(pos,idx,stack:get_count())

			if sorcery.lathe.techs[l.tech].consume then
				l.tool:take_item(l.cost)
			elseif sorcery.lathe.techs[l.tech].dmg then
			--TODO wear down tool










			end
			l.wkpc:take_item(l.qty)
			l.inv:set_stack('tool', 1, l.tool)
			l.inv:set_stack('workpiece', 1, l.wkpc)
			minetest.sound_play('sorcery_clank', { pos = pos, gain = 0.9 })
		end
		sorcery.lathe.update(pos)







>
>
>
>
>
>
>







 







<



|
>
>
>
>
>
>
>
>
>
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
...
169
170
171
172
173
174
175

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
		if not inv:is_empty('preview') then
			for i=1, inv:get_size('preview') do
				inv:set_stack('preview',i,ItemStack())
			end
		end
		return
	end

	local tmat = sorcery.itemclass.get(tool:get_name(),'material')
	local wmat = sorcery.itemclass.get(wkpc:get_name(),'material')
	-- obey level restrictions. TODO honor Rend
	if (wmat and wmat.data.level or 0) > (tmat and (tmat.data.maxlevel or tmat.data.level) or 0) then
		return
	end

	local tech = sorcery.lathe.tooltech(tool)
	local rec = R[wkpc:get_name()][tech]
	tech = sorcery.lathe.techs[tech]

	-- fill in the preview slots
	local j = 1
................................................................................
			else return 0 end
		else return stack:get_count() end
	end;
	on_metadata_inventory_put = sorcery.lathe.update;
	on_metadata_inventory_take = function(pos, list, idx, stack, user)
		if list == 'preview' then
			local l = sorcery.lathe.get(pos,idx,stack:get_count())

			if sorcery.lathe.techs[l.tech].consume then
				l.tool:take_item(l.cost)
			elseif sorcery.lathe.techs[l.tech].dmg then
				local mat = sorcery.itemclass.get(l.tool,'material')
				local mmat = sorcery.itemclass.get(l.wkpc,'metal')
				local dur = 100
				local lfac = 1
				if mat then
					local dur = mat.data.durability or dur
					lfac = (mmat and mmat.data.level or 1) /
						(mat.data.maxlevel or mat.data.level or 1)
				end
				local ch = 65535 / dur
				l.tool:add_wear(4 * ch * l.cost * lfac)
			end
			l.wkpc:take_item(l.qty)
			l.inv:set_stack('tool', 1, l.tool)
			l.inv:set_stack('workpiece', 1, l.wkpc)
			minetest.sound_play('sorcery_clank', { pos = pos, gain = 0.9 })
		end
		sorcery.lathe.update(pos)