use crate::script_implementations::rune::wrappers::{impl_rune_wrapper, RuneStringKey, RuneWrapper}; use crate::static_data::Ability; use rune::runtime::{AnyObj, Shared}; use rune::Any; use std::sync::Arc; pub fn register(module: &mut rune::Module) -> anyhow::Result<()> { module.ty::()?; module.function_meta(RuneAbility::name)?; module.function_meta(RuneAbility::effect)?; module.function_meta(RuneAbility::get_parameter)?; Ok(()) } #[derive(Debug, Any)] pub struct RuneAbility(Arc); impl_rune_wrapper!(&Arc, RuneAbility); impl RuneAbility { #[rune::function] fn name(&self) -> Shared { self.0.name().wrap() } #[rune::function] fn effect(&self) -> Shared { self.0.effect().wrap() } #[rune::function(vm_result)] fn get_parameter(&self, key: RuneStringKey) -> Option> { match self.0.parameters().get(&key.0) { None => None, Some(p) => Some(p.wrap()), } } }