sorcery  Diff

Differences From Artifact [1c87060d5d]:

To Artifact [1f34837a06]:


   105    105   	for i = 1*f,M*f do
   106    106   		local top = L.image('sorcery_trough_top_overlay.png')
   107    107   		if liq then top = top:blit( 
   108    108   			L.image('sorcery_node_liquid.png'):multiply(L.color(liq.color))
   109    109   		) else top=top:blit(
   110    110   			L.image('sorcery_trough_bottom.png')
   111    111   		) end
   112         -		local ttlc = function(liq,i) return
   113         -			liq and string.format('%s Trough', L.str.capitalize(liq.name)),
   114         -			liq and string.format('%s of %s', liq.measure(i * Q), liq.name)
          112  +		local ttlc = function(liq,i) 
          113  +			if type(liq) == 'string' then liq = sorcery.register.liquid.db[liq] end
          114  +			return
          115  +				liq and string.format('%s Trough', L.str.capitalize(liq.name)),
          116  +				liq and string.format('%s of %s', liq.measure(i * Q), liq.name)
   115    117   		end
   116    118   		local trough_title, trough_content = ttlc(liq,i)
   117    119   		local function trough_caption(pos,i,l) 
   118    120   			local trough_title, trough_content = ttlc(l or liq,i)
   119    121   			minetest.get_meta(pos):set_string('infotext', i > 0 and string.format(
   120    122   				'%s\n(%s)', trough_title, trough_content
   121    123   			) or 'Empty Trough')
................................................................................
   168    170   					type = 'bucket';
   169    171   					hold = 'liquid';
   170    172   					has = liq and liq.id;
   171    173   					charge = liq and Q * i;
   172    174   					empty = 'sorcery:trough';
   173    175   					max = constants.bottles_per_trough * Q;
   174    176   					set_node_vol = liq and function(pos, vol)
          177  +						log.act('putting', vol, liq, 'in trough at', pos)
   175    178   						vol = math.min(M, math.max(0, math.floor(vol / Q)))
   176    179   						minetest.swap_node(pos, {name = lid(vol)})
   177    180   						trough_caption(pos, vol)
          181  +						return vol * Q
   178    182   					end;
   179    183   					set_node_liq = function(pos, liq, vol)
   180         -						log.act('adding', vol, 'to trough at', liq)
          184  +						log.act('putting', vol, liq, 'in trough at', pos)
   181    185   						vol = vol or Q * i
   182    186   						local idx = math.min(M, math.floor(vol/Q))
   183    187   						minetest.swap_node(pos, {name = trough_mkid(liq, idx)})
   184    188   						trough_caption(pos, idx, liq)
          189  +						return idx * Q
   185    190   					end
   186    191   				}
   187    192   			};
   188    193   		})
   189    194   	end
   190    195   end
   191    196   sorcery.liquid.mktrough()
          197  +
          198  +sorcery.liquid.setctr = function(pos, liq, vol, sameliq)
          199  +	local n = sorcery.lib.node.force(pos)
          200  +	if minetest.get_item_group(n.name, 'sorcery_container') ~= 2 then return false end
          201  +	local def = minetest.registered_items[n.name]._sorcery
          202  +	if not (def and def.container and def.container.set_node_liq) then
          203  +		log.err('node',n.name,'marked as liquid container but is missing container.set_node_liq callback')
          204  +		return false
          205  +	end
          206  +	if sameliq then
          207  +		if def.container.has ~= nil and def.container.has ~= liq then
          208  +			return false
          209  +		end
          210  +	end
          211  +	return def.container.set_node_liq(pos, liq, vol)
          212  +end
   192    213   
   193    214   sorcery.liquid.measure_default = sorcery.liquid.units.dram
   194    215   
   195    216   sorcery.liquid.container = function(liq, ctr)
   196    217   	return liq.containers[({
   197    218   		bottle = 'vessels:glass_bottle';
   198    219   		glass = 'vessels:drinking_glass';