@@ -15,7 +15,7 @@ local sfinv_only = core.settings:get_bool("craftguide_sfinv_only") and rawget(_G
15
15
16
16
local log = core .log
17
17
local after = core .after
18
- local clrz = core .colorize
18
+ local clr = core .colorize
19
19
local reg_tools = core .registered_tools
20
20
local reg_items = core .registered_items
21
21
local show_formspec = core .show_formspec
@@ -418,55 +418,48 @@ local function groups_to_items(groups, get_all)
418
418
return names
419
419
end
420
420
421
- local function not_repairable (tool )
421
+ local function repairable (tool )
422
422
local def = reg_tools [tool ]
423
- return toolrepair and def and def .groups and def .groups .disable_repair = = 1
423
+ return toolrepair and def and def .groups and def .groups .disable_repair ~ = 1
424
424
end
425
425
426
426
local function get_tooltip (item , info )
427
- local tooltip
428
-
429
- local function add (str )
430
- return tooltip .. " \n " .. str
431
- end
432
-
433
427
local function get_desc (def , name )
434
428
name = name or item
435
429
return def and def .description or
436
430
(def and match (name , " :.*" ):gsub (" %W%l" , upper ):sub (2 ):gsub (" _" , " " ) or
437
431
S (" Unknown Item (@1)" , name ))
438
432
end
439
433
434
+ local tooltip = get_desc (reg_items [item ])
435
+
436
+ local function add (str )
437
+ return tooltip .. " \n " .. str
438
+ end
439
+
440
440
if info .groups then
441
441
local groupstr , c = {}, 0
442
442
443
443
for i = 1 , # info .groups do
444
444
c = c + 1
445
- groupstr [c ] = clrz (" yellow" , info .groups [i ])
445
+ groupstr [c ] = clr (" yellow" , info .groups [i ])
446
446
end
447
447
448
448
groupstr = concat (groupstr , " , " )
449
449
tooltip = S (" Any item belonging to the group(s): @1" , groupstr )
450
- else
451
- local def = reg_items [item ]
452
- tooltip = get_desc (def )
453
-
454
- if info .norepair then
455
- tooltip = add (S (" This tool cannot be repaired" ))
456
- end
457
450
end
458
451
459
452
if info .cooktime then
460
- tooltip = add (S (" Cooking time: @1" , clrz (" yellow" , info .cooktime )))
453
+ tooltip = add (S (" Cooking time: @1" , clr (" yellow" , info .cooktime )))
461
454
end
462
455
463
456
if info .burntime then
464
- tooltip = add (S (" Burning time: @1" , clrz (" yellow" , info .burntime )))
457
+ tooltip = add (S (" Burning time: @1" , clr (" yellow" , info .burntime )))
465
458
end
466
459
467
460
if info .replace then
468
461
local def = reg_items [info .replace ]
469
- local desc = clrz (" yellow" , get_desc (def , info .replace ))
462
+ local desc = clr (" yellow" , get_desc (def , info .replace ))
470
463
471
464
if info .cooktime then
472
465
tooltip = add (S (" Replaced by @1 on smelting" , desc ))
@@ -477,6 +470,10 @@ local function get_tooltip(item, info)
477
470
end
478
471
end
479
472
473
+ if info .repair then
474
+ tooltip = add (S (" Repairable by step of @1" , clr (" yellow" , toolrepair .. " %" )))
475
+ end
476
+
480
477
return fmt (" tooltip[%s;%s]" , item , ESC (tooltip ))
481
478
end
482
479
@@ -523,23 +520,23 @@ local function get_output_fs(fs, L)
523
520
output_X , YOFFSET + (sfinv_only and 0.7 or 0 ),
524
521
1.1 , 1.1 , item , ESC (name ), " " )
525
522
526
- local norepair = not_repairable (item )
523
+ local repair = repairable (item )
527
524
528
- if burntime or norepair then
525
+ if burntime or repair then
529
526
fs [# fs + 1 ] = get_tooltip (name , {
530
527
burntime = burntime ,
531
- norepair = norepair ,
528
+ repair = repair ,
532
529
})
530
+ end
533
531
534
- if burntime then
535
- fs [# fs + 1 ] = fmt (FMT .image ,
536
- output_X + 1 , YOFFSET + (sfinv_only and 0.7 or 0.1 ),
537
- 0.6 , 0.4 , PNG .arrow )
532
+ if burntime then
533
+ fs [# fs + 1 ] = fmt (FMT .image ,
534
+ output_X + 1 , YOFFSET + (sfinv_only and 0.7 or 0.1 ),
535
+ 0.6 , 0.4 , PNG .arrow )
538
536
539
- fs [# fs + 1 ] = fmt (FMT .image ,
540
- output_X + 1.6 , YOFFSET + (sfinv_only and 0.55 or 0 ),
541
- 0.6 , 0.6 , PNG .fire )
542
- end
537
+ fs [# fs + 1 ] = fmt (FMT .image ,
538
+ output_X + 1.6 , YOFFSET + (sfinv_only and 0.55 or 0 ),
539
+ 0.6 , 0.6 , PNG .fire )
543
540
end
544
541
end
545
542
end
@@ -635,7 +632,7 @@ local function get_recipe_fs(data, fs)
635
632
burntime = burntime ,
636
633
cooktime = cooktime ,
637
634
replace = replace ,
638
- norepair = nil ,
635
+ repair = nil ,
639
636
}
640
637
641
638
for _ , v in pairs (infos ) do
@@ -694,7 +691,7 @@ local function make_formspec(name)
694
691
695
692
fs [# fs + 1 ] = fmt (" label[%f,%f;%s / %u]" ,
696
693
sfinv_only and 6.35 or 7.85 , 0.06 ,
697
- clrz (" yellow" , data .pagenum ), data .pagemax )
694
+ clr (" yellow" , data .pagenum ), data .pagemax )
698
695
699
696
fs [# fs + 1 ] = fmt ([[
700
697
image_button[%f,-0.05;0.8,0.8;%s;prev;;;false;%s^\[colorize:yellow:255]
@@ -855,7 +852,7 @@ core.register_craft = function(recipe)
855
852
old_register_craft (recipe )
856
853
857
854
if recipe .type == " toolrepair" then
858
- toolrepair = recipe .additional_wear ~= 0
855
+ toolrepair = recipe .additional_wear * - 100
859
856
end
860
857
861
858
local output = recipe .output or
@@ -1433,7 +1430,7 @@ register_command("craft", {
1433
1430
end
1434
1431
end
1435
1432
1436
- local red = clrz (" red" , " [craftguide] " )
1433
+ local red = clr (" red" , " [craftguide] " )
1437
1434
1438
1435
if not node_name then
1439
1436
return false , red .. S (" No node pointed" )
@@ -1450,7 +1447,7 @@ register_command("craft", {
1450
1447
end
1451
1448
1452
1449
if not recipes or # recipes == 0 then
1453
- local ylw = clrz (" yellow" , node_name )
1450
+ local ylw = clr (" yellow" , node_name )
1454
1451
local msg = red .. " %s: " .. ylw
1455
1452
1456
1453
if usages then
0 commit comments