Index: cookbook.lua ================================================================== --- cookbook.lua +++ cookbook.lua @@ -709,14 +709,17 @@ local meta = stack:get_meta() local curpage = meta:contains("pagenr") and meta:get_int("pagenr") or 1 local pagect = math.ceil(#book.pages / constants.recipes_per_cookbook_page) - if curpage > 1 and fields.pageback then - meta:set_int('pagenr', curpage - 1) - elseif curpage < pagect and fields.pagenext then - meta:set_int('pagenr', curpage + 1) + if fields.pageback or fields.pagenext then + if curpage > 1 and fields.pageback then + meta:set_int('pagenr', curpage - 1) + elseif curpage < pagect and fields.pagenext then + meta:set_int('pagenr', curpage + 1) + end + minetest.sound_play('sorcery_pgturn', { pos = pos, gain = 0.6 }) end uinv:set_stack('main',idx,stack) bookform(stack,user) end) Index: itemclass.lua ================================================================== --- itemclass.lua +++ itemclass.lua @@ -21,10 +21,11 @@ -- themselves) and items crafted from those materials. -- the former includes only crafting materials, the -- latter includes both. gem = { compat = 'gems'; + finagle = function(g) return {data = sorcery.data.gems[g.id]} end; groups = { 'gem', 'crystal'; }; predicate = function(name) if minetest.get_item_group(name, 'sorcery_gem') ~= 0 or minetest.get_item_group(name, 'sorcery_shard') ~= 0 then return minetest.registered_items[name]._sorcery.material; Index: lathe.lua ================================================================== --- lathe.lua +++ lathe.lua @@ -56,10 +56,17 @@ inv:set_stack('preview',i,ItemStack()) end end return end + + local tmat = sorcery.itemclass.get(tool:get_name(),'material') + local wmat = sorcery.itemclass.get(wkpc:get_name(),'material') + -- obey level restrictions. TODO honor Rend + if (wmat and wmat.data.level or 0) > (tmat and (tmat.data.maxlevel or tmat.data.level) or 0) then + return + end local tech = sorcery.lathe.tooltech(tool) local rec = R[wkpc:get_name()][tech] tech = sorcery.lathe.techs[tech] @@ -164,15 +171,24 @@ end; on_metadata_inventory_put = sorcery.lathe.update; on_metadata_inventory_take = function(pos, list, idx, stack, user) 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 - --TODO wear down tool + 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(4 * ch * l.cost * lfac) end l.wkpc:take_item(l.qty) l.inv:set_stack('tool', 1, l.tool) l.inv:set_stack('workpiece', 1, l.wkpc) minetest.sound_play('sorcery_clank', { pos = pos, gain = 0.9 }) Index: writing.lua ================================================================== --- writing.lua +++ writing.lua @@ -479,10 +479,11 @@ if fields.nextpage or fields.prevpage then local page = math.max(1,bm:get_int('pagenr')) if fields.nextpage then page = page + 1 elseif fields.prevpage then page = page - 1 end bm:set_int('pagenr',math.max(1,page)) + minetest.sound_play('sorcery_pgturn', { pos = pos, gain = 0.6 }) changed = true end -- handle retitle request if fields.title then