1
1
craftguide = {}
2
2
3
+ craftguide .background = " craftguide_bg_full.png"
4
+
3
5
local pdata = {}
4
6
local core = core
5
7
@@ -443,15 +445,11 @@ local function get_recipe_fs(data)
443
445
fs [# fs + 1 ] = fmt (FMT .button ,
444
446
xoffset + (sfinv_only and 1.98 or 2.7 ),
445
447
yoffset + (sfinv_only and 1.9 or 1.2 ),
446
- 2.2 ,
447
- 1 ,
448
- " alternate" ,
449
- btn_lab )
448
+ 2.2 , 1 , " alternate" , btn_lab )
450
449
451
450
if width > GRID_LIMIT or rows > GRID_LIMIT then
452
451
fs [# fs + 1 ] = fmt (FMT .label ,
453
- sfinv_only and 2 or 3 ,
454
- 7 ,
452
+ sfinv_only and 2 or 3 , 7 ,
455
453
ESC (S (" Recipe is too big to be displayed (@1x@2)" , width , rows )))
456
454
457
455
return concat (fs )
@@ -491,13 +489,8 @@ local function get_recipe_fs(data)
491
489
local label = groups and " \n G" or " "
492
490
493
491
fs [# fs + 1 ] = fmt (FMT .item_image_button ,
494
- X ,
495
- Y + (sfinv_only and 0.7 or 0 ),
496
- btn_size ,
497
- btn_size ,
498
- item ,
499
- match (item , " %S*" ),
500
- ESC (label ))
492
+ X , Y + (sfinv_only and 0.7 or 0 ),
493
+ btn_size , btn_size , item , match (item , " %S*" ), ESC (label ))
501
494
502
495
local burntime = fuel_cache [item ]
503
496
@@ -519,69 +512,44 @@ local function get_recipe_fs(data)
519
512
local pos_y = yoffset + (sfinv_only and 0.25 or - 0.45 )
520
513
521
514
fs [# fs + 1 ] = fmt (FMT .image ,
522
- min (3.9 , rightest ) + 1.2 ,
523
- pos_y ,
524
- 0.5 ,
525
- 0.5 ,
526
- icon )
515
+ min (3.9 , rightest ) + 1.2 , pos_y , 0.5 , 0.5 , icon )
527
516
528
517
local tooltip = custom_recipe and custom_recipe .description or
529
518
shapeless and S (" Shapeless" ) or S (" Cooking" )
530
519
531
520
fs [# fs + 1 ] = fmt (" tooltip[%f,%f;%f,%f;%s]" ,
532
- rightest + 1.2 ,
533
- pos_y ,
534
- 0.5 ,
535
- 0.5 ,
536
- ESC (tooltip ))
521
+ rightest + 1.2 , pos_y , 0.5 , 0.5 , ESC (tooltip ))
537
522
end
538
523
539
524
local arrow_X = rightest + (s_btn_size or 1.1 )
540
525
local output_X = arrow_X + 0.9
541
526
542
527
fs [# fs + 1 ] = fmt (FMT .image ,
543
- arrow_X ,
544
- yoffset + (sfinv_only and 0.9 or 0.2 ),
545
- 0.9 ,
546
- 0.7 ,
547
- " craftguide_arrow.png" )
528
+ arrow_X , yoffset + (sfinv_only and 0.9 or 0.2 ),
529
+ 0.9 , 0.7 , " craftguide_arrow.png" )
548
530
549
531
if recipe .type == " fuel" then
550
532
fs [# fs + 1 ] = fmt (FMT .image ,
551
- output_X ,
552
- yoffset + (sfinv_only and 0.7 or 0 ),
553
- 1.1 ,
554
- 1.1 ,
555
- " craftguide_fire.png" )
533
+ output_X , yoffset + (sfinv_only and 0.7 or 0 ),
534
+ 1.1 , 1.1 , " craftguide_fire.png" )
556
535
else
557
536
local output_name = match (recipe .output , " %S+" )
558
537
local burntime = fuel_cache [output_name ]
559
538
560
539
fs [# fs + 1 ] = fmt (FMT .item_image_button ,
561
- output_X ,
562
- yoffset + (sfinv_only and 0.7 or 0 ),
563
- 1.1 ,
564
- 1.1 ,
565
- recipe .output ,
566
- ESC (output_name ),
567
- " " )
540
+ output_X , yoffset + (sfinv_only and 0.7 or 0 ),
541
+ 1.1 , 1.1 , recipe .output , ESC (output_name ), " " )
568
542
569
543
if burntime then
570
544
fs [# fs + 1 ] = get_tooltip (output_name , nil , nil , burntime )
571
545
572
546
fs [# fs + 1 ] = fmt (FMT .image ,
573
- output_X + 1 ,
574
- yoffset + (sfinv_only and 0.7 or 0.1 ),
575
- 0.6 ,
576
- 0.4 ,
577
- " craftguide_arrow.png" )
547
+ output_X + 1 , yoffset + (sfinv_only and 0.7 or 0.1 ),
548
+ 0.6 , 0.4 , " craftguide_arrow.png" )
578
549
579
550
fs [# fs + 1 ] = fmt (FMT .image ,
580
- output_X + 1.6 ,
581
- yoffset + (sfinv_only and 0.55 or 0 ),
582
- 0.6 ,
583
- 0.6 ,
584
- " craftguide_fire.png" )
551
+ output_X + 1.6 , yoffset + (sfinv_only and 0.55 or 0 ),
552
+ 0.6 , 0.6 , " craftguide_fire.png" )
585
553
end
586
554
end
587
555
@@ -595,41 +563,44 @@ local function make_formspec(name)
595
563
local fs = {}
596
564
597
565
if not sfinv_only then
598
- fs [# fs + 1 ] = fmt (" size[%f,%f;]" , 9.5 , 8.4 )
599
-
600
- fs [# fs + 1 ] = [[
566
+ fs [# fs + 1 ] = fmt ([[
567
+ size[%f,%f;]
601
568
no_prepend[]
602
569
bgcolor[#00000000;false]
603
- background[1,1;1,1;craftguide_bg_full.png;true;10]
604
- ]]
570
+ background[1,1;1,1;%s;true;10]
571
+ ]] ,
572
+ 9.5 , 8.4 , craftguide .background )
605
573
end
606
574
607
- fs [# fs + 1 ] = fmt (" field[0.25,0.2;%f,1;filter;;%s]" ,
608
- sfinv_only and 2.76 or 2.72 ,
609
- ESC (data .filter ))
575
+ fs [# fs + 1 ] = fmt ([[
576
+ field[0.25,0.2;%f,1;filter;;%s]
577
+ field_close_on_enter[filter;false]
578
+ ]] ,
579
+ sfinv_only and 2.76 or 2.72 , ESC (data .filter ))
580
+
581
+ local search_icon = " craftguide_search_icon.png"
582
+ local clear_icon = " craftguide_clear_icon.png"
610
583
611
- fs [# fs + 1 ] = fmt (
612
- " field_close_on_enter[filter;false]\
613
- image_button[%f,-0.05;0.85,0.85;craftguide_search_icon.png;search;;;false;" ..
614
- " craftguide_search_icon.png^\\ [colorize:yellow:255]" ..
615
- " image_button[%f,-0.05;0.85,0.85;craftguide_clear_icon.png;clear;;;false;" ..
616
- " craftguide_clear_icon.png^\\ [colorize:red:255]" ,
617
- sfinv_only and 2.6 or 2.54 ,
618
- sfinv_only and 3.3 or 3.25 )
584
+ fs [# fs + 1 ] = fmt ([[
585
+ image_button[%f,-0.05;0.85,0.85;%s;search;;;false;%s^\[colorize:yellow:255]
586
+ image_button[%f,-0.05;0.85,0.85;%s;clear;;;false;%s^\[colorize:red:255]
587
+ ]] ,
588
+ sfinv_only and 2.6 or 2.54 , search_icon , search_icon ,
589
+ sfinv_only and 3.3 or 3.25 , clear_icon , clear_icon )
619
590
620
591
fs [# fs + 1 ] = fmt (" label[%f,%f;%s / %u]" ,
621
- sfinv_only and 6.35 or 7.85 ,
622
- 0.06 ,
623
- colorize ( " yellow " , data . pagenum ),
624
- data . pagemax )
625
-
626
- fs [ # fs + 1 ] = fmt (
627
- " image_button[%f,-0.05;0.8,0.8;craftguide_prev_icon.png;prev;;;false; " ..
628
- " craftguide_prev_icon.png^ \\ [colorize:yellow:255]" ..
629
- " image_button[%f,-0.05;0.8,0.8;craftguide_next_icon.png ;next;;;false;" ..
630
- " craftguide_next_icon.png^ \\ [colorize:yellow:255] " ,
631
- sfinv_only and 5.45 or 6.83 ,
632
- sfinv_only and 7.2 or 8.75 )
592
+ sfinv_only and 6.35 or 7.85 , 0.06 ,
593
+ colorize ( " yellow " , data . pagenum ), data . pagemax )
594
+
595
+ local prev_icon = " craftguide_next_icon.png^ \\ [transformFX "
596
+ local next_icon = " craftguide_next_icon.png "
597
+
598
+ fs [ # fs + 1 ] = fmt ( [[
599
+ image_button[%f,-0.05;0.8,0.8;%s;prev;;;false;%s^\ [colorize:yellow:255]
600
+ image_button[%f,-0.05;0.8,0.8;%s ;next;;;false;%s^\[colorize:yellow:255]
601
+ ]] ,
602
+ sfinv_only and 5.45 or 6.83 , prev_icon , prev_icon ,
603
+ sfinv_only and 7.2 or 8.75 , next_icon , next_icon )
633
604
634
605
if # data .items == 0 then
635
606
local no_item = S (" No item to show" )
@@ -654,10 +625,7 @@ local function make_formspec(name)
654
625
fs [# fs + 1 ] = fmt (" item_image_button[%f,%f;%f,%f;%s;%s_inv;]" ,
655
626
X - (X * (sfinv_only and 0.12 or 0.14 )) - 0.05 ,
656
627
Y - (Y * 0.1 ) - 0.1 ,
657
- 1 ,
658
- 1 ,
659
- item ,
660
- item )
628
+ 1 , 1 , item , item )
661
629
end
662
630
663
631
if data .recipes and # data .recipes > 0 then
0 commit comments