sorcery  Check-in [e408b8d0e0]

Overview
Comment:enable kegs to store (non-drinkable) potions, add keg crafting recipe
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e408b8d0e018c5d0fcad0cc3930dee280e971c18e75897e98c10a80bd81cf328
User & Date: lexi on 2021-06-24 16:36:14
Other Links: manifest | tags
Context
2021-06-28
15:38
more work on kegs and liquid, add taps and troughs for tapping trees and obtaining sap, add tree lore, add infuser module system, various tweaks, fix up bugged itemclass logic, add scaffold for crafting extension mechanism check-in: 01f4ba8ddc user: lexi tags: trunk
2021-06-24
16:36
enable kegs to store (non-drinkable) potions, add keg crafting recipe check-in: e408b8d0e0 user: lexi tags: trunk
07:15
add basic keg impl check-in: 9b8118877e user: lexi tags: trunk
Changes

Modified keg.lua from [1db75c4003] to [64df297e83].

    11     11   		local liq = sorcery.register.liquid.db[liqid]
    12     12   		if not liq then log.err('missing entry for liquid',liqid) return end
    13     13   		local measure = liq.measure or function(u)
    14     14   			return string.format('%s drams', u*63.9)
    15     15   		end
    16     16   
    17     17   		return {
    18         -			title = string.format('Keg of %s', liq.name);
           18  +			title = string.format('%s Keg', sorcery.lib.str.capitalize(liq.name));
    19     19   			color = sorcery.lib.color(liq.color);
    20         -			props = {
    21         -				{title = 'Contains', desc = measure(m:get_int('charge'))};
    22         -			}
           20  +			desc = string.format('%s of %s', measure(m:get_int('charge')), liq.name);
    23     21   		};
    24     22   	else return { title = 'Empty Keg', props = {} } end
    25     23   end
    26     24   local log = sorcery.logger('keg')
    27     25   minetest.register_node('sorcery:keg', {
    28     26   	description = 'Keg';
    29     27   	drawtype = 'mesh';
................................................................................
    65     63   		m:set_string('infotext', 'Empty Keg')
    66     64   	end;
    67     65   	on_rightclick = function(pos, node, user, stack)
    68     66   		local m = minetest.get_meta(pos)
    69     67   		local update = function()
    70     68   			local c = kegcaption(m)
    71     69   			local str = c.title
    72         -			for _,p in pairs(c.props) do
           70  +			if c.desc then str = str .. '\n(' .. c.desc .. ')' end
           71  +			if c.props then for _,p in pairs(c.props) do -- future-proofing
    73     72   				str = str .. string.format('\n(%s: %s)', p.title, p.desc)
    74         -			end
           73  +			end end
    75     74   			m:set_string('infotext', str)
    76     75   		end
    77     76   		local noise = function(amt)
    78     77   			minetest.sound_play('default_water_footstep', {
    79     78   				gain = 0.5 + amt / 9.0;
    80     79   				pitch = 1.3 - amt / 12.0;
    81     80   				pos = pos;
................................................................................
   189    188   					}
   190    189   				end
   191    190   			end
   192    191   
   193    192   		end
   194    193   	end;
   195    194   })
          195  +
          196  +minetest.register_craft {
          197  +	output = "sorcery:keg";
          198  +	recipe = {
          199  +		{'', 'basic_materials:steel_bar', 'screwdriver:screwdriver'};
          200  +		{'sorcery:screw_bronze', 'default:bronze_ingot', 'sorcery:screw_bronze'};
          201  +		{'', 'xdecor:barrel', ''};
          202  +	};
          203  +	replacements = {
          204  +		{'screwdriver:screwdriver', 'screwdriver:screwdriver'};
          205  +	};
          206  +}

Modified liquid.lua from [951f6052a6] to [a02ac21c24].

     1      1   -- liquid.lua
     2      2   -- the liquid registry is used to keep track of abstract liquids,
     3      3   -- their properties, and their representation in-game.
     4      4   
     5      5   sorcery.registry.mk('liquid', false)
            6  +sorcery.liquid = {}
     6      7   
     7         --- pre-register liquids used in Sorcery and common ones sorcery depends on
            8  +-- pre-register basic liquids used in Sorcery and common ones sorcery depends on
     8      9   
     9     10   sorcery.register.liquid.link('default:water', {
    10         -	name = 'Water';
           11  +	name = 'water';
    11     12   	kind = 'default:drink';
    12     13   	color = {10,85,255};
    13     14   	proto = nil;
    14     15   	src = 'default:water_source';
    15     16   	containers = {
    16     17   		['vessels:glass_bottle'] = 'sorcery:potion_water';
    17     18   		['bucket:bucket_empty'] = 'bucket:bucket_water';
    18     19   	};
    19     20   })
    20     21   
    21     22   sorcery.register.liquid.link('farming:ethanol', {
    22         -	name = 'Ethanol';
           23  +	name = 'ethanol';
    23     24   	kind = 'default:fuel';
    24     25   	color = {175,185,130};
    25     26   	proto = nil;
    26     27   	measure = function(u) return string.format('%s pints', u * 5) end;
    27     28   	containers = {
    28     29   		['vessels:glass_bottle'] = 'farming:ethanol_bottle';
    29     30   	};
    30     31   })
    31     32   
    32     33   sorcery.register.liquid.link('sorcery:blood', {
    33         -	name = 'Blood';
           34  +	name = 'blood';
    34     35   	kind = 'sorcery:reagent';
    35     36   	color = {255,10,30};
    36     37   	proto = nil;
    37     38   	measure = function(u) return string.format('%s cc', u * 236.5) end;
    38     39   	containers = {
    39     40   		['vessels:glass_bottle'] = 'sorcery:blood';
    40     41   	};
    41     42   })

Modified potions.lua from [a284aef5fe] to [1d78d17f17].

   113    113   	local glow = v.glow
   114    114   	local id = 'potion_' .. string.lower(n)
   115    115   	local desc = 'A ' .. ((glow and 'glowing ') or '') ..
   116    116   		'bottle of ' .. string.lower(n) .. 
   117    117   		((kind == 'sparkle' and ', fiercely bubbling') or '') ..
   118    118   		' liquid'
   119    119   	local fullname = n .. ' Potion'
          120  +	sorcery.register.liquid.link('sorcery:'..id, {
          121  +		name = 'Serene Potion';
          122  +		color = v.color;
          123  +		proto = v;
          124  +		kind = 'sorcery:potion';
          125  +		measure = function(amt) return string.format('%s draughts', amt / 3) end;
          126  +		containers = {
          127  +			['vessels:glass_bottle'] = 'sorcery:' .. id;
          128  +		};
          129  +	})
   120    130   	sorcery.register_potion(id, fullname, desc, color, kind, glow, {
   121         -		_proto = v;
   122    131   		groups = {
   123    132   			sorcery_potion = 1;
   124    133   			sorcery_magical = 1;
          134  +		};
          135  +		_proto = v;
          136  +		_sorcery = {
          137  +			container = {
          138  +				type = 'vessel';
          139  +				hold = 'liquid';
          140  +				has = 'sorcery:' .. id;
          141  +				empty = 'vessels:glass_bottle';
          142  +				charge = 3;
          143  +			};
   125    144   		};
   126    145   	})
   127    146   	create_infusion_recipe(id,v,'sorcery:potion_serene',{data=v,name=fullname})
   128    147   end)
   129    148   
   130    149   -- for n,potion in pairs(sorcery.data.draughts) do
   131    150   sorcery.register.draughts.foreach('sorcery:mknodes',{},function(n,potion)