Index: lathe.lua ================================================================== --- lathe.lua +++ lathe.lua @@ -33,20 +33,32 @@ local inv = minetest.get_meta(pos):get_inventory() local tool = inv:get_stack('tool',1) local tech = sorcery.lathe.tooltech(tool) if not tech then return nil end local wkpc = inv:get_stack('workpiece',1) - howmany = howmany or wkpc:get_count() local rec = R[wkpc:get_name()][tech][idx] local outn = ItemStack(rec.output):get_count() - local ntimes = math.floor(howmany / (rec.mass or 1)) + howmany = howmany or math.floor(wkpc:get_count()/(rec.mass or 1))*outn + local ntimes = math.floor(howmany / outn) + + local tmat = sorcery.itemclass.get(tool,'material') + local wmat = sorcery.itemclass.get(wkpc,'material') + local dur = 100 + local lfac = 1 + if tmat then + local dur = tmat.data.durability or dur + lfac = (wmat and wmat.data.level or 1) / + (tmat.data.maxlevel or tmat.data.level or 1) + end + local ch = 65535 / dur + local wear = 2 * (ch * rec.cost * ntimes * lfac); return { tool = tool, wkpc = wkpc; cost = rec.cost * ntimes; + wear = wear; ntimes = ntimes; - tqty = math.floor(howmany / outn) * (rec.mass or 1), outn = outn; - gqty = ntimes * outn; + tqty = ntimes * (rec.mass or 1), outn = outn; tech = tech; rec = rec; inv = inv; } end @@ -77,21 +89,30 @@ -- fill in the preview slots local j = 1 for i=1, inv:get_size 'preview' do local stk = ItemStack() - if rec[i] and minetest.registered_items[ItemStack(rec[i].output):get_name()] and (rec[i].mass == nil or rec[i].mass <= wkpc:get_count()) then - local l = sorcery.lathe.get(pos, i, wkpc:get_count()) - local max = l.ntimes --math.floor(wkpc:get_count() / (rec[i].mass or 1)) + local os = rec[i] and ItemStack(rec[i].output) + if rec[i] and minetest.registered_items[os:get_name()] and (rec[i].mass == nil or rec[i].mass <= wkpc:get_count()) then + local l = sorcery.lathe.get(pos, i) + local max = l.ntimes + --math.floor(wkpc:get_count() / (rec[i].mass or 1)) if tech.dmg then - -- TODO count remaining tool uses + local lw = l.wear + while lw + tool:get_wear() > 65535 do + max = max - 1 + if max == 0 then break end + lw = sorcery.lathe.get(pos, i, max).wear + end elseif tech.consume then max = math.min(max, tool:get_count()) end if max > 0 then stk = ItemStack(rec[i].output) - stk:set_count(stk:get_count() * max) + local ct = math.min(stk:get_count() * max, stk:get_stack_max()) + ct = ct - (ct % os:get_count()) + stk:set_count(ct) end end inv:set_stack('preview',i,stk) j = j + 1 end @@ -132,12 +153,12 @@ i:set_size('workpiece', 1); i:set_size('tool', 1); i:set_size('preview', 8); m:set_string('formspec', [[ formspec_version[3] size[10.25,8] - list[context;tool;1.50,1;1,1] - list[context;workpiece;3,1;1,1] + list[context;tool;1.25,1;1,1] + list[context;workpiece;2.75,1;1,1] list[context;preview;5.25,0.25;4,2] list[current_player;main;0.25,3;8,4] listring[current_player;main] listring[context;workpiece] listring[current_player;main] listring[context;tool] @@ -180,21 +201,11 @@ if list == 'preview' then local l = sorcery.lathe.get(pos,idx,stack:get_count()) if sorcery.lathe.techs[l.tech].consume then l.tool:take_item(l.cost) elseif sorcery.lathe.techs[l.tech].dmg then - local mat = sorcery.itemclass.get(l.tool,'material') - local mmat = sorcery.itemclass.get(l.wkpc,'metal') - local dur = 100 - local lfac = 1 - if mat then - local dur = mat.data.durability or dur - lfac = (mmat and mmat.data.level or 1) / - (mat.data.maxlevel or mat.data.level or 1) - end - local ch = 65535 / dur - l.tool:add_wear(ch * l.cost * lfac) + l.tool:add_wear(l.wear) end l.wkpc:take_item(l.tqty) l.inv:set_stack('tool', 1, l.tool) l.inv:set_stack('workpiece', 1, l.wkpc) if l.rec.leftover then Index: metal.lua ================================================================== --- metal.lua +++ metal.lua @@ -37,10 +37,11 @@ ['morelights_vintage:brass_block'] = { id = 'brass'; data = sorcery.data.metals.brass; value = fragments_per_ingot * 9; }; } +local fmt = string.format local tools, armors = sorcery.matreg.tools, sorcery.matreg.armors -- for name, metal in pairs(sorcery.data.metals) do sorcery.register.metals.foreach('sorcery:generate',{},function(name,metal) local ingot = metal.ingot or 'sorcery:' .. name .. '_ingot' @@ -96,11 +97,11 @@ }; }; }) minetest.register_craftitem(disc, { description = sorcery.lib.str.capitalize(name) .. ' Disc'; - inventory_image = sorcery.lib.image('sorcery_disc.png'):multiply(sorcery.lib.color(metal.tone)):render(); + inventory_image = fmt('sorcery_disc_%s.png', name); groups = { metal = 1; sorcery_disc = 1; sorcery_tech_component = 1; }; _sorcery = { material = { id = name, data = metal; powder = powder; Index: recipes.lua ================================================================== --- recipes.lua +++ recipes.lua @@ -167,19 +167,10 @@ {'',mtlp('silver','disc'),''}; {'sorcery:inverter_coil','sorcery:warding_plate','sorcery:inverter_coil'}; }; } -print(dump{ - output = 'sorcery:tuning_disc'; - recipe = { - {'','sorcery_gem:emerald',''}; - {'',mtlp('silver','disc'),''}; - {'sorcery:inverter_coil','sorcery:warding_plate','sorcery:inverter_coil'}; - }; -}) - minetest.register_craft { output = 'sorcery:farcaster'; recipe = { {ingot('gold'),ingot('iridium'),ingot('gold')}; {'sorcery:core_mandatic','default:diamondblock','sorcery:tuning_disc'}; ADDED textures/sorcery_disc_aluminum.png Index: textures/sorcery_disc_aluminum.png ================================================================== --- textures/sorcery_disc_aluminum.png +++ textures/sorcery_disc_aluminum.png cannot compute difference between binary files ADDED textures/sorcery_disc_brass.png Index: textures/sorcery_disc_brass.png ================================================================== --- textures/sorcery_disc_brass.png +++ textures/sorcery_disc_brass.png cannot compute difference between binary files ADDED textures/sorcery_disc_bronze.png Index: textures/sorcery_disc_bronze.png ================================================================== --- textures/sorcery_disc_bronze.png +++ textures/sorcery_disc_bronze.png cannot compute difference between binary files ADDED textures/sorcery_disc_cobalt.png Index: textures/sorcery_disc_cobalt.png ================================================================== --- textures/sorcery_disc_cobalt.png +++ textures/sorcery_disc_cobalt.png cannot compute difference between binary files ADDED textures/sorcery_disc_copper.png Index: textures/sorcery_disc_copper.png ================================================================== --- textures/sorcery_disc_copper.png +++ textures/sorcery_disc_copper.png cannot compute difference between binary files ADDED textures/sorcery_disc_draconium.png Index: textures/sorcery_disc_draconium.png ================================================================== --- textures/sorcery_disc_draconium.png +++ textures/sorcery_disc_draconium.png cannot compute difference between binary files ADDED textures/sorcery_disc_duridium.png Index: textures/sorcery_disc_duridium.png ================================================================== --- textures/sorcery_disc_duridium.png +++ textures/sorcery_disc_duridium.png cannot compute difference between binary files ADDED textures/sorcery_disc_electrum.png Index: textures/sorcery_disc_electrum.png ================================================================== --- textures/sorcery_disc_electrum.png +++ textures/sorcery_disc_electrum.png cannot compute difference between binary files ADDED textures/sorcery_disc_eternium.png Index: textures/sorcery_disc_eternium.png ================================================================== --- textures/sorcery_disc_eternium.png +++ textures/sorcery_disc_eternium.png cannot compute difference between binary files ADDED textures/sorcery_disc_gold.png Index: textures/sorcery_disc_gold.png ================================================================== --- textures/sorcery_disc_gold.png +++ textures/sorcery_disc_gold.png cannot compute difference between binary files ADDED textures/sorcery_disc_impervium.png Index: textures/sorcery_disc_impervium.png ================================================================== --- textures/sorcery_disc_impervium.png +++ textures/sorcery_disc_impervium.png cannot compute difference between binary files ADDED textures/sorcery_disc_iridium.png Index: textures/sorcery_disc_iridium.png ================================================================== --- textures/sorcery_disc_iridium.png +++ textures/sorcery_disc_iridium.png cannot compute difference between binary files ADDED textures/sorcery_disc_levitanium.png Index: textures/sorcery_disc_levitanium.png ================================================================== --- textures/sorcery_disc_levitanium.png +++ textures/sorcery_disc_levitanium.png cannot compute difference between binary files ADDED textures/sorcery_disc_lithium.png Index: textures/sorcery_disc_lithium.png ================================================================== --- textures/sorcery_disc_lithium.png +++ textures/sorcery_disc_lithium.png cannot compute difference between binary files ADDED textures/sorcery_disc_platinum.png Index: textures/sorcery_disc_platinum.png ================================================================== --- textures/sorcery_disc_platinum.png +++ textures/sorcery_disc_platinum.png cannot compute difference between binary files ADDED textures/sorcery_disc_silver.png Index: textures/sorcery_disc_silver.png ================================================================== --- textures/sorcery_disc_silver.png +++ textures/sorcery_disc_silver.png cannot compute difference between binary files ADDED textures/sorcery_disc_steel.png Index: textures/sorcery_disc_steel.png ================================================================== --- textures/sorcery_disc_steel.png +++ textures/sorcery_disc_steel.png cannot compute difference between binary files ADDED textures/sorcery_disc_tin.png Index: textures/sorcery_disc_tin.png ================================================================== --- textures/sorcery_disc_tin.png +++ textures/sorcery_disc_tin.png cannot compute difference between binary files ADDED textures/sorcery_disc_tungsten.png Index: textures/sorcery_disc_tungsten.png ================================================================== --- textures/sorcery_disc_tungsten.png +++ textures/sorcery_disc_tungsten.png cannot compute difference between binary files ADDED textures/sorcery_disc_tyrannium.png Index: textures/sorcery_disc_tyrannium.png ================================================================== --- textures/sorcery_disc_tyrannium.png +++ textures/sorcery_disc_tyrannium.png cannot compute difference between binary files ADDED textures/sorcery_disc_unobtanium.png Index: textures/sorcery_disc_unobtanium.png ================================================================== --- textures/sorcery_disc_unobtanium.png +++ textures/sorcery_disc_unobtanium.png cannot compute difference between binary files ADDED textures/sorcery_disc_vidrium.png Index: textures/sorcery_disc_vidrium.png ================================================================== --- textures/sorcery_disc_vidrium.png +++ textures/sorcery_disc_vidrium.png cannot compute difference between binary files