Modding:TreeAttribute/ru: Difference between revisions
Mirotworez (talk | contribs) (Created page with "Кроме того, вы можете хранить данные как <code>byte[]</code>, если они не поддерживаются самим TreeAttribute (дл...") |
m (FuzzyBot moved page Modding:Tree Attribute/ru to Modding:TreeAttribute/ru without leaving a redirect: Part of translatable page "Modding:Tree Attribute") |
||
(3 intermediate revisions by one other user not shown) | |||
Line 5: | Line 5: | ||
Атрибуты записываются и читаются с помощью ключей. | Атрибуты записываются и читаются с помощью ключей. | ||
Чтобы использовать TreeAttribute, добавьте оператор using для '''Vintagestory.API.Datastructures'''.<br><br> | |||
== | == Использовать в API == | ||
В рамках API TreeAttribute часто используется для хранения постоянных данных объектов (предметов, содержащихся в корзине, содержимого бочки/ведра) и для доступа к данным, извлеченным из файлов JSON. '''TreeAttribute''' часто предоставляется как интерфейс '''ITreeAttribute'''.<br> | |||
== | == Пример в коде == | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
using Vintagestory.API.Datastructures; | using Vintagestory.API.Datastructures; | ||
Line 31: | Line 31: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Документацию см. в [http://apidocs.vintagestory.at/api/Vintagestory.API.Datastructures.TreeAttribute.html TreeAttribute] и [http://apidocs.vintagestory.at/api/Vintagestory.API.Datastructures.ITreeAttribute. html ITreeAttribute]. | |||
{{Navbox/modding|Vintage Story}} | {{Navbox/modding|Vintage Story}} |
Latest revision as of 11:27, 5 December 2023
Эта страница проверялась в последний раз для версии Vintage Story 1.15.
TreeAttribute — это вложенная структура данных, основной целью которой является хранение данных. Он может содержать общие данные для большинства примитивов, таких как int, string, float, а также для более сложных типов, таких как ItemStacks и другие TreeAttributes (отсюда и вложенная структура).
Кроме того, вы можете хранить данные как byte[]
, если они не поддерживаются самим TreeAttribute (для этого вы можете использовать Vintagestory.API.Util.SerializerUtil
).
Атрибуты записываются и читаются с помощью ключей.
Чтобы использовать TreeAttribute, добавьте оператор using для Vintagestory.API.Datastructures.
Использовать в API
В рамках API TreeAttribute часто используется для хранения постоянных данных объектов (предметов, содержащихся в корзине, содержимого бочки/ведра) и для доступа к данным, извлеченным из файлов JSON. TreeAttribute часто предоставляется как интерфейс ITreeAttribute.
Пример в коде
using Vintagestory.API.Datastructures;
class Example
{
Example()
{
// Setting and getting values
TreeAttribute tree;
tree = new TreeAttribute();
float someValue = 0.35f;
string someKey = "valueKey";
// Set the value
tree.SetFloat(someKey, someValue);
// Retrieve the value
tree.GetFloat(someKey);
}
}
Документацию см. в TreeAttribute и html ITreeAttribute.
Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.
Modding | |
---|---|
Modding Introduction | Getting Started • Пакет тем |
Content Modding | Content Mods • Developing a Content Mod • Basic Tutorials • Intermediate Tutorials • Advanced Tutorials • Content Mod Concepts |
Code Modding | Code Mods • Setting up your Development Environment |
Property Overview | Item • Entity • Block • Block Behaviors • Block Classes • Block Entities • Block Entity Behaviors • World properties |
Workflows & Infrastructure | Modding Efficiency Tips • Mod-engine compatibility • Mod Extensibility • VS Engine |
Additional Resources | Community Resources • Modding API Updates • Programming Languages • List of server commands • List of client commands • Client startup parameters • Server startup parameters Example Mods • API Docs • GitHub Repository |