#[derive(Clone)]
pub struct NumberSequence(rbx_types::NumberSequence);
impl NumberSequence{
	pub const fn new(keypoints:Vec<rbx_types::NumberSequenceKeypoint>)->Self{
		Self(rbx_types::NumberSequence{keypoints})
	}
}
impl From<NumberSequence> for rbx_types::NumberSequence{
	fn from(NumberSequence(value):NumberSequence)->rbx_types::NumberSequence{
		value
	}
}

pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{
	let table=lua.create_table()?;

	table.raw_set("new",
		lua.create_function(|_,_:mlua::MultiValue|
			Ok(NumberSequence::new(Vec::new()))
		)?
	)?;

	globals.set("NumberSequence",table)?;

	Ok(())
}

impl mlua::UserData for NumberSequence{}
impl mlua::FromLua for NumberSequence{
	fn from_lua(value:mlua::Value,_lua:&mlua::Lua)->Result<Self,mlua::Error>{
		match value{
			mlua::Value::UserData(ud)=>Ok(ud.borrow::<Self>()?.clone()),
			other=>Err(mlua::Error::runtime(format!("Expected {} got {:?}",stringify!(NumberSequence),other))),
		}
	}
}
