Vintage Story Wiki:Infobox tutorial
Using infoboxes can be daunting. This tutorial should give you a bit of a feel for them and help you work on the wiki!
Syntax
Infoboxes, and all templates actually, have similar syntax.
{{TemplateName |Param1=value |Param2=value ... }}
In this example, the name is TemplateName
. When inserting, formally "transcluding", a template into a page you will change this name. The parameters Param1
and Param2
are named parameters. This means that they are referenced by name. Other parameters can be unnamed or anonymous parameters meaning they are not referred to by name. When transcluding the template it would look like this...
{{TemplateWithAnonParams |value }}
Some templates may utilize more than one anon parameter, in which case, you must be aware of the order of the values. When using named parameters, order does not matter however anon parameters must be in the correct order. When using a template that has both named and anon parameters, the anon parameters must be in the expected order, but named parameters do not have to be. Thus, in the following three examples, the first two are equivalent to each other but the third is not.
{{BothAnonAndNamedParams |Param=value1 |value2 |value3 }} {{BothAnonAndNamedParams |value2 |value3 |Param=value1 }} {{BothAnonAndNamedParams |value3 |value2 |Param=value1 }}
Documentation
Most templates should have a documentation table with them. A table will list the names of all parameters, whether they are required or optional and if there is a default value, and an example value.
Parameter | Required or Optional, default if applicable | Example |
---|---|---|
Name | Required | Dirt |
Stackable | Optional, 64 | 64 |
Material | Optional | Soil |
This shows the template has 3 parameters, Name
, Stackable
, and Material
. Name
is required; it must be defined for the template to be correct. When a require parameter isn't specified, not defined, it will appear as {{{Name}}} on the page. Stackable
is optional; it may or may not be defined. If there is a second value after "Optional" that is the default value. Stackable
defaults to 64. Material
is optional but does not have a default value.
Additional notes
Infoboxes can be positioned on screen by surrounding them with div
HTML tags. For pages with multiple infoboxes the following groups them cleanly:
<div style="display:flex"> {{Template}} </div>