-
| I'm looking at https://github.com/khvzak/mlua/blob/master/examples/userdata.rs and I see this in Rectangle::add_methods(): but in the usage of that it's doing this: which seems wrong on the surface since I think it's creating 2 rectangles (one in Rust and then another in lua)? Alternatively, looking at https://github.com/khvzak/mlua/blob/master/examples/guided_tour.rs I see this instead of defining a MetaMethod::Call constructor: and that makes sense but now I don't know what the right way to do this is between the two. If I just do this: I get this error:  | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
| 
 It's true but you need an instance of Userdata to exec  In your example  | 
Beta Was this translation helpful? Give feedback.
It's true but you need an instance of Userdata to exec
__callOR just a new function to construct it (as it's done invec2_constructor).In your example
Animalis just a Rust type that implementsUserDatabut in Lua it must be an entity in a global namespace to use it on that way.It your case it should be a "dummy" instance of
Animalor you can make it as a function and remove__callconstructor.In another words - an existing instance of Animal that constructs new instances of self.