use rhai::plugin::*;
#[export_module]
pub mod advanced_math {
#[cfg(not(feature = "no_float"))]
pub mod floating_point {
use rhai::plugin::*;
use rhai::FLOAT;
pub fn get_mystic_number() -> FLOAT {
42.0 as FLOAT
}
}
}
However, in the course of implementing this, I found additional weird ways for the macro to fail that are very confusing to users. For the moment, #[cfg] is forbidden on functions and constants exported to Rhai. I hope this situation is fixable, but if it it isn't, a future flatten tag on rhai_mod should be a suitable workaround.
Also contains an irrelevant drive-by fix for how the UI tests are run.
So far, as long as you can put #[cfg] on a sub-module, it should work nicely. I already have a Module::combine_flatten method that recursively adds all functions.
This is now supported on submodules:
However, in the course of implementing this, I found additional weird ways for the macro to fail that are very confusing to users. For the moment,
#[cfg]
is forbidden on functions and constants exported to Rhai. I hope this situation is fixable, but if it it isn't, a futureflatten
tag onrhai_mod
should be a suitable workaround.Also contains an irrelevant drive-by fix for how the UI tests are run.