roblox_emulator: implement :service alias for GetService
This commit is contained in:
parent
c0ad20d54c
commit
f0b2470039
@ -377,25 +377,27 @@ type CFD=phf::Map<&'static str,// Class name
|
||||
ClassFunctionPointer
|
||||
>
|
||||
>;
|
||||
const GET_SERVICE:ClassFunctionPointer=cf!(|lua,_this,service:mlua::String|{
|
||||
dom_mut(lua,|dom|{
|
||||
//dom.root_ref()==this.referent ?
|
||||
let service=&*service.to_str()?;
|
||||
match service{
|
||||
"Lighting"|"RunService"=>{
|
||||
let referent=find_first_child_of_class(dom,dom.root(),service)
|
||||
.map(|instance|instance.referent())
|
||||
.unwrap_or_else(||
|
||||
dom.insert(dom.root_ref(),InstanceBuilder::new(service))
|
||||
);
|
||||
Ok(Instance::new_unchecked(referent))
|
||||
},
|
||||
other=>Err::<Instance,_>(mlua::Error::runtime(format!("Service '{other}' not supported"))),
|
||||
}
|
||||
})
|
||||
});
|
||||
static CLASS_FUNCTION_DATABASE:CFD=phf::phf_map!{
|
||||
"DataModel"=>phf::phf_map!{
|
||||
"GetService"=>cf!(|lua,_this,service:mlua::String|{
|
||||
dom_mut(lua,|dom|{
|
||||
//dom.root_ref()==this.referent ?
|
||||
let service=&*service.to_str()?;
|
||||
match service{
|
||||
"Lighting"|"RunService"=>{
|
||||
let referent=find_first_child_of_class(dom,dom.root(),service)
|
||||
.map(|instance|instance.referent())
|
||||
.unwrap_or_else(||
|
||||
dom.insert(dom.root_ref(),InstanceBuilder::new(service))
|
||||
);
|
||||
Ok(Instance::new_unchecked(referent))
|
||||
},
|
||||
other=>Err::<Instance,_>(mlua::Error::runtime(format!("Service '{other}' not supported"))),
|
||||
}
|
||||
})
|
||||
}),
|
||||
"service"=>GET_SERVICE,
|
||||
"GetService"=>GET_SERVICE,
|
||||
},
|
||||
"Terrain"=>phf::phf_map!{
|
||||
"FillBlock"=>cf!(|_lua,_,_:(crate::runner::cframe::CFrame,Vector3,crate::runner::r#enum::Enum)|mlua::Result::Ok(()))
|
||||
|
Loading…
x
Reference in New Issue
Block a user