-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Expose the proxy types for Bevy builtins #122
Comments
This is already the case, you might be confusing the dummy types in the generated provider files with the proxies which are generated by the macro. All proxies have a Lua prefix in the type name, for entity this is "LuaEntity" which you can use in your code to interact with the Builtins |
I may have expressed myself wrong. Here's what I want to do #[derive(..., Reflect, LuaProxy)]
#[reflect(LuaProxyable)]
#[proxy(
derive(clone),
function[
r#"
// Error: LuaEntity not in this scope!
#[lua(kind = "MutatingMethod")]
fn add(&mut self, #[proxy] character: Entity) { self.0.push(character) }
"#
]
)]
pub struct GarrisonedCharacter(Vec<LuaEntity>) I tried using just the |
Hmm this should already work, is the Entity type imported and in scope? What's the exact error? And can you try proxying without an inlined body? (I.e. implement this function in rust fully) Edit: oh but in your actual struct you should be working with Entities not LuaEntities |
Try: #[derive(..., Reflect, LuaProxy)]
#[reflect(LuaProxyable)]
#[proxy(
derive(clone),
function[
r#"
#[lua(kind = "MutatingMethod")]
fn(&mut self, #[proxy] entity: Entity)
"#
]
)]
pub struct GarrisonedCharacter(Vec<Entity>)
Impl GarrisonedCharacter {
pub fn add(&mut self, entity: Entity) {
self.0.push(entity)
}
} |
Oh I see the LuaEntity type is not in scope, can you import that |
I can't. That's exactly what I was asking about, since LuaEntity doesn't seem to appear in |
Oh try the main branch of the library, it should be a public import there, but it's still unreleased |
I'm trying to create a lua function that takes an entity as argument to perform actions on it from rust. However, the compiler complains that the
Entity
type doesn't implementIntoLua
.A way of circumventing this specific problem is to call the
Entity::to_bits
method in lua, then have the function take anumber
as argument, which then is transformed back withEntity::from_bits
in rust, but I feel like it's too much boilerplate for something that could be solved by simply exposing the implementation to the user.The text was updated successfully, but these errors were encountered: