Шаблон:Инвентарный слот/док — различия между версиями
[непроверенная версия] | [непроверенная версия] |
MailGik (обсуждение | вклад) (Новая страница: «{{Документация/Шапка}} <!-- Документацию следует размещать здесь --> {{Lua}} Этот шаблон исполь…») |
MailGik (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
{{Документация/Шапка}} | {{Документация/Шапка}} | ||
− | |||
{{Lua}} | {{Lua}} | ||
− | + | The inventory slot template creates an interface element which looks and acts like an in-game inventory slot. | |
− | == | + | The images used are primarily taken from {{tl|ИнвСпрайт}}, but if the specified item is not found, the template falls back to individual images in the format of <code>Grid ''<item name>''.png</code>. |
− | + | ||
+ | == Usage == | ||
+ | All inputs are optional:<br> | ||
+ | <pre>{{Слот | ||
+ | |[Title]Mod:Name,Amount[Description]; [Title2]Mod2:Name2,Amount2[Description2]; ... | ||
+ | |mod=Default mod (useful for animations and layout templates) | ||
+ | |default=Image always shown under the main image | ||
+ | |align=Vertical Alignment | ||
+ | |link=Link override | ||
+ | |title=Text show on mouseover | ||
+ | |class=Adds additional classes to the .invslot class | ||
+ | |style=Adds styling to the .invslot | ||
+ | |imgclass=Adds additional classes to the .invslot-item | ||
+ | |numstyle=Adds styling to the stack number | ||
+ | }}</pre> | ||
+ | |||
+ | === Parts === | ||
+ | The first parameter is a special parameter consisting of various "parts" grouped together in frames (delimited by <code>;</code>) which will be display one after another if JavaScript is enabled. Every part is optional, but without "name", won't do anything. | ||
+ | |||
+ | ==== Simple example ==== | ||
+ | To display an inventory item of "Raw Porkchop" with an stack size of 20 you would put: <code><nowiki>{{Слот|Raw Porkchop,20}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|Жареная свинина,20}} | ||
+ | |||
+ | An amount of 2–999 is supported, anything else will not be displayed. | ||
+ | |||
+ | If no image is specified, an empty slot is displayed, this could be used to do layouts like so: | ||
+ | <pre style="width:550px">{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}<br> | ||
+ | {{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}<br> | ||
+ | {{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}<br> | ||
+ | {{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}<br> | ||
+ | {{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}<br> | ||
+ | {{Слот}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот}}</pre> | ||
+ | ;shows | ||
+ | {{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}<br> | ||
+ | {{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}<br> | ||
+ | {{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}<br> | ||
+ | {{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}<br> | ||
+ | {{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}<br> | ||
+ | {{Слот}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот}} | ||
+ | |||
+ | However this is really inefficient and produces ugly code, so don't do this. Use [[Template:BlockGrid]] or [[Template:Schematic]] instead. | ||
+ | |||
+ | === Aliases === | ||
+ | {{#invoke: Inventory slot/Aliases/Table | table }} | ||
+ | Note: Banner variations are not included due to how many there are. | ||
+ | |||
+ | The above aliases can be used to shorten common items, such as all wood blocks or adding parts to certain names by default. | ||
+ | |||
+ | <code><nowiki>{{Слот|Any Wood;Golden Apple}}</nowiki></code> | ||
+ | |||
+ | ;shows | ||
+ | {{Слот|Any Wood;Golden Apple}} | ||
+ | |||
+ | |||
+ | When using the alias, parts can be added which will override any parts in the alias. | ||
+ | |||
+ | <code><nowiki>{{Слот|Any Wood,4;[&oShiny Apple]Enchanted Golden Apple}}</nowiki></code> | ||
+ | |||
+ | ;shows | ||
+ | {{Слот|Any Wood,4;[&oShiny Apple]Enchanted Golden Apple}} | ||
+ | |||
+ | |||
+ | Mods can specify an additional aliases table using the modaliases parameter. | ||
+ | |||
+ | === Titles and description === | ||
+ | The title parameter can be used to set a title for all frames. | ||
+ | |||
+ | <code><nowiki>{{Слот|Raw Porkchop; Cooked Porkchop|title=Smelly Pork}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|Raw Porkchop; Cooked Porkchop|title=Smelly Porkchop}} | ||
+ | |||
+ | |||
+ | To remove the title, set it to "none": <code><nowiki>{{Слот|Raw Porkchop; Cooked Porkchop|title=none}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|Raw Porkchop; Cooked Porkchop|title=none}} | ||
+ | |||
+ | |||
+ | However, the first bracketed text can be used to specify a title for each frame individually, and also supports standard [[formatting codes]] using <code>&</code> instead of <code>§</code>. If the title only contains formatting codes and no actual text, the formatting will be added to the normal title. | ||
+ | |||
+ | <code><nowiki>{{Слот|[&b]Diamond Sword}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|[&b]Diamond Sword}} | ||
+ | |||
+ | |||
+ | The last bracketed text can be used to specify a description, this also supports standard formatting codes, and can also have multiple lines by using forward slashes (/). | ||
+ | |||
+ | <code><nowiki>{{Слот|[&b&oExcalibur]Iron Sword[&7Smite V/Fire Aspect I//&9+6 Attack Damage]}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|[&b&oExcalibur]Iron Sword[&7Smite V/Fire Aspect I//&9+6 Attack Damage]}} | ||
+ | |||
+ | === Align === | ||
+ | Align uses the [http://www.w3.org/wiki/CSS/Properties/vertical-align vertical-align] CSS property. For example to align to the middle: | ||
+ | <code><nowiki>Smells like {{Слот|Raw Porkchop|align=middle}} in here!</nowiki></code> | ||
+ | ;shows | ||
+ | Smells like {{Слот|Raw Porkchop|align=middle}} in here! | ||
+ | |||
+ | === Default === | ||
+ | Default is always shown and is placed under the image. <code><nowiki>{{Слот|default=Grid layout Brewing Empty}}{{Слот|Splash Mundane Potion|default=Grid layout Brewing Empty}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|default=Grid layout Brewing Empty}}{{Слот|Splash Mundane Potion|default=Grid layout Brewing Empty}} | ||
+ | |||
+ | === Link === | ||
+ | To change the link for all frames from the image name put: <code><nowiki>{{Слот|Charcoal|link=Coal#Charcoal}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|Charcoal|link=Coal#Charcoal}} | ||
+ | |||
+ | |||
+ | To remove the link, set link to none: <code><nowiki>{{Слот|Charcoal|link=none}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|Charcoal|link=none}} | ||
+ | |||
+ | Note that this retains the title. | ||
+ | |||
+ | |||
+ | === Mods === | ||
+ | <!-- TODO: Update for sprite usage --> | ||
+ | A mod image is specified with the Mod: section of the name (or by setting a default mod using the mod parameter). The image link will then link to the mod sub-page allowing correct linking of mod images. The uploaded image name should by uploaded as <code>Grid <Name> (<Mod>).png</code> and should be added to the [[:Category:Inventory slot mods|Inventory slot mods]] category, which prevents them from being confused with official Minecraft items.<br> | ||
+ | For example, to display this mod image [[:File:Grid Bronze Sword (IndustrialCraft).png]]: <code><nowiki>{{Слот|IndustrialCraft:Bronze Sword}}</nowiki></code> (or <code><nowiki>{{Слот|mod=IndustrialCraft|Bronze Sword}}</nowiki></code>) | ||
+ | ;shows | ||
+ | {{Слот|IndustrialCraft:Bronze Sword}} | ||
+ | |||
+ | |||
+ | Слотs can be animated with a theoretically unlimited amount of frames, between mod items and vanilla items. Frames are separated by semi-colons (;). | ||
+ | <pre>{{Слот| | ||
+ | Dirt; | ||
+ | ТНТ,64; | ||
+ | IndustrialCraft:Bronze Sword,6; | ||
+ | ; | ||
+ | Grass Block,5; | ||
+ | Sand; | ||
+ | Gold Helmet,12; | ||
+ | IndustrialCraft:Bronze Helmet,2; | ||
+ | IndustrialCraft:Copper,50; | ||
+ | Redstone | ||
+ | }}</pre> | ||
+ | ;shows | ||
+ | {{Слот| | ||
+ | Dirt; | ||
+ | ТНТ,64; | ||
+ | IndustrialCraft:Bronze Sword,6; | ||
+ | ; | ||
+ | Grass Block,5; | ||
+ | Sand; | ||
+ | Gold Helmet,12; | ||
+ | IndustrialCraft:Bronze Helmet,2; | ||
+ | IndustrialCraft:Copper,50; | ||
+ | Redstone | ||
+ | }} | ||
+ | |||
+ | As you can see, the mod had to be specified for each mod frame, this is where the default mod parameter is useful. | ||
+ | <code><nowiki>{{Слот|mod=IndustrialCraft|Bronze Sword,6; ; Bronze Helmet,12; Copper,50; Copper Dust}}</nowiki></code> | ||
+ | ;shows | ||
+ | {{Слот|mod=IndustrialCraft|Bronze Sword,6; ; Bronze Helmet,12; Copper,50; Copper Dust}} | ||
+ | |||
+ | To use a vanilla minecraft item when a default mod is set, use "vanilla" (shortcut "v") or "minecraft" (shortcut "mc") as the mod (case insensitive). | ||
+ | <pre>{{Слот|mod=IndustrialCraft| | ||
+ | Vanilla:Dirt; | ||
+ | vanilla:ТНТ,64; | ||
+ | Bronze Sword,6; | ||
+ | ; | ||
+ | V:Grass Block,5; | ||
+ | v:Sand; | ||
+ | Minecraft:Gold Helmet,12; | ||
+ | Bronze Helmet,2; | ||
+ | Copper,50; | ||
+ | mc:Redstone Dust | ||
+ | }}</pre> | ||
+ | ;shows | ||
+ | {{Слот|mod=IndustrialCraft| | ||
+ | Vanilla:Dirt; | ||
+ | vanilla:ТНТ,64; | ||
+ | Bronze Sword,6; | ||
+ | ; | ||
+ | V:Grass Block,5; | ||
+ | v:Sand; | ||
+ | Minecraft:Gold Helmet,12; | ||
+ | Bronze Helmet,2; | ||
+ | Copper,50; | ||
+ | mc:Redstone Dust | ||
+ | }} | ||
+ | |||
+ | == Available images == | ||
+ | |||
+ | {{InvSprite/Image list}} | ||
+ | |||
+ | == Other templates == | ||
+ | |||
+ | These templates implement this template into a GUI screen which mimics how it would look in Minecraft. Thus, they have mostly the same features as this template. | ||
+ | {{UI see also}} | ||
<includeonly> | <includeonly> | ||
− | <!-- | + | <!-- Template categories/interwiki here --> |
+ | [[Category:Image templates]] | ||
+ | [[Category:Inventory templates]] | ||
</includeonly> | </includeonly> | ||
<noinclude> | <noinclude> | ||
− | <!-- | + | <!-- Documentation categories/interwiki here --> |
</noinclude> | </noinclude> |
Версия 13:14, 7 августа 2016
Это страница документации, её следует включить в основную страницу этого шаблона. Для дополнительной информации см. Шаблон:Документация.
Этот шаблон использует Модуль:Инвентарный слот, написанный на языке программирования Lua. Пожалуйста, просмотрите wikipedia:Wikipedia:Lua и mw:Extension:Scribunto (обе англ.) для понимания работы модуля. |
The inventory slot template creates an interface element which looks and acts like an in-game inventory slot.
The images used are primarily taken from {{ИнвСпрайт}}, but if the specified item is not found, the template falls back to individual images in the format of Grid <item name>.png
.
Содержание
Usage
All inputs are optional:
{{Слот |[Title]Mod:Name,Amount[Description]; [Title2]Mod2:Name2,Amount2[Description2]; ... |mod=Default mod (useful for animations and layout templates) |default=Image always shown under the main image |align=Vertical Alignment |link=Link override |title=Text show on mouseover |class=Adds additional classes to the .invslot class |style=Adds styling to the .invslot |imgclass=Adds additional classes to the .invslot-item |numstyle=Adds styling to the stack number }}
Parts
The first parameter is a special parameter consisting of various "parts" grouped together in frames (delimited by ;
) which will be display one after another if JavaScript is enabled. Every part is optional, but without "name", won't do anything.
Simple example
To display an inventory item of "Raw Porkchop" with an stack size of 20 you would put: {{Слот|Raw Porkchop,20}}
- shows
20
An amount of 2–999 is supported, anything else will not be displayed.
If no image is specified, an empty slot is displayed, this could be used to do layouts like so:
{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}<br> {{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}<br> {{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}{{Слот}}<br> {{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}<br> {{Слот}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот|ТНТ}}{{Слот}}<br> {{Слот}}{{Слот|ТНТ}}{{Слот}}{{Слот}}{{Слот|ТНТ}}{{Слот}}
- shows
However this is really inefficient and produces ugly code, so don't do this. Use Template:BlockGrid or Template:Schematic instead.
Aliases
Ошибка скрипта: Нет такого модуля, как «Inventory slot/Aliases/Table». Note: Banner variations are not included due to how many there are.
The above aliases can be used to shorten common items, such as all wood blocks or adding parts to certain names by default.
{{Слот|Any Wood;Golden Apple}}
- shows
When using the alias, parts can be added which will override any parts in the alias.
{{Слот|Any Wood,4;[&oShiny Apple]Enchanted Golden Apple}}
- shows
Mods can specify an additional aliases table using the modaliases parameter.
Titles and description
The title parameter can be used to set a title for all frames.
{{Слот|Raw Porkchop; Cooked Porkchop|title=Smelly Pork}}
- shows
To remove the title, set it to "none": {{Слот|Raw Porkchop; Cooked Porkchop|title=none}}
- shows
However, the first bracketed text can be used to specify a title for each frame individually, and also supports standard formatting codes using &
instead of §
. If the title only contains formatting codes and no actual text, the formatting will be added to the normal title.
{{Слот|[&b]Diamond Sword}}
- shows
The last bracketed text can be used to specify a description, this also supports standard formatting codes, and can also have multiple lines by using forward slashes (/).
{{Слот|[&b&oExcalibur]Iron Sword[&7Smite V/Fire Aspect I//&9+6 Attack Damage]}}
- shows
Align
Align uses the vertical-align CSS property. For example to align to the middle:
Smells like {{Слот|Raw Porkchop|align=middle}} in here!
- shows
Smells like Raw Porkchop
in here!
Default
Default is always shown and is placed under the image. {{Слот|default=Grid layout Brewing Empty}}{{Слот|Splash Mundane Potion|default=Grid layout Brewing Empty}}
- shows
Link
To change the link for all frames from the image name put: {{Слот|Charcoal|link=Coal#Charcoal}}
- shows
To remove the link, set link to none: {{Слот|Charcoal|link=none}}
- shows
Note that this retains the title.
Mods
A mod image is specified with the Mod: section of the name (or by setting a default mod using the mod parameter). The image link will then link to the mod sub-page allowing correct linking of mod images. The uploaded image name should by uploaded as Grid <Name> (<Mod>).png
and should be added to the Inventory slot mods category, which prevents them from being confused with official Minecraft items.
For example, to display this mod image File:Grid Bronze Sword (IndustrialCraft).png: {{Слот|IndustrialCraft:Bronze Sword}}
(or {{Слот|mod=IndustrialCraft|Bronze Sword}}
)
- shows
Слотs can be animated with a theoretically unlimited amount of frames, between mod items and vanilla items. Frames are separated by semi-colons (;).
{{Слот| Dirt; ТНТ,64; IndustrialCraft:Bronze Sword,6; ; Grass Block,5; Sand; Gold Helmet,12; IndustrialCraft:Bronze Helmet,2; IndustrialCraft:Copper,50; Redstone }}
- shows
Dirt
64Bronze Sword6
Grass Block5SandGold Helmet12Bronze Helmet2Copper50Redstone
As you can see, the mod had to be specified for each mod frame, this is where the default mod parameter is useful.
{{Слот|mod=IndustrialCraft|Bronze Sword,6; ; Bronze Helmet,12; Copper,50; Copper Dust}}
- shows
Bronze Sword6
Bronze Helmet12Copper50Copper Dust
To use a vanilla minecraft item when a default mod is set, use "vanilla" (shortcut "v") or "minecraft" (shortcut "mc") as the mod (case insensitive).
{{Слот|mod=IndustrialCraft| Vanilla:Dirt; vanilla:ТНТ,64; Bronze Sword,6; ; V:Grass Block,5; v:Sand; Minecraft:Gold Helmet,12; Bronze Helmet,2; Copper,50; mc:Redstone Dust }}
- shows
Dirt
64Bronze Sword6
Grass Block5SandGold Helmet12Bronze Helmet2Copper50Redstone Dust
Available images
Other templates
These templates implement this template into a GUI screen which mimics how it would look in Minecraft. Thus, they have mostly the same features as this template. Шаблон:UI see also