Index: liquid.lua ================================================================== --- liquid.lua +++ liquid.lua @@ -1,19 +1,38 @@ -- liquid.lua -- the liquid registry is used to keep track of abstract liquids, -- their properties, and their representation in-game. sorcery.registry.mk('liquid', false) +local mkunit = function(unit,fac) + return function(amt) + -- allow division for more accurate results + if fac >= 0 then + amt = amt * fac + else + amt = amt / (-fac) + end + return string.format('%s %s%s', amt, unit, (amt == 1) and '' or 's') + end +end sorcery.liquid = { constants = { drams_per_glass = 64; + pints_per_glass = 0.5; glasses_per_bottle = 3; bottles_per_bucket = 3; bottles_per_trough = 6; - } + }; + unit = mkunit; } local constants = sorcery.liquid.constants +sorcery.liquid.units = { + dram = mkunit('dram', constants.drams_per_glass); + pint = mkunit('pint', constants.pints_per_glass); + draught = mkunit('draught', -3); + drink = mkunit('drink', 1); +}; local L = sorcery.lib local log = sorcery.logger('liquid') sorcery.liquid.fill_from_basin = function(ctr, liquid, basin) @@ -166,13 +185,11 @@ }) end end sorcery.liquid.mktrough() -sorcery.liquid.measure_default = function(amt) - return string.format('%s drams', amt*constants.drams_per_glass) -end +sorcery.liquid.measure_default = sorcery.liquid.units.dram sorcery.liquid.container = function(liq, ctr) return liq.containers[({ bottle = 'vessels:glass_bottle'; glass = 'vessels:drinking_glass'; Index: potions.lua ================================================================== --- potions.lua +++ potions.lua @@ -122,11 +122,11 @@ id = 'sorcery:'..id; name = fullname; color = v.color; proto = v; kind = 'sorcery:potion'; - measure = function(amt) return string.format('%s draughts', amt / 3) end; + measure = sorcery.liquid.units.draught; containers = { ['vessels:glass_bottle'] = 'sorcery:' .. id; }; } v.kind = kind_potion; @@ -304,10 +304,11 @@ id = liqid; name = desc; kind = 'sorcery:extract'; proto = v; color = v[2]; + measure = sorcery.liquid.units.pint; containers = { ['vessels:glass_bottle'] = liqid; }; } Index: recipes.lua ================================================================== --- recipes.lua +++ recipes.lua @@ -412,11 +412,18 @@ regtech('warding_plate', 'Warding Plate', {metal = 1}, { {'basic_materials:gold_wire','basic_materials:gold_wire','basic_materials:gold_wire'}; {'',mtlp('vidrium','block'),''}; {'basic_materials:gold_wire','basic_materials:gold_wire','basic_materials:gold_wire'}; -}, 4) +}, 4, { + {'basic_materials:gold_wire', 'basic_materials:empty_spool'}; + {'basic_materials:gold_wire', 'basic_materials:empty_spool'}; + {'basic_materials:gold_wire', 'basic_materials:empty_spool'}; + {'basic_materials:gold_wire', 'basic_materials:empty_spool'}; + {'basic_materials:gold_wire', 'basic_materials:empty_spool'}; + {'basic_materials:gold_wire', 'basic_materials:empty_spool'}; +}) regtech('ley_puncture', 'Ley Puncture', {metal = 1}, { {'default:flint','sorcery:tungsten_ingot','group:sorcery_ley_cable'}; {'','group:sorcery_ley_cable',''}; {'group:sorcery_ley_cable','sorcery:tungsten_ingot','default:flint'}; }) @@ -423,16 +430,23 @@ regtech('pulse_rectifier', 'Pulse Rectifier', {metal = 1}) regtech('current_felicitator', 'Current Felicitator', {metal = 1}, { {'basic_materials:silver_wire','basic_materials:silver_wire','basic_materials:silver_wire'}; {'sorcery:cobalt_ingot','sorcery:inversion_matrix','sorcery:cobalt_ingot'}; {'default:bronze_ingot','sorcery:platinum_ingot','default:bronze_ingot'}; +},1,{ + {'basic_materials:silver_wire', 'basic_materials:empty_spool'}; + {'basic_materials:silver_wire', 'basic_materials:empty_spool'}; + {'basic_materials:silver_wire', 'basic_materials:empty_spool'}; }) regtech('conduction_plate', 'Conduction Plate', {metal = 1}, { {'','default:copper_ingot',''}; {'','stairs:slab_stone',''}; {'basic_materials:copper_wire','basic_materials:steel_bar','basic_materials:copper_wire'}; +}, 1, { + {'basic_materials:copper_wire', 'basic_materials:empty_spool'}; + {'basic_materials:copper_wire', 'basic_materials:empty_spool'}; }) regtech('catalytic_convector', 'Catalytic Convector', {metal = 1}, { {'basic_materials:heating_element','default:gold_ingot','basic_materials:heating_element'}; {'default:mese_crystal','default:mese_crystal','default:mese_crystal'}; @@ -545,10 +559,13 @@ recipe = { {'','sorcery:inverter_coil','basic_materials:gold_wire'}; {'sorcery:inverter_coil','sorcery:leyline_stabilizer','sorcery:inverter_coil'}; {'basic_materials:gold_wire','sorcery:inverter_coil',''}; }; + replacements = { + {'basic_materials:gold_wire', 'basic_materials:empty_spool'}; + }; } minetest.register_craft { output = 'sorcery:field_emitter'; Index: tree.lua ================================================================== --- tree.lua +++ tree.lua @@ -6,14 +6,10 @@ sapling = 'default:sapling'; } local log = sorcery.logger('tree') local L = sorcery.lib -local measure_sap = function(v) -- v in half-pints - return string.format('%s pints', v / 2) -end - sorcery.register.trees.foreach('sorcery:treesetup', {}, function(id, t) -- generates sap and hooks handlers appropriately if t.node then local def = minetest.registered_nodes[t.node] local nextfn = def.on_place @@ -43,11 +39,11 @@ name = sapdesc; kind = 'sorcery:sap'; color = t.sapcolor or t.color or {119,24,30}; autogen = true; imgvariant = 'sparkle'; - measure = measure_sap; + measure = sorcery.liquid.units.pint; usetrough = t.sap ~= false; } end end)