Terraria Wiki

Miss the old Hydra Skin? Try out our Hydralize gadget! Visit the preferences page while logged in and turn on the gadget.


Terraria Wiki
Template-info.svg Documentation The documentation below is transcluded from Template:Options/doc. (edit | history)

A common options mechanism for templates.



The configuration of options must be registered before the options can be used. It can be done via {{options/init}}, for example(It will be used for all following examples as well):

{{options/init|item<!-- init config for "item" namespace
-->|key:icons=yes<!--  declare an option named "icons", with a default value of "yes"
-->|key:small=no<!-- default value of "small" option is "no"
-->|value:small:n=no<!-- value "n" for "small" is same as "no", so {{options/set|item|small=n}} is same as {{options/set|item|small=no}}
-->|key:style=<!-- default value of "style" is empty value.
-->|alias:css=style<!-- "css" is an alias of "style", so {{options|item|css}} is same as {{options|item|style}}

It is possible to have it load automatically("autoload") via Template:<template_name>/initOptions. For example, for {{options|icon|small}}, it will try to transclude Template:item/initOptions.

Get/set options

Get: {{options/get|<template_name>|<key>}} or {{options|<template_name>|<key>}}

Set: {{options/set|<template_name>|<key1>=<value1>|<ke2>=<value2>|...}} or {{options|<template_name>|<key1>=<value1>|<key2>=<value2>|...}}

Note: The latter form is a bit slow, but more handy for writing. For using in templates the former is prefer, and for using in articles both are ok.


{{options/get|item|icons}}<!-- get default value -->
{{options/set|item|icons=no}}<!-- set it to "no" -->
{{options/get|item|icons}}<!-- now it will be "no" -->
{{options/set|item|icons=all|small=yes}}<!-- set multiple options -->

It will output: yes no all yes


It is possible to save current state of options to a snapshot, then restore it later.




-->{{options|item|icons}} {{options/get|item|small}} <!-- aa bb 
-->{{options|item|icons}} {{options/get|item|small}} <!-- xx yy 
-->{{options|item|icons}} {{options/get|item|small}} <!-- aa bb -->

It will output: aa bb xx yy aa bb

There is a special snapshot created during initialization, it can be restored via {{options/reset|<template_name>}}