fake out nil parent

This commit is contained in:
Quaternions 2024-10-05 12:09:57 -07:00
parent b457da64a1
commit eccf7243c4

View File

@ -9,11 +9,11 @@ pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table<'_>)->Result<(),mlua::Err
//Instance.new
instance_table.raw_set("new",
lua.create_function(|lua,(class_name,parent):(mlua::String,Instance)|{
lua.create_function(|lua,(class_name,parent):(mlua::String,Option<Instance>)|{
let class_name_str=class_name.to_str()?;
let parent=parent.ok_or(mlua::Error::runtime("Nil Parent not yet supported"))?;
dom_mut(lua,|dom|{
//TODO: Nil instances, accept optional parent:Option<Instance>
//let parent_ref=parent.map_or(NIL_INSTANCES,|instance|instance.referent);
//TODO: Nil instances
Ok(Instance::new(dom.insert(parent.referent,InstanceBuilder::new(class_name_str))))
})
})?