Overview
Comment: | add lathe recipes, bugfixes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
669078947dc575378783161b2bc3da75 |
User & Date: | lexi on 2021-07-08 23:14:33 |
Other Links: | manifest | tags |
Context
2021-07-10
| ||
00:43 | remove unnecessary neighbor restriction check-in: ced73b0ebe user: lexi tags: trunk | |
2021-07-08
| ||
23:14 | add lathe recipes, bugfixes check-in: 669078947d user: lexi tags: trunk | |
21:52 | add tree lathe recipes check-in: 56a2b90c1b user: lexi tags: trunk | |
Changes
Modified cookbook.lua from [1bf06d7139] to [bc084489e5].
42 42 43 43 local slot3x3 = { 44 44 {0,0}, {1,0}, {2,0}; 45 45 {0,1}, {1,1}, {2,1}; 46 46 {0,2}, {1,2}, {2,2}; 47 47 } 48 48 local props_builtin = function(item) 49 - local props = minetest.registered_items[item]._sorcery 49 + local props = minetest.registered_items[ItemStack(item):get_name()]._sorcery 50 50 if props and props.recipe then 51 51 return props.recipe 52 52 end 53 53 return {} 54 54 end 55 55 local modofname = function(id) 56 56 local item = minetest.registered_nodes[id] ................................................................................ 149 149 return i 150 150 end 151 151 return i 152 152 end 153 153 local function desc_builtin(i) 154 154 local desc 155 155 i, desc = group_eval(i) 156 - -- print('describing ',i,dump(minetest.registered_items[i])) 157 156 local s = ItemStack(i) 158 157 if not minetest.registered_items[s:get_name()] then 159 - minetest.log('WARNING: unknown item in recipe ' .. i) 158 + log.warn('unknown item in recipe',i) 160 159 return 'Unknown Item' 161 160 end 162 161 if not desc then desc = minetest.registered_items[s:get_name()].description end 163 162 if not desc then return 'Peculiar Item' end 164 163 165 164 local eol = string.find(desc,'\n') 166 165 if eol then desc = string.sub(desc,1,eol-1) end ................................................................................ 193 192 for k,v in pairs(minetest.registered_items) do 194 193 if sorcery.itemclass.get(k, 'grindable') then 195 194 cache.grindables[#cache.grindables+1] = k 196 195 end 197 196 end 198 197 end 199 198 end; 199 + 200 + populate_lathe = function(cache) 201 + if cache.lathe then return end 202 + cache.lathe = { tools = {} } 203 + for k in pairs(sorcery.lathe.techs) do cache.lathe.tools[k] = {} end 204 + 205 + for id, item in pairs(minetest.registered_tools) do 206 + for group, tech in pairs(sorcery.lathe.tools) do 207 + if minetest.get_item_group(id, group) ~= 0 then 208 + local tt = cache.lathe.tools[tech] 209 + local mat = sorcery.itemclass.get(id, 'material') 210 + tt[#tt+1] = { 211 + id = id; 212 + ptr = item; 213 + level = mat and mat.data and (mat.data.maxlevel or mat.data.level) or nil; 214 + } 215 + end 216 + end 217 + end 218 + for _, tech in pairs(sorcery.lathe.tools) do 219 + table.sort(cache.lathe.tools[tech], function(a,b) 220 + return (a.level or 0) < (b.level or 0) 221 + end) 222 + end 223 + end; 200 224 } 201 225 sorcery.cookbook.classes = { 202 226 craft = { 203 227 name = 'Crafting Guide'; 204 228 node = 'xdecor:workbench'; 205 229 booksuf = 'Codex'; 206 230 w = 3, h = 3; ................................................................................ 327 351 return {v, 'sorcery:mill_grindhead_' .. metal} 328 352 end 329 353 end 330 354 return {v,''} -- !! 331 355 end 332 356 end 333 357 end; 358 + }; 359 + lathe = { 360 + name = 'Lathe'; 361 + chance = 1; 362 + node = 'sorcery:lathe'; 363 + booksuf = 'Compendium'; 364 + w = 2, h = 1; 365 + slots = { {1,0}, {0,0} }; 366 + apply_exclusions = true; 367 + props = props_builtin; 368 + find = function(out) 369 + cache:populate_lathe() 370 + local mat = sorcery.itemclass.get(out, 'material') 371 + local level = 0 372 + if mat and mat.data and mat.data.level then 373 + level = mat.data.level 374 + end 375 + for input,tqs in pairs(sorcery.lathe.recipes) do 376 + for tech, defs in pairs(tqs) do 377 + for _, def in pairs(defs) do 378 + if ItemStack(def.output):get_name() == out then 379 + local tool 380 + if level > 0 then 381 + for _,t in pairs(cache.lathe.tools[tech]) do 382 + if (t.level or 0) >= level then 383 + tool = t.id 384 + break 385 + end 386 + end 387 + else 388 + tool = cache.lathe.tools[tech][1].id 389 + end 390 + if def.mass then input = input .. ' ' .. tostring(def.mass) end 391 + local rec = {input, tool or ''} 392 + return rec, {count = ItemStack(def.output):get_count()} 393 + end 394 + end 395 + end 396 + end 397 + end; 398 + pick = function(restrict) 399 + local p = {} 400 + for input,tqs in pairs(sorcery.lathe.recipes) do 401 + for tech, defs in pairs(tqs) do 402 + for _, def in pairs(defs) do 403 + local nm = ItemStack(def.output):get_name() 404 + if item_restrict_eval(nm, restrict) then 405 + p[#p+1] = nm 406 + end 407 + end 408 + end 409 + end 410 + return select(2, sorcery.lib.tbl.pick(p)) 411 + end; 334 412 }; 335 413 enchant = { 336 414 name = 'Enchantment Matrix'; 337 415 node = 'sorcery:enchanter'; 338 416 booksuf = 'Grimoire'; 339 417 drawslots = false; 340 418 chance = 4; ................................................................................ 504 582 img and 'image' or 'item_image', 505 583 k.w+1.1, k.h/2 - 0.5, minetest.formspec_escape(img or result), 506 584 k.w+1.1, k.h/2 - 0.5, minetest.formspec_escape(ot)) 507 585 end; 508 586 509 587 local retrieve_recipe = function(kind,out,notes_right) 510 588 local rec = recipe_kinds[kind] 511 - local ing = rec.find(out) 589 + local ing, props = rec.find(out) 590 + if props then 591 + if props.count then 592 + out = out .. ' ' .. tostring(props.count) 593 + end 594 + end 512 595 return render_recipe(kind,ing,out,notes_right), rec.w, rec.h 513 596 end 514 597 515 598 sorcery.cookbook.setrecipe = function(stack,k,r,restrict) 516 599 local meta = stack:get_meta() 517 600 if not r then r,k = sorcery.cookbook.pickrecipe(k,restrict) end 518 601 if not r then return false end
Modified data/metals.lua from [eba257a7d6] to [36b84b05c4].
231 231 rarity = 13; 232 232 hardness = 2; 233 233 fuel = 80; 234 234 depth = 670; 235 235 level = 1; 236 236 no_tools = true; 237 237 no_armor = true; 238 + no_craftables = true; 238 239 }; 239 240 vidrium = { 240 241 tone = {119,185,221}, alpha = 140; 241 242 artificial = true; 242 243 dye = 'cyan'; 243 244 hardness = 1; 244 245 durability = 300;
Modified metal.lua from [69d743e332] to [f2df9bf8e4].
80 80 id = name; data = metal; 81 81 value = fragments_per_ingot * 9; 82 82 } 83 83 sorcery.data.metallookup[fragment] = { 84 84 id = name; data = metal; 85 85 value = 1; 86 86 } 87 - minetest.register_craftitem(screw, { 88 - description = sorcery.lib.str.capitalize(name) .. ' Screw'; 89 - inventory_image = sorcery.lib.image('sorcery_screw.png'):multiply(sorcery.lib.color(metal.tone)):render(); 90 - groups = { metal = 1; sorcery_screw = 1; sorcery_tech_component = 1; }; 91 - _sorcery = { 92 - material = { 93 - id = name, data = metal; 94 - powder = powder; 95 - grindcost = 2, grindvalue = 1; 96 - value = 0.5; 87 + sorcery.data.metallookup[disc] = { 88 + id = name; data = metal; 89 + value = 8/3; 90 + } 91 + if not metal.no_craftables then 92 + sorcery.data.metallookup[screw] = { 93 + id = name; data = metal; 94 + value = 0.5; 95 + } 96 + minetest.register_craftitem(screw, { 97 + description = sorcery.lib.str.capitalize(name) .. ' Screw'; 98 + inventory_image = sorcery.lib.image('sorcery_screw.png'):multiply(sorcery.lib.color(metal.tone)):render(); 99 + groups = { metal = 1; sorcery_screw = 1; sorcery_tech_component = 1; }; 100 + _sorcery = { 101 + material = { 102 + id = name, data = metal; 103 + powder = powder; 104 + grindcost = 2, grindvalue = 1; 105 + value = 0.5; 106 + }; 97 107 }; 98 - }; 99 - }) 108 + }) 109 + local reglathe = function(ty, sz) 110 + sorcery.lathe.register { 111 + input = ty; 112 + output = {name = screw, count = sz * 2}; 113 + tech = 'cut', cost = 1; 114 + } 115 + end 116 + reglathe(fragment, 1) 117 + reglathe(ingot, 4) 118 + reglathe(block, 4 * 9) 119 + end 120 + 100 121 minetest.register_craftitem(disc, { 101 122 description = sorcery.lib.str.capitalize(name) .. ' Disc'; 102 123 inventory_image = fmt('sorcery_disc_%s.png', name); 103 124 groups = { metal = 1; sorcery_disc = 1; sorcery_tech_component = 1; }; 104 125 _sorcery = { 105 126 material = { 106 127 id = name, data = metal; 107 128 powder = powder; 108 - grindvalue = (3*4) / 2; 129 + grindcost = 3; 130 + grindvalue = 2*4; 109 131 value = 4 * (2/3); 110 132 }; 111 133 }; 112 134 }) 113 135 114 - local reglathe = function(ty, sz) 115 - sorcery.lathe.register { 116 - input = ty; 117 - output = {name = screw, count = sz * 2}; 118 - tech = 'cut', cost = 1; 119 - } 120 - end 121 - reglathe(fragment, 1) 122 - reglathe(ingot, 4) 123 - reglathe(block, 4 * 9) 124 - 125 136 sorcery.lathe.register { 126 137 input = ingot, mass = 2; 127 138 output = {name = disc, count = 3}; 128 139 tech = 'cut', cost = 5; 129 140 } 130 141 sorcery.lathe.register { 131 142 input = block;