Libraries

s&box libraries list

Data Tables

tzainten.datatables

A prototype inspired by Data Tables from Unreal Engine

About

How to Use

Data Tables provides you with a custom resource type that holds a list of data entries. You can then easily query data from this resource in C#.

You define your Data Structure in C# like so:

public class ExampleStruct : RowStruct
{
    public string Text { get; set; }

    public Dictionary<string, SoundEvent> Sounds { get; set; }

    public List<string> Strings { get; set; }
}

And then query data from a Data Table like this:

ExampleStruct Struct = Table.Get<ExampleStruct>( "NewEntry_0" );
Log.Info( Struct.Text );

When you make a change to your Data Table, those changes will be reflected in-game immediately after you save the file.

Custom Attributes

The [JsonTypeAnnotate] attribute will tell the serializer to also store this property's type, allowing for this property to be properly deserialized later.

Combining the above attribute with the [Instanced] attribute provides you with a dropdown in the editor. You can now select any class that inherits from the property's type.

public class BaseClass {}

public class A : BaseClass
{
    public int Integer { get; set; }
}

public class B : BaseClass
{
    public bool Boolean { get; set; }
}

public class ExampleStruct : RowStruct
{
    [JsonTypeAnnotate, Instanced]
    public List<BaseClass> List;
}

Report Issues

If you encounter a bug or you want something added, your options are:

More by tzainten

01
Vivid Panels thumbnail
Vivid Panels tzainten.vividpanels

Aims to mimic the behavior of WorldPanels, while being unaffected by Post Processing effects.

+0 24h
0favorites
0upvotes
--Terry score