diff --git a/src/runner/instance.rs b/src/runner/instance.rs index a54f826..7a3a5af 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -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)|{ 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 - //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)))) }) })?