-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
#[var(set = function_name
)] is not compatible with #[func(rename = gdscript_name
)]
#863
Comments
Interesting! Certainly not intended. Might be a bit tricky because those are in two separate macros, and I don't know if the |
One idea to address this: #[godot_api]
impl Herbivore {
#[func]
fn eat_herbs(&mut self, value: f64) {...}
#[func(rename = set_health)]
fn gdscript_set_health(&mut self, value: f64) {...}
} generates something like mod __funcs_Herbivore {
pub const eat_herbs: &str = "eat_herbs";
pub const gdscript_set_health: &str = "set_health";
} Then, the custom setter #[var(get, set = gdscript_set_health)]
pub(super) health: f64, would, instead of registering the setter as
|
That got kinda harder with my PR, where you can now have multiple Since you can't contribute to one #[godot_api]
impl Herbivore {
#[func]
fn eat_herbs(&mut self, value: f64) {...}
}
// generated
pub const __funcs_Herbivore_eat_herbs: &str = "eat_herbs";
#[godot_api]
impl Herbivore {
#[func(rename = set_health)]
fn gdscript_set_health(&mut self, value: f64) {...}
}
// generated
pub const __funcs_Herbivore_gdscript_set_health: &str = "set_health"; |
Ugh... back to C namespacing then 😔 (It could be |
would you merge a PR for this anyway? if yes, what pattern exactly? /// Generated by the #[func] macro of gdext. Maps the name under which it is exported to godot to the rust name of the function.
#[doc(hidden)]
pub(self) const __func_{class}_{rust-fn-name}: &str = "{godot-fn-name}"; (I could take a stab at implementing it next week or so) |
Yes, a PR would still be appreciated! It would already fix the issue, and if we find another approach in the future, we can always change it 🙂 You could maybe use the gdext/godot-core/src/init/mod.rs Line 21 in d32d569
Also, #[doc(hidden)]
const __gdext_func_{class}_{rust-fn-name}: &str = "{godot-fn-name}"; |
Example:
This compiles in Rust but in Godot we get a runtime error when trying to invoke the property:
This happens because inside Godot its using the original name, not the renamed one.
Not sure if this is by design or a niche bug.
The text was updated successfully, but these errors were encountered: