Overview
Comment: | lathe is a mess but whatever i dont care it works now |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
77b901d9505d7405223a74300aa017b2 |
User & Date: | lexi on 2021-07-08 11:25:23 |
Other Links: | manifest | tags |
Context
2021-07-08
| ||
13:41 | commit missing texture check-in: aece454800 user: lexi tags: trunk | |
11:25 | lathe is a mess but whatever i dont care it works now check-in: 77b901d950 user: lexi tags: trunk | |
01:08 | add tool wear to lathe, add page turning sounds for cookbooks check-in: 0dbb4f52c3 user: lexi tags: trunk | |
Changes
Modified lathe.lua from [5af73c1767] to [1310436767].
29 29 local R = sorcery.lathe.recipes 30 30 sorcery.lathe.get = function(pos,idx,howmany) 31 31 local inv = minetest.get_meta(pos):get_inventory() 32 32 local tool = inv:get_stack('tool',1) 33 33 local tech = sorcery.lathe.tooltech(tool) 34 34 if not tech then return nil end 35 35 local wkpc = inv:get_stack('workpiece',1) 36 + howmany = howmany or wkpc:get_count() 36 37 local rec = R[wkpc:get_name()][tech][idx] 37 38 local outn = ItemStack(rec.output):get_count() 38 - local q = howmany / outn 39 + local ntimes = math.floor(howmany / (rec.mass or 1)) 39 40 return { 40 41 tool = tool, wkpc = wkpc; 41 - cost = rec.cost * q; 42 - qty = q, outn = outn; 42 + cost = rec.cost * ntimes; 43 + ntimes = ntimes; 44 + tqty = math.floor(howmany / outn), outn = outn; 45 + gqty = ntimes * outn; 43 46 tech = tech; 44 47 rec = rec; 45 48 inv = inv; 46 49 } 47 50 end 48 51 49 52 sorcery.lathe.update = function(pos) ................................................................................ 61 64 62 65 local tmat = sorcery.itemclass.get(tool:get_name(),'material') 63 66 local wmat = sorcery.itemclass.get(wkpc:get_name(),'material') 64 67 -- obey level restrictions. TODO honor Rend 65 68 if (wmat and wmat.data.level or 0) > (tmat and (tmat.data.maxlevel or tmat.data.level) or 0) then 66 69 return 67 70 end 68 - 71 + 69 72 local tech = sorcery.lathe.tooltech(tool) 70 73 local rec = R[wkpc:get_name()][tech] 71 74 tech = sorcery.lathe.techs[tech] 72 75 73 76 -- fill in the preview slots 74 77 local j = 1 75 - for i=1, inv:get_size('preview') do 76 - local stk 77 - if rec[i] and minetest.registered_items[ItemStack(rec[i].output):get_name()] then 78 - local max = wkpc:get_count() 78 + for i=1, inv:get_size 'preview' do 79 + local stk = ItemStack() 80 + 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 81 + local l = sorcery.lathe.get(pos, i, wkpc:get_count()) 82 + local max = l.ntimes --math.floor(wkpc:get_count() / (rec[i].mass or 1)) 79 83 if tech.dmg then 80 84 -- TODO count remaining tool uses 81 85 elseif tech.consume then 82 86 max = math.min(max, tool:get_count()) 83 87 end 84 88 if max > 0 then 85 89 stk = ItemStack(rec[i].output) 86 90 stk:set_count(stk:get_count() * max) 87 - inv:set_stack('preview',i,stk) 88 91 end 89 92 end 93 + inv:set_stack('preview',i,stk) 90 94 j = j + 1 91 95 end 92 96 93 97 -- make sure remaining slots are clear 94 98 for i = j, inv:get_size('preview') do 95 99 inv:set_stack('preview',i,ItemStack()) 96 100 end ................................................................................ 182 186 local lfac = 1 183 187 if mat then 184 188 local dur = mat.data.durability or dur 185 189 lfac = (mmat and mmat.data.level or 1) / 186 190 (mat.data.maxlevel or mat.data.level or 1) 187 191 end 188 192 local ch = 65535 / dur 189 - l.tool:add_wear(4 * ch * l.cost * lfac) 193 + l.tool:add_wear(ch * l.cost * lfac) 190 194 end 191 - l.wkpc:take_item(l.qty) 195 + l.wkpc:take_item(l.tqty) 192 196 l.inv:set_stack('tool', 1, l.tool) 193 197 l.inv:set_stack('workpiece', 1, l.wkpc) 198 + if l.rec.leftover then 199 + sorcery.lib.node.insert(ItemStack(l.rec.leftover), 'workpiece', pos, user, l.inv) 200 + end 194 201 minetest.sound_play('sorcery_clank', { pos = pos, gain = 0.9 }) 195 202 end 196 203 sorcery.lathe.update(pos) 197 204 end; 198 205 199 206 }) 200 207
Modified metal.lua from [816e3182ea] to [43593523a3].
44 44 -- for name, metal in pairs(sorcery.data.metals) do 45 45 sorcery.register.metals.foreach('sorcery:generate',{},function(name,metal) 46 46 local ingot = metal.ingot or 'sorcery:' .. name .. '_ingot' 47 47 local block = metal.block or 'sorcery:' .. name .. 'block' 48 48 local screw = 'sorcery:screw_' .. name 49 49 local fragment = 'sorcery:fragment_' .. name 50 50 local powder = 'sorcery:powder_' .. name 51 + local disc = 'sorcery:disc_' .. name 51 52 metal.parts = { 52 53 ingot = ingot; 53 54 block = block; 54 55 screw = screw; 55 56 fragment = fragment; 56 57 powder = powder; 58 + disc = disc; 57 59 } 58 60 if not metal.no_tools then for t,c in pairs(tools) do 59 61 sorcery.matreg.lookup[(metal.items and metal.items[t]) or ('sorcery:' .. t .. '_' .. name)] = { 60 62 metal = true; 61 63 id = name; data = metal; 62 64 value = c.cost * fragments_per_ingot; 63 65 } ................................................................................ 80 82 sorcery.data.metallookup[fragment] = { 81 83 id = name; data = metal; 82 84 value = 1; 83 85 } 84 86 minetest.register_craftitem(screw, { 85 87 description = sorcery.lib.str.capitalize(name) .. ' Screw'; 86 88 inventory_image = sorcery.lib.image('sorcery_screw.png'):multiply(sorcery.lib.color(metal.tone)):render(); 87 - groups = { 88 - metal = 1; 89 - sorcery_screw = 1; 90 - sorcery_tech_component = 1; 91 - }; 89 + groups = { metal = 1; sorcery_screw = 1; sorcery_tech_component = 1; }; 92 90 _sorcery = { 93 91 material = { 94 92 id = name, data = metal; 95 93 powder = powder; 96 94 grindcost = 2, grindvalue = 1; 97 95 value = 0.5; 98 96 }; 99 97 }; 100 98 }) 99 + minetest.register_craftitem(disc, { 100 + description = sorcery.lib.str.capitalize(name) .. ' Disc'; 101 + inventory_image = sorcery.lib.image('sorcery_disc.png'):multiply(sorcery.lib.color(metal.tone)):render(); 102 + groups = { metal = 1; sorcery_disc = 1; sorcery_tech_component = 1; }; 103 + _sorcery = { 104 + material = { 105 + id = name, data = metal; 106 + powder = powder; 107 + grindvalue = (3*4) / 2; 108 + value = 4 * (2/3); 109 + }; 110 + }; 111 + }) 112 + 101 113 local reglathe = function(ty, sz) 102 114 sorcery.lathe.register { 103 115 input = ty; 104 116 output = {name = screw, count = sz * 2}; 105 117 tech = 'cut', cost = 1; 106 118 } 107 119 end 108 120 reglathe(fragment, 1) 109 121 reglathe(ingot, 4) 110 122 reglathe(block, 4 * 9) 123 + 124 + sorcery.lathe.register { 125 + input = ingot, mass = 2; 126 + output = {name = disc, count = 3}; 127 + tech = 'cut', cost = 5; 128 + } 129 + sorcery.lathe.register { 130 + input = block; 131 + output = {name = disc, count = 8*3}; 132 + leftover = ingot; 133 + tech = 'cut', cost = 5*7; 134 + } 135 + 111 136 minetest.register_craftitem(powder, { 112 137 description = sorcery.lib.str.capitalize(name) .. ' Powder'; 113 138 inventory_image = 'sorcery_' .. name .. '_powder.png'; 114 139 }) 115 140 if metal.dye then 116 141 minetest.register_craft { 117 142 output = 'dye:' .. metal.dye .. ' 4';
Modified recipes.lua from [a1903de2a1] to [3fef19dac9].
368 368 -- used in constructing devices that are subject to attunement wand 369 369 regtech('gravity_manipulator', 'Gravity Manipulator', {metal = 1}) 370 370 regtech('valve','Valve', {metal = 1}, { 371 371 {'','default:bronze_ingot',''}; 372 372 {'basic_materials:plastic_sheet','basic_materials:steel_bar','basic_materials:plastic_sheet'}; 373 373 {'','default:bronze_ingot',''}; 374 374 },3,nil, mprop('bronze',2*4,1,2*4)) 375 -regtech('pipe','Pipe', {metal = 1}, { 376 - {ingot('aluminum'),'',ingot('aluminum')}; 377 - {ingot('aluminum'),'',ingot('aluminum')}; 378 - {ingot('aluminum'),'',ingot('aluminum')}; 379 -}, 6, nil, mprop('aluminum', 4)) 375 +regtech('pipe','Pipe', {metal = 1},nil, nil, nil, mprop('aluminum', 4)) 376 + 377 +sorcery.lathe.register { 378 + input = ingot('aluminum'); 379 + output = 'sorcery:pipe'; 380 + tech = 'cut', cost = 8; 381 +} 380 382 381 383 minetest.register_craft { 382 384 output = 'sorcery:trough'; 383 385 recipe = { 384 386 {ingot('aluminum'),'',ingot('aluminum')}; 385 387 {ingot('aluminum'),'',ingot('aluminum')}; 386 388 {ingot('aluminum'),ingot('aluminum'),ingot('aluminum')}; ................................................................................ 789 791 potion_auto_recipe(id,v,{'farming:mixing_bowl'},'xdecor:bowl') 790 792 end 791 793 end 792 794 793 795 sorcery.lathe.register { 794 796 output = 'basic_materials:steel_bar 2'; 795 797 input = 'default:steel_ingot'; 796 - tech = 'cut'; 797 - cost = 3; 798 + tech = 'cut', cost = 3; 799 +} 800 +sorcery.lathe.register { 801 + output = 'basic_materials:steel_bar 18'; 802 + input = 'default:steelblock'; 803 + tech = 'cut', cost = 3*9; 804 +} 805 +sorcery.lathe.register { 806 + output = 'basic_materials:steel_bar'; 807 + input = 'default:steel_fragment', mass = 2; 808 + tech = 'cut', cost = 2; 798 809 }