wip ClassFunctions
This commit is contained in:
parent
29c8cd94df
commit
56f6738028
@ -1,10 +1,26 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use mlua::IntoLua;
|
||||
use rbx_types::Ref;
|
||||
use rbx_dom_weak::{InstanceBuilder,WeakDom};
|
||||
|
||||
use super::vector3::Vector3;
|
||||
|
||||
/// A store of created functions for each Roblox class.
|
||||
/// Functions are created the first time they are accessed and stored in this data structure.
|
||||
#[derive(Default)]
|
||||
struct ClassFunctions<'a>{
|
||||
classes:HashMap<&'static str,//ClassName
|
||||
HashMap<&'static str,//Function name
|
||||
mlua::Function<'a>
|
||||
>
|
||||
>
|
||||
}
|
||||
|
||||
pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table<'_>)->Result<(),mlua::Error>{
|
||||
//class functions store
|
||||
lua.set_app_data::<ClassFunctions<'static>>(ClassFunctions::default());
|
||||
|
||||
let instance_table=lua.create_table()?;
|
||||
|
||||
//Instance.new
|
||||
@ -29,6 +45,10 @@ fn dom_mut<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result<T>)->m
|
||||
let mut dom=lua.app_data_mut::<&'static mut WeakDom>().ok_or(mlua::Error::runtime("DataModel missing"))?;
|
||||
f(&mut *dom)
|
||||
}
|
||||
fn class_functions_mut<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut ClassFunctions<'_>)->mlua::Result<T>)->mlua::Result<T>{
|
||||
let mut dom=lua.app_data_mut::<ClassFunctions<'static>>().ok_or(mlua::Error::runtime("ClassFunctions missing"))?;
|
||||
f(&mut *dom)
|
||||
}
|
||||
|
||||
fn coerce_float32(value:&mlua::Value)->Option<f32>{
|
||||
match value{
|
||||
|
Loading…
Reference in New Issue
Block a user