Differences From
Artifact [569141ccf4]:
- File
crafttools.lua
— part of check-in
[72eebac4bc]
at
2020-09-26 18:49:51
on branch trunk
— add writing stand for editing codexes; add scissors, ink, erasure fluid, pens; touch up codex UI; add many recipe notes; add craft divination type for crafttools; defuckulate fucktarded crafttool impl; enhance table library with missing features like lua's table.unpack; many bug fixes and enhancements; blood for the blood god
(user:
lexi,
size: 1100)
[annotate]
[blame]
[check-ins using]
1 1 minetest.register_on_craft(function(stack,crafter,recipe,grid)
2 - local ctoolclass = {
3 - [1] = 200;
4 - [2] = 100;
5 - [3] = 50;
6 - [4] = 10;
7 - [5] = 5;
8 - }
9 2 for i=1,grid:get_size('craft') do
10 3 local s = grid:get_stack('craft',i)
11 4 local v = minetest.get_item_group(s:get_name(),'crafttool')
12 5 if v ~= 0 then
13 - local dmg = 65536 / ctoolclass[v]
6 + local dmg = 65536 / v
14 7 local tool = recipe[i]
15 8 tool:add_wear(dmg)
16 9 grid:set_stack('craft',i,tool)
17 10 end
18 11 end
19 12 return nil
20 13 end)
21 14
22 -if minetest.get_modpath('xdecor') then
23 - local og = minetest.registered_tools['xdecor:hammer'].groups
24 - og.crafttool = 2
25 - minetest.override_item('xdecor:hammer', {groups = og})
15 +local mod_override = function(mod,name,val)
16 + if minetest.get_modpath(mod) then
17 + local id = mod..':'..name
18 + local og = minetest.registered_tools[id].groups
19 + og.crafttool = val
20 + minetest.override_item(id, {groups = og})
21 + end
26 22 end
23 +
24 +mod_override('xdecor', 'hammer', 70)
25 +mod_override('screwdriver','screwdriver',40)
27 26
28 27 minetest.register_tool('sorcery:vice', {
29 28 description = 'Vice';
30 29 inventory_image = 'sorcery_vice.png';
31 - group = { crafttool = 3; }
30 + group = { crafttool = 100; }
32 31 })
33 32 minetest.register_craft {
34 33 output = 'sorcery:vice';
35 34 recipe = {
36 35 {'default:steel_ingot','sorcery:screw_steel','default:steel_ingot'};
37 36 {'default:bronze_ingot','sorcery:screw_steel','default:bronze_ingot'};
38 37 {'default:tin_ingot','default:tin_ingot','default:tin_ingot'};
39 38 };
40 39 }
41 40 -- chisel