Index: data/gems.lua ================================================================== --- data/gems.lua +++ data/gems.lua @@ -55,27 +55,32 @@ }; }; luxite = { tone = {189,255,236}; rarity = 130; + hardness = 3; }; ruby = { tone = {255,94,161}; + hardness = 5; rarity = 150; }; amethyst = { tone = {234,94,255}; + hardness = 6; rarity = 190; }; sapphire = { tone = {94,139,255}; rarity = 260; + hardness = 7; wandprops = { sturdiness = 0.5; power = 2; }; }; emerald = { + hardness = 7; tone = {133,255,94}; rarity = 320; }; } Index: gems.lua ================================================================== --- gems.lua +++ gems.lua @@ -135,10 +135,16 @@ value = (5 * shards_per_gem) + 4; }; amulet = { base = name }; }; }) + sorcery.lathe.register { + input = itemname; + output = amuletname; + tech = 'intaglio'; + cost = 1; + } sorcery.register.metals.foreach('sorcery:mk-amulet-frames-'..name,{'sorcery:generate'}, function(metalid,metal) if not metal.amulet then return end local framedid = string.format("%s_frame_%s", amuletname, metalid) local img_frame = img(string.format('sorcery_amulet_frame_%s.png',metalid)) minetest.register_craftitem(framedid, { @@ -149,17 +155,20 @@ on_use = useamulet; _sorcery = { amulet = { base = name, frame = metalid }; }; }) - local frag = metal.parts.fragment + --local frag = metal.parts.fragment + local disc = metal.parts.disc minetest.register_craft { output = framedid; recipe = { - {'', frag,''}; - {frag,amuletname,frag}; - {'', frag,''}; + {amuletname}; + {disc}; + -- {'', frag,''}; + -- {frag,amuletname,frag}; + -- {'', frag,''}; }; } end) end minetest.register_craft { @@ -179,18 +188,18 @@ shardname, shardname, shardname; shardname, shardname, shardname; }; output = itemname; }; - minetest.register_craft { - recipe = { - {shardname,itemname,shardname}; - {itemname,itemname,itemname}; - {shardname,itemname,shardname}; - }; - output = amuletname; - }; +-- minetest.register_craft { +-- recipe = { +-- {shardname,itemname,shardname}; +-- {itemname,itemname,itemname}; +-- {shardname,itemname,shardname}; +-- }; +-- output = amuletname; +-- }; -- generate lenses and crafting recipes for _, kind in pairs { 'amplifier','rectifier','concave','convex' } do local id = 'sorcery:lens_' .. kind .. '_' .. name minetest.register_tool(id, { Index: lathe.lua ================================================================== --- lathe.lua +++ lathe.lua @@ -1,14 +1,27 @@ -- the math basically needs to be rewritten from scratch by someone who isn't -- dyscalculic but +local L = sorcery.lib +local M = function(i) return sorcery.itemclass.get(i, 'material') end sorcery.lathe = { techs = { cut = {dmg = true}; - intaglio = {consume = true}; + intaglio = { + consume = true; + toolpred = function(tool) + if minetest.get_item_group(tool, 'sorcery_powder') == 0 then return false end + local cl = sorcery.itemclass.get(tool, 'metal') + return cl.data.hardness >= 3 + end; + validate = function(tool, wkpc) + return M(tool).data.hardness >= M(wkpc).data.hardness + end; + }; }; tools = { - sword = 'cut', knife = 'cut', blade = 'cut'; + ['group:sword'] = 'cut', ['group:knife'] = 'cut', ['group:blade'] = 'cut'; + ['group:sorcery_intaglio_powder'] = 'intaglio'; }; recipes = {}; register = function(def) local recipes = sorcery.lathe.recipes if not recipes[def.input] then recipes[def.input] = {} end @@ -20,11 +33,11 @@ end; register_metal = function(def) local parts = sorcery.data.metals[def.metal].parts local out = ItemStack(def.output) for _, ty in pairs {'ingot', 'block', 'fragment'} do - local pt = parts[ty] + local pt = parts[ty] local ptc = sorcery.itemclass.get(pt, 'metal') if ptc and ptc.value then if def.mass <= ptc.value then local mass local vfc = ptc.value / def.mass @@ -57,15 +70,27 @@ end end end; tooltech = function(tool) if type(tool) ~= 'string' then tool = tool:get_name() end - for g,t in pairs(sorcery.lathe.tools) do - if minetest.get_item_group(tool, g) ~= 0 then + local ts = sorcery.lathe.tools + if ts[tool] then return ts[tool] end + + for id,t in pairs(ts) do + local q, g = L.str.beginswith(id, 'group:') + if q and minetest.get_item_group(tool, g) ~= 0 then return t end end + + for tech, t in pairs(sorcery.lathe.techs) do + if t.toolpred then + if t.toolpred(tool) then return tech end + end + end + + return nil end; } local R = sorcery.lathe.recipes sorcery.lathe.get = function(pos,idx,howmany) @@ -218,29 +243,40 @@ allow_metadata_inventory_put = function(pos, list, idx, stack, user) local inv = minetest.get_meta(pos):get_inventory() if list == 'tool' then local s_wkpc = inv:get_stack('workpiece', 1) local tech = sorcery.lathe.tooltech(stack) + if not tech then return 0 end + local vdtr = sorcery.lathe.techs[tech].validate if tech and (s_wkpc:is_empty() - or (R[s_wkpc:get_name()] ~= nil and - R[s_wkpc:get_name()][tech] ~= nil)) + or (R[s_wkpc:get_name()] ~= nil and + R[s_wkpc:get_name()][tech] ~= nil and + (vdtr == nil or vdtr(stack,s_wkpc) ))) then return stack:get_count() end for g,v in pairs(s_wkpc:get_definition().groups) do local gs = R['group:'..g..'='..tostring(v)] local gg = R['group:'..g] if (gs and gs[tech]) or (gg and gg[tech]) then - return stack:get_count() + if vdtr == nil or vdtr(stack, s_wkpc) then + return stack:get_count() + end end end elseif list == 'workpiece' then local s_tool = inv:get_stack('tool', 1) if R[stack:get_name()] then - if s_tool:is_empty() - or R[stack:get_name()][sorcery.lathe.tooltech(s_tool)] - then return stack:get_count() end + if s_tool:is_empty() then return stack:get_count() end + + local tech = sorcery.lathe.tooltech(s_tool) + if tech and R[stack:get_name()][tech] then + local vdtr = sorcery.lathe.techs[tech].validate + if vdtr == nil or vdtr(s_tool, stack) then + return stack:get_count() + end + end end end return 0 end; Index: lib/str.lua ================================================================== --- lib/str.lua +++ lib/str.lua @@ -14,16 +14,20 @@ return string.upper(string.sub(str, 1,1)) .. string.sub(str, 2) end; beginswith = function(str,pfx) if #str < #pfx then return false end - return string.sub(str,1,#pfx) == pfx + if string.sub(str,1,#pfx) == pfx then + return true, string.sub(str,1 + #pfx) + end end; endswith = function(str,sfx) if #str < #sfx then return false end - return string.sub(str,#sfx) == sfx + if string.sub(str,#sfx) == sfx then + return true, string.sub(str,1,#sfx) + end end; explode = function(str,delim,pat) -- this is messy as fuck but it works so im keeping it local i = 1 local tbl = {} Index: metal.lua ================================================================== --- metal.lua +++ metal.lua @@ -70,31 +70,21 @@ metal = true; id = name; data = metal; value = c.cost * fragments_per_ingot; } end end - sorcery.data.metallookup[ingot] = { - id = name; data = metal; - value = fragments_per_ingot; - } - sorcery.data.metallookup[block] = { - id = name; data = metal; - value = fragments_per_ingot * 9; - } - sorcery.data.metallookup[fragment] = { - id = name; data = metal; - value = 1; - } - sorcery.data.metallookup[disc] = { - id = name; data = metal; - value = 8/3; - } + local install = function(part,amt) + sorcery.data.metallookup[part] = { id = name, data = metal, value = amt } + end + install(ingot, fragments_per_ingot) + install(block, fragments_per_ingot*9) + install(fragment, 1) + install(powder, 1) + install(disc, 8/3) + if not metal.no_craftables then - sorcery.data.metallookup[screw] = { - id = name; data = metal; - value = 0.5; - } + install(screw, 0.5) minetest.register_craftitem(screw, { description = sorcery.lib.str.capitalize(name) .. ' Screw'; inventory_image = sorcery.lib.image('sorcery_screw.png'):multiply(sorcery.lib.color(metal.tone)):render(); groups = { metal = 1; sorcery_screw = 1; sorcery_tech_component = 1; }; _sorcery = { @@ -131,10 +121,20 @@ value = 4 * (2/3); }; }; }) + sorcery.lathe.register { + input = ingot; + output = {name = fragment; count = fragments_per_ingot}; + tech = 'cut', cost = 2; + } + sorcery.lathe.register { + input = block; + output = {name = fragment; count = fragments_per_ingot*9}; + tech = 'cut', cost = 2*7; + } sorcery.lathe.register { input = ingot, mass = 2; output = {name = disc, count = 3}; tech = 'cut', cost = 5; } @@ -146,10 +146,11 @@ } minetest.register_craftitem(powder, { description = sorcery.lib.str.capitalize(name) .. ' Powder'; inventory_image = 'sorcery_' .. name .. '_powder.png'; + groups = {sorcery_powder = 1; powder = 1}; }) if metal.dye then minetest.register_craft { output = 'dye:' .. metal.dye .. ' 4'; recipe = { @@ -223,11 +224,11 @@ cooktime = (metal.cooktime or 4) * 0.5; output = fragment .. ' ' .. tostring(fragments_per_ingot); } do local rec = {} for i=1,fragments_per_ingot do - rec[#rec+1]=fragment + rec[#rec+1]=fragment end minetest.register_craft { type = 'shapeless'; recipe = rec; output = ingot; Index: recipes.lua ================================================================== --- recipes.lua +++ recipes.lua @@ -378,10 +378,23 @@ metal = 'aluminum'; output = 'sorcery:pipe'; tech = 'cut', cost = 8; mass = 4; } + +sorcery.lathe.register_metal { + metal = 'steel'; + output = 'basic_materials:steel_strip'; + tech = 'cut', cost = 2; + mass = 0.5; +} +sorcery.lathe.register_metal { + metal = 'copper'; + output = 'basic_materials:copper_strip'; + tech = 'cut', cost = 1; + mass = 0.5; +} minetest.register_craft { output = 'sorcery:trough'; recipe = { {ingot 'aluminum','',ingot 'aluminum'}; @@ -390,18 +403,18 @@ }; } regtech('infuser_tube', 'Infusion Tube', {metal = 1}, { {"basic_materials:copper_strip",'sorcery:infuser_concentrator', "basic_materials:copper_strip"}; - {"", "basic_materials:copper_strip", "basic_materials:gold_wire"}; - {"", "basic_materials:copper_strip", ""}; + {"", mtlp('copper','disc'), "basic_materials:gold_wire"}; + {"", 'sorcery:pipe', ""}; }, 1, { {"basic_materials:gold_wire", "basic_materials:empty_spool"} }) regtech('infuser_chamber', 'Infuser Chamber', nil, { {'default:clay_brick','sorcery:grease_sealant','default:clay_brick'}; - {'default:clay_brick','stairs:slab_steelblock','default:clay_brick'}; + {'default:clay_brick',mtlp('steel','disc'),'default:clay_brick'}; }, 1, { {'sorcery:grease_sealant','xdecor:bowl'}; }) regtech('infuser_concentrator', 'Infuser Concentrator', nil, { {'basic_materials:steel_wire'}; @@ -424,13 +437,13 @@ {'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'}; + {'default:flint',mtlp('tungsten','disc'),'group:sorcery_ley_cable'}; {'','group:sorcery_ley_cable',''}; - {'group:sorcery_ley_cable','sorcery:tungsten_ingot','default:flint'}; + {'group:sorcery_ley_cable',mtlp('tungsten','disc'),'default:flint'}; }) 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'}; Index: tree.lua ================================================================== --- tree.lua +++ tree.lua @@ -40,27 +40,35 @@ tech = 'cut'; output = 'default:stick 18'; cost = 1; } - if t.lathe then for tech, items in pairs(t.lathe) do - for _, i in pairs(items) do - for _, n in pairs(nodes) do - if minetest.registered_items[n] - and minetest.registered_items[i[1]] then - sorcery.lathe.register { - input = n; - tech = tech; - output = { - name = i[1]; - count = i[2]; - }; - cost = i[3]; - } + for _, n in pairs(nodes) do + if minetest.registered_items[n] then + sorcery.lathe.register { + input = n, tech = 'cut'; + output = 'xdecor:table 2'; + cost = 2; + } + if t.lathe then + for tech, items in pairs(t.lathe) do + for _, i in pairs(items) do + if minetest.registered_items[i[1]] then + sorcery.lathe.register { + input = n; + tech = tech; + output = { + name = i[1]; + count = i[2]; + }; + cost = i[3]; + } + end + end end end - end end - end end + end + end end if t.sap == false then return end if not t.sapliq then t.sapliq = string.format('sorcery:sap_%s', id)