sorcery  Diff

Differences From Artifact [6c01c64259]:

To Artifact [0b21397e89]:


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
end

local elixir_can_apply = function(elixir, potion)
	-- accepts an elixir def and potion def
	if elixir        == nil or
	   potion        == nil then return false end

	if elixir.apply and potion.on_use then
		-- the ingredient is an elixir and at least one potion
		-- is a fully enchanted, usable potion
		if elixir.flag and potion._proto and
		   potion._proto['no_' .. elixir.flag] == true then
			-- does the elixir have a property used to denote
			-- compatibility? if so, check the potion to see if it's
			-- marked as incompatible
			return false
		else
			return true
		end
................................................................................
	return false
end

local effects_table = function(potion)
	local meta = potion:get_meta()
	local tbl = {}
	for k,v in pairs(sorcery.data.elixirs) do
		if not v.flag then goto skip end
		local val = meta:get_int(v.flag)
		if val > 0 then
			local aff, title, desc = v.describe(potion)
			if val > 3 then title = title .. ' x' .. val
			elseif val == 3 then title = 'thrice-' .. title
			elseif val == 2 then title = 'twice-' .. title
			end
			tbl[#tbl + 1] = {
................................................................................

sorcery.alchemy.elixir_apply = function(elixir, potion)
	if not potion then return end
	local pdef = potion:get_definition()
	if elixir_can_apply(elixir, pdef) then
		elixir.apply(potion, pdef._proto)
		potion:get_meta():set_string('description', sorcery.lib.ui.tooltip {
			title = pdef._proto.name .. ' Draught';
			desc = pdef._proto.desc;
			color = sorcery.lib.color(pdef._proto.color):readable();
			props = effects_table(potion);
		});
	end
	return potion
end
................................................................................
			elseif r.enhance then
				if fx.onenhance then out = fx.onenhance {
					pos = pos;
					stack = out;
					potion = r.proto;
					elixir = r.elixir;
				} end
				log.act(dump(r))
				log.act(string.format('an infuser at %s has enhanced a %s potion with a %s elixir',
					minetest.pos_to_string(pos), out:get_name(), infusion[1]:get_name()))
			end
			inv:set_stack('potions',i,discharge(out))
		end

		inv:set_stack('infusion',1,residue)







|
|
|
|
<







 







|
|







 







|







 







<







101
102
103
104
105
106
107
108
109
110
111

112
113
114
115
116
117
118
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
...
300
301
302
303
304
305
306

307
308
309
310
311
312
313
end

local elixir_can_apply = function(elixir, potion)
	-- accepts an elixir def and potion def
	if elixir        == nil or
	   potion        == nil then return false end

	if elixir.apply and potion._proto and potion._proto.quals then
		-- the ingredient is an elixir and at least one potion has a
		-- quality that can be enhanced
		if elixir.qual and potion._proto and not potion._proto.quals[elixir.qual] then

			-- does the elixir have a property used to denote
			-- compatibility? if so, check the potion to see if it's
			-- marked as incompatible
			return false
		else
			return true
		end
................................................................................
	return false
end

local effects_table = function(potion)
	local meta = potion:get_meta()
	local tbl = {}
	for k,v in pairs(sorcery.data.elixirs) do
		if not v.qual then goto skip end
		local val = meta:get_int(v.qual)
		if val > 0 then
			local aff, title, desc = v.describe(potion)
			if val > 3 then title = title .. ' x' .. val
			elseif val == 3 then title = 'thrice-' .. title
			elseif val == 2 then title = 'twice-' .. title
			end
			tbl[#tbl + 1] = {
................................................................................

sorcery.alchemy.elixir_apply = function(elixir, potion)
	if not potion then return end
	local pdef = potion:get_definition()
	if elixir_can_apply(elixir, pdef) then
		elixir.apply(potion, pdef._proto)
		potion:get_meta():set_string('description', sorcery.lib.ui.tooltip {
			title = string.format('%s %s', pdef._proto.name, pdef._proto.kind.label);
			desc = pdef._proto.desc;
			color = sorcery.lib.color(pdef._proto.color):readable();
			props = effects_table(potion);
		});
	end
	return potion
end
................................................................................
			elseif r.enhance then
				if fx.onenhance then out = fx.onenhance {
					pos = pos;
					stack = out;
					potion = r.proto;
					elixir = r.elixir;
				} end

				log.act(string.format('an infuser at %s has enhanced a %s potion with a %s elixir',
					minetest.pos_to_string(pos), out:get_name(), infusion[1]:get_name()))
			end
			inv:set_stack('potions',i,discharge(out))
		end

		inv:set_stack('infusion',1,residue)