This commit is contained in:
Quaternions 2024-10-04 16:48:25 -07:00
parent c0323d12df
commit e110365325

View File

@ -12,6 +12,7 @@ pub enum Error{
RustLua(mlua::Error),
Script(super::instance::GetScriptError),
NoContext,
NoServices,
}
impl std::fmt::Display for Error{
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
@ -46,7 +47,11 @@ impl Runner{
init(&runner.lua).map_err(Error::RustLua)?;
Ok(runner)
}
pub fn runnable_context<'a>(self,context:&'a mut Context,services:&crate::place::Services)->Result<Runnable<'a>,Error>{
pub fn runnable_context<'a>(self,context:&'a mut Context)->Result<Runnable<'a>,Error>{
let services=context.find_services().ok_or(Error::NoServices)?;
self.runnable_context_with_services(context,&services)
}
pub fn runnable_context_with_services<'a>(self,context:&'a mut Context,services:&crate::context::Services)->Result<Runnable<'a>,Error>{
{
let globals=self.lua.globals();
globals.set("game",super::instance::DataModel::new(services.game)).map_err(Error::RustLua)?;