Modding:TreeAttribute/ru: Difference between revisions

From Vintage Story Wiki
(Created page with "Моддинг:Дерево атрибутов")
 
(Created page with "TreeAttribute — это вложенная структура данных, основной целью которой является хранение данных. Он м...")
Line 1: Line 1:
{{GameVersion|1.15}}
{{GameVersion|1.15}}
<languages/>A TreeAttribute is a nested data structure whose primary purpose is to store data. It can hold generic data for most primitives, such as int, string, float, as well as more complex types like ItemStacks and other TreeAttributes (hence a nested structure).  
<languages/>TreeAttribute — это вложенная структура данных, основной целью которой является хранение данных. Он может содержать общие данные для большинства примитивов, таких как int, string, float, а также для более сложных типов, таких как ItemStacks и другие TreeAttributes (отсюда и вложенная структура).  


Additionally you can store data as <code>byte[]</code> if it is not supported by the TreeAttribute itself (for this you could use <code>Vintagestory.API.Util.SerializerUtil</code>).
Additionally you can store data as <code>byte[]</code> if it is not supported by the TreeAttribute itself (for this you could use <code>Vintagestory.API.Util.SerializerUtil</code>).

Revision as of 05:48, 21 September 2022

Эта страница проверялась в последний раз для версии Vintage Story 1.15.

Other languages:

TreeAttribute — это вложенная структура данных, основной целью которой является хранение данных. Он может содержать общие данные для большинства примитивов, таких как int, string, float, а также для более сложных типов, таких как ItemStacks и другие TreeAttributes (отсюда и вложенная структура).

Additionally you can store data as byte[] if it is not supported by the TreeAttribute itself (for this you could use Vintagestory.API.Util.SerializerUtil). Attributes are written and read via keys.

To use TreeAttribute, add the using statement for Vintagestory.API.Datastructures.

Use in API

Within the API, TreeAttribute is often employed to store persistent entity data (items a basket contains, content of a barrel/bucket) and to access data extracted from JSON files. TreeAttribute is often supplied as the interface ITreeAttribute.

Example in code

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);
    }
}

For documentation, see TreeAttribute and ITreeAttribute.

Icon Sign.png

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 ItemEntityEntity BehaviorsBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsCollectible BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository