sorcery  Check-in [aba5ad057a]

Overview
Comment:add mounted keg for shelving units, fix altar visuals
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: aba5ad057aa371de3b3398edc83b2164ef38f22a984ef79f917418682da18267
User & Date: lexi on 2021-07-07 15:34:56
Other Links: manifest | tags
Context
2021-07-07
15:35
fix keg group check-in: a27bfa0fa7 user: lexi tags: trunk
15:34
add mounted keg for shelving units, fix altar visuals check-in: aba5ad057a user: lexi tags: trunk
13:08
fug bixes check-in: b9235d8bfa user: lexi tags: trunk
Changes

Modified altar.lua from [dfbf2cd360] to [f0ec80311e].

     1      1   local altar_item_offset = {
     2         -	x = 0, y = -0.3, z = 0
            2  +	x = 0, y = -0.3, z = 0.13
     3      3   }
     4      4   local log = sorcery.logger('altar')
     5      5   local L = sorcery.lib
     6      6   
     7      7   local range = function(min, max)
     8      8   	local span = max - min
     9      9   	local val = math.random() * span

Modified keg.lua from [b24c7d1147] to [4b624880ad].

     1      1   local constants = {
     2      2   	keg_volume = sorcery.liquid.constants.glasses_per_bottle * 600
     3      3   }
     4      4   
     5         -local hitbox = {
            5  +local hitbox = function(yo) return {
            6  +	type = 'fixed';
            7  +	fixed = {
            8  +		-0.4, -0.5 + yo, -0.45;
            9  +		 0.4,  0.2 + yo,  0.5;
           10  +	};
           11  +} end
           12  +local mcbox = {
     6     13   	type = 'fixed';
     7     14   	fixed = {
     8         -		-0.4, -0.5, -0.5;
     9         -		 0.4,  0.2,  0.5;
           15  +		-0.5, -0.4, -0.5;
           16  +		 0.5,  0.3,  0.4;
    10     17   	};
    11     18   }
           19  +
    12     20   local kegcaption = function(m)
    13     21   	local liqid = m:get_string('liquid')
    14     22   	if liqid ~= '' then
    15     23   		local liq = sorcery.register.liquid.db[liqid]
    16     24   		if not liq then log.err('missing entry for liquid',liqid) return end
    17     25   		return {
    18     26   			title = string.format('%s Keg', sorcery.lib.str.capitalize(liq.name));
    19     27   			color = sorcery.lib.color(liq.color);
    20     28   			desc = string.format('%s of %s', liq.measure(m:get_int('charge')), liq.name);
    21     29   		};
    22     30   	else return { title = 'Empty Keg', props = {} } end
    23     31   end
           32  +
    24     33   local log = sorcery.logger('keg')
    25         -minetest.register_node('sorcery:keg', {
    26         -	description = 'Keg';
           34  +for _, keg in pairs {
           35  +	{ name = 'Keg', id = 'sorcery:keg', model = 'sorcery-keg.obj', atch = 1 };
           36  +	{ name = 'Mounted Keg', id = 'sorcery:keg_stand', model = 'sorcery-keg-stand.obj', atch = 0, ofs = 0.1, cb = mcbox };
           37  +} do
           38  +	minetest.register_node(keg.id, {
           39  +		description = keg.name;
    27     40   	drawtype = 'mesh';
    28         -	mesh = 'sorcery-keg.obj';
           41  +		mesh = keg.model;
    29     42   	sunlight_propagates = true;
    30     43   	paramtype = 'light';
    31     44   	paramtype2 = 'facedir';
    32         -	groups = { choppy = 2; sorcery_container = 2 }; -- 2=liquid
           45  +		groups = { choppy = 2; sorcery_container = 2; attached_node = keg.atch }; -- 2=liquid
    33     46   	tiles = {
    34     47   		'default_bronze_block.png';
    35     48   		'default_wood.png';
    36     49   		'default_steel_block.png';
    37     50   	};
    38         -	selection_box = hitbox;
    39         -	collision_box = hitbox;
           51  +		selection_box = hitbox(keg.ofs or 0);
           52  +		collision_box = keg.cb or hitbox(keg.ofs or 0);
    40     53   	drop = {
    41     54   		-- preserve_metadata will not work without this!
    42     55   		max_items = 1;
    43     56   		items = {
    44         -			{ items = { 'sorcery:keg' } };
           57  +				{ items = { keg.id } };
    45     58   		};
    46     59   	};
    47     60   	preserve_metadata = function(pos,node,meta,drops)
    48     61   		if meta.liquid and meta.liquid ~= '' then
    49     62   			local m = drops[1]:get_meta()
    50     63   			m:from_table({fields = meta})
    51     64   			local cap = kegcaption(m)
................................................................................
   124    137   				else m:set_int('charge', amtleft) end
   125    138   				sorcery.liquid.sound_dip(chg,avail,pos)
   126    139   				update()
   127    140   
   128    141   				-- fancy visuals
   129    142   				local color = sorcery.lib.color(liq.color or {255,255,255})
   130    143   				local spritz = sorcery.lib.image('sorcery_droplet.png'):glow(color)
   131         -				local drop = sorcery.lib.image('sorcery_drop.png'):glow(color)
          144  +					local drop = sorcery.lib.image('sorcery_drop.png'):multiply(color)
   132    145   				local facing = minetest.facedir_to_dir(minetest.get_node(pos).param2)
   133         -				local noz = vector.add(pos, vector.rotate(
          146  +					local noz = vector.add(
          147  +						vector.offset(pos,0,keg.ofs or 0,0),
          148  +						vector.rotate(
   134    149   					vector.new(0.0,0,-0.48),
   135    150   					vector.dir_to_rotation(facing)
   136         -				))
          151  +						)
          152  +					)
   137    153   				local minnoz = vector.offset(noz, -0.03, -0.32, -0.03);
   138    154   				local maxnoz = vector.offset(noz,  0.03, -0.32,  0.03);
   139    155   				minetest.add_particlespawner {
   140    156   					amount = 15 * chg, time = 0.1*chg;
   141    157   					texture = spritz:render();
   142    158   					minpos = minnoz, maxpos = maxnoz;
   143    159   					minvel = vector.new(0,0,0);
................................................................................
   177    193   				end)
   178    194   
   179    195   				return filled
   180    196   			end
   181    197   		end
   182    198   	end;
   183    199   })
          200  +end
   184    201   
   185    202   minetest.register_craft {
   186    203   	output = "sorcery:keg";
   187    204   	recipe = {
   188    205   		{'','screwdriver:screwdriver',''};
   189    206   		{'sorcery:screw_bronze', 'sorcery:tap', 'sorcery:screw_bronze'};
   190    207   		{'sorcery:screw_bronze', 'xdecor:barrel', 'sorcery:screw_bronze'};
   191    208   	};
   192    209   	replacements = {
   193    210   		{'screwdriver:screwdriver', 'screwdriver:screwdriver'};
   194    211   	};
   195    212   }
          213  +
          214  +minetest.register_craft {
          215  +	output = "sorcery:keg_stand";
          216  +	recipe = {
          217  +		{'','sorcery:keg',''};
          218  +		{'sorcery:screw_steel','group:wood','sorcery:screw_steel'};
          219  +		{'sorcery:screw_steel','screwdriver:screwdriver','sorcery:screw_steel'};
          220  +	};
          221  +	replacements = {{'screwdriver:screwdriver', 'screwdriver:screwdriver'}};
          222  +}
          223  +
          224  +minetest.register_craft {
          225  +	output = "sorcery:keg";
          226  +	type = 'shapeless';
          227  +	recipe = { 'sorcery:keg_stand', 'screwdriver:screwdriver' };
          228  +	replacements = {
          229  +		{'screwdriver:screwdriver', 'screwdriver:screwdriver'};
          230  +		{'sorcery:keg_stand', 'sorcery:screw_steel 4'};
          231  +	};
          232  +}