Skip to content

Allow adding fields to Lua defined types after construction #15

@TheModMaker

Description

@TheModMaker

Currently, you can only add fields to a Lua defined type by defining it on the constructor. If you attempt to access a nonexistent field after construction, it will throw an exception because the field is not found. For C# defined types, this makes sense since the field doesn't exist. But it would be beneficial to be able to add fields dynamically to a Lua defined types.

Note that this will NOT change the C# exposed type. This will only affect field access within Lua. To have a field visible to C# code, it MUST be defined on the constructor so it appears in the generated type signature.

class Type

function Type:__ctor()
  self.newField = 123
end

-- Currently you have to define the field using a default or a type.
-- Type.newField = int

local inst = Type()
assert(inst.newField == 123)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions