Modding:TreeAttribute
Эта страница проверялась в последний раз для версии Vintage Story 1.15.
TreeAttribute — это вложенная структура данных, основной целью которой является хранение данных. Он может содержать общие данные для большинства примитивов, таких как int, string, float, а также для более сложных типов, таких как ItemStacks и другие TreeAttributes (отсюда и вложенная структура).
Кроме того, вы можете хранить данные как byte[]
, если они не поддерживаются самим TreeAttribute (для этого вы можете использовать Vintagestory.API.Util.SerializerUtil
).
Атрибуты записываются и читаются с помощью ключей.
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.
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 |