game:GetService("Lighting") + game.PlaceId
This commit is contained in:
parent
748f544a4b
commit
6ec0d61b3d
@ -1,5 +1,6 @@
|
||||
use mlua::IntoLua;
|
||||
use rbx_types::Ref;
|
||||
use rbx_dom_weak::WeakDom;
|
||||
use rbx_dom_weak::{InstanceBuilder,WeakDom};
|
||||
|
||||
use super::vector3::Vector3;
|
||||
|
||||
@ -186,13 +187,27 @@ class!(DataModel);
|
||||
class_composition!(DataModel,(Instance,DataModel));
|
||||
impl DataModel{
|
||||
fn composition_add_fields<'lua,T:Referent,F:mlua::UserDataFields<'lua,T>>(fields:&mut F){
|
||||
fields.add_field_method_get("PlaceId",|lua,this|{
|
||||
Ok(mlua::Value::Integer(0))
|
||||
});
|
||||
}
|
||||
fn composition_add_methods<'lua,T,M:mlua::UserDataMethods<'lua,T>>(methods:&mut M){
|
||||
methods.add_method("GetService",|lua,this,service:String|
|
||||
dom(lua,|dom|{
|
||||
match service.as_str(){
|
||||
//"Lighting"=>Ok(Lighting::new()),
|
||||
other=>Err::<(),_>(mlua::Error::runtime("Service '{other}' not supported")),
|
||||
"Lighting"=>{
|
||||
let referent=dom.root()
|
||||
.children()
|
||||
.iter()
|
||||
.find(|&&c|
|
||||
dom.get_by_ref(c).is_some_and(|c|c.class=="Lighting")
|
||||
).map(|r|*r)
|
||||
.unwrap_or_else(||
|
||||
dom.insert(dom.root_ref(),InstanceBuilder::new("Lighting"))
|
||||
);
|
||||
Lighting::new(referent).into_lua(lua)
|
||||
},
|
||||
other=>Err::<mlua::Value,_>(mlua::Error::runtime(format!("Service '{other}' not supported"))),
|
||||
}
|
||||
})
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user