Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding fields to Lua defined types after construction #15

Open
TheModMaker opened this issue Jan 13, 2017 · 0 comments
Open

Allow adding fields to Lua defined types after construction #15

TheModMaker opened this issue Jan 13, 2017 · 0 comments
Milestone

Comments

@TheModMaker
Copy link
Owner

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)
@TheModMaker TheModMaker modified the milestone: Backlog Jan 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant