Skip to content

Injecting LuaObject structure #271

@ashtonmeuser

Description

@ashtonmeuser

Currently, the recommended way of adding a LuaObject class to the environment is to do state.Environment["Vector2"] = new Vector3();. This adds a full "instance" of the class as a Lua table. This includes non-static properties and methods.

In my opinion, the way "classes" are injected should further mirror C#. Perhaps a state.Environment.Inject(Vector3) or something similar. Instead of instantiating the class and adding this instance to the environment as a table, it should simply add all static methods and properties. The type can still be used as a LuaValue in that it can be passed to and received from Lua. But the e.g. x property and normalized method of the global Vector3 class in the README are really meaningless.

TL;DR: Provide a way to add only static properties and methods to Lua environment global table, mirroring the C# class interface.

For example, the Vector3 class in the README would expose the create method to Lua but not normalized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions