Skip to content

Commit

Permalink
fix wrappers example
Browse files Browse the repository at this point in the history
  • Loading branch information
makspll committed Apr 4, 2024
1 parent b3f89ac commit b3f144f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions examples/wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use bevy_mod_scripting::prelude::*;
"#,
r#"
#[lua(kind="MutatingMethod")]
fn set_with_another(&mut self, #[proxy] another: &Self);
fn set_with_another(&mut self, #[proxy] another: Self);
"#,
r#"
#[lua(kind="Method")]
Expand Down Expand Up @@ -40,8 +40,8 @@ pub struct MyProxiedStruct {

impl MyProxiedStruct {

fn set_with_another(&mut self, another: &MyProxiedStruct) {
self.my_string = another.my_string.clone();
fn set_with_another(&mut self, another: MyProxiedStruct) {
self.my_string = another.my_string;
}

fn set_my_string(&mut self, another_string: Option<String>) {
Expand All @@ -53,8 +53,7 @@ impl MyProxiedStruct {
}

fn get_my_string(&self) -> String {
// self.my_string.clone()
"".to_owned()
self.my_string.clone()
}
}

Expand Down Expand Up @@ -84,10 +83,13 @@ fn main() -> std::io::Result<()> {
print("The string value is:", resource:get_my_string())
resource:set_my_string(nil)
print("The string value after calling method with nil is:", resource:get_my_string())
print("The string value after calling 'set_my_string(nil)' is:", resource:get_my_string())
resource:set_my_string("I was changed by the script")
print("The string value after calling method with string is:", resource:get_my_string())
print("The string value after calling 'set_my_string(\"I was changed by the script\")' is:", resource:get_my_string())
resource:set_with_another(resource)
print("The string value after calling 'set_with_another(resource)' is:", resource:get_my_string())
end
"#
Expand Down

0 comments on commit b3f144f

Please sign in to comment.