Template:Sandbox/Drusna/Crafting/doc

From Vintage Story Wiki
This page contains changes which are not marked for translation.


An updated version of Template:Grid/Crafting with improved usability. DON'T USE THIS TEMPLATE - still in the development phase, subject to change entirely without notice.

Usage

See Template:Grid/Crafting for the original documentation.

{{Sandbox/Drusna/Crafting
|A1=c1r1 |A1N=num |A1-image=image (with extension) |A1-link=link |A1_name
|A2=c1r2 |A2N=num |A2-image=image (with extension) |A2-link=link |A2_name
|A3=c1r3 |A3N=num |A3-image=image (with extension) |A3-link=link |A3_name
|B1=c2r1 |B1N=num |B1-image=image (with extension) |B1-link=link |B1_name
|B2=c2r2 |B2N=num |B2-image=image (with extension) |B2-link=link |B2_name
|B3=c2r3 |B3N=num |B3-image=image (with extension) |B3-link=link |B3_name
|C1=c3r1 |C1N=num |C1-image=image (with extension) |C1-link=link |C1_name
|C2=c4r2 |C2N=num |C2-image=image (with extension) |C2-link=link |C2_name
|C3=c3r3 |C3N=num |C3-image=image (with extension) |C3-link=link |C3_name
|Output=out |OA=num |Output-link=link |Output_name=name
|NoBreak=y
}}

Features

Backwards compatibility

The new template should have the same layout properties as the old template when it's used without any newly-added features. This ensures that the >1500 pages which use Template:Grid/Crafting don't have their layout changed by the update.

NoBreak not used NoBreak=y
Old New Old New
float not used Text before



Bone



Bonemeal

Bonemeal

Bonemeal



Bone

Bone




Text after

Text before
3
5

Text after

Text before



Bone



Bonemeal

Bonemeal

Bonemeal



Bone

Bone



Text after

Text before
3
5

Text after

float=left Text before



Bone



Bonemeal

Bonemeal

Bonemeal



Bone

Bone




Text after

Text before
3
5

Text after

Text before



Bone



Bonemeal

Bonemeal

Bonemeal



Bone

Bone



Text after

Text before
3
5

Text after

float=right Text before



Bone



Bonemeal

Bonemeal

Bonemeal



Bone

Bone




Text after

Text before
3
5

Text after

Text before



Bone



Bonemeal

Bonemeal

Bonemeal



Bone

Bone



Text after

Text before
3
5

Text after

float=none Text before



Bone



Bonemeal

Bonemeal

Bonemeal



Bone

Bone




Text after

Text before
3
5

Text after

Text before



Bone



Bonemeal

Bonemeal

Bonemeal



Bone

Bone



Text after

Text before
3
5

Text after

Additionally, Template:Crafting should have its layout unaffected.

Old New
Ingredients Crafting Recipe
16x Compost
8x Bonemeal
8x Powdered charcoal
1x High fertility soil

Compost

Powder-charcoal

Compost

Bonemeal

Soil-compost-none

Bonemeal

Compost

Powder-charcoal

Compost

Soil-high-none

Soil-high-none

Soil-high-none

Compost

Compost

Powder-charcoal

Powder-charcoal

Compost

Compost

Bonemeal

Bonemeal

Bonemeal

Bonemeal

Compost

Compost

Powder-charcoal

Powder-charcoal

Compost

Compost


Ingredients Crafting Recipe
16x Compost
8x Bonemeal
8x Powdered charcoal
1x High fertility soil
Compost
4
Powdered charcoal
4
Compost
4
Bonemeal
4
High fertility soil
Bonemeal
4
Compost
4
Powdered charcoal
4
Compost
4
Terra Preta
2

Optional output slot

The new template allows you to only display a recipe's inputs by leaving the Output parameter empty. This is useful when the recipe's output is implied by context clues, and you want to save space or avoid redundancy.

Old method:

Ingredients Crafting Recipe
1x Knife or Shears
8x Pelt (Small) OR
5x Pelt (Medium) OR
3x Pelt (Large) OR
1x Pelt (Huge)
  • Pelt (Small)

    Pelt (Small)

    Pelt (Small)

    Knife (any) or shears (any)

    Pelt (Small)

    Pelt (Small)

    Pelt (Small)

    Pelt (Small)

    Pelt (Small)

    Fur coat







  • Pelt (Medium)

    Pelt (Medium)

    Knife (any) or shears (any)

    Pelt (Medium)

    Pelt (Medium)

    Pelt (Medium)

    Fur coat







  • Pelt (Large)


    Knife (any) or shears (any)

    Pelt (Large)

    Pelt (Large)


    Fur coat







  • Knife (any) or shears (any)


    Pelt (Huge)



    Fur coat







New method:

Output Crafting Recipes
Fur coat
Fur coat

 

 

 

New layout options

If any of the new parameters are used, then the float and NoBreak parameters are ignored.

halign

halign behaves similarly to MediaWiki images' horizontal alignment option (see [1]), and allows center alignment. A margin is automatically added between the template and nearby text.

halign= behavior test
Template Image
halign=none Text before the template.
5

Text after the template.

Text before an image.

Text after an image.

halign=center Text before the template.
5

Text after the template.

Text before an image.

Text after an image.

halign=left Text before the template.
5

Text after the template.

Text before an image.

Text after an image.

halign=right Text before the template.
5

Text after the template.

Text before an image.

Text after an image.

Default Text before the template.
5

Text after the template.

Text before an image.

Text after an image.

margin

Displaying multiple recipes side-by-side is a common use case. However, this is surprisingly difficult with the old template, causing different wiki pages to have different ways of doing this.

Option 1: use NoBreak and allow divs to all float left. For example, Plaster#Crafting_Plaster_Variants

  • No additional HTML/CSS, but we want more space between grids.
  • On mobile, the 3rd grid wraps to the next line, which creates uneven formatting.
  • Last recipe must have an added linebreak if there is any text following it, or else the templates float left of the following text.
1
2
3



Option 2: Put different recipes in different cells of a table. For example, Guide:Prepare_for_Winter#Warmth

  • No additional HTML/CSS, but using a table limits formatting options.
  • Space between grids is determined by table padding.
  • Looks the same on mobile as on desktop; users scroll horizontally to see all the recipes.
1
2
3

Option 3: Wrap recipes in <div style="display:flex">...</div>. For example, Axe#Creation.

  • To add space between recipes, each one can be wrapped in another div with style="margin-right:10px", as in Knife#Creation.
  • Alternatively, you can use float=none and NoBreak=y on each template and add &nbsp; between them, as is done elsewhere on this page
  • Similarly, you can use <ul> and <li> elements, as in Fur_clothing_set
  • Allows precise control, but requires HTML/CSS knowledge
  • Will be implemented differently on every page, leading to inconsistency across the wiki
1
2
3

Option 4: Use the new margin parameter.

  • Achieves the same thing as the flexbox solution, but without requiring HTML.
1
2
3



Additional text for example purposes

Fixes

Background image

The old template's background crafting grid image () has a number of issues:

  • The gap between columns 2 and 3 is 1 pixel too wide; same for rows 2 and 3
  • The top margin is 1px larger than the other margins
  • The image gets resized from 189px to 174px by the template, which introduces artifacts

The new template uses a new image ( and ) which solves these issues, and reduces the margin by 5px.

Rendering items and numbers

Issues with the old template:

  • Elements are wrapped in <p> blocks, which causes items and numbers to be misaligned on mobile or with different font sizes
  • Numbers in a crafting grid inside a collapsible table don't render at all on mobile due to a MediaWiki bug involving lazy-loaded images
  • Hovering your mouse over the 10s place of a 1-digit number causes the link and hover text to disappear

The new template fixes these issues, and:

  • Matches the in-game font and improves readability
  • Matches the in-game size of items
  • Can render arbitrary numbers
New Old
1
23
45
67
89
100
Oak Log
0
-1
1.5
99

Bone

Stick

Leather

Cloth

Fat

Resin

Log

Copper_Ingot

Rusty_gear

Temporal_gear

Temporal_gear

Temporal_gear

Bone

Bone

Stick

Stick

Leather

Leather

Cloth

Cloth

Fat

Fat

Resin

Resin

Log

Log

Copper_Ingot

Copper_Ingot

Rusty_gear

Rusty_gear


Tests

Placeholder puppy


Link, name, image tests

The hover-text for an item should be determined using the name parameter if it's used, or the linked page's title otherwise.

Brick
Not A Real Name



Number rendering tests

  • Numbers should look the same regardless of sub-pixel positioning of the template
  • There should be a 1 pixel gap between the number and the bottom/right of the grid cell
  • Numbers should have a consistent 1 pixel outline and no blurry edges
Left Center Right
Try resizing this cell using the handle in the lower right corner.
Try resizing this cell using the handle in the lower right corner.
1
4
7
2
5
8
3
6
9
10
1
4
7
2
5
8
3
6
9
10
1
4
7
2
5
8
3
6
9
10
11
14
17
12
15
18
13
16
19
20
11
14
17
12
15
18
13
16
19
20
11
14
17
12
15
18
13
16
19
20
21
24
27
22
25
28
23
26
29
30
21
24
27
22
25
28
23
26
29
30
21
24
27
22
25
28
23
26
29
30