mirror of
https://github.com/lune-org/lune.git
synced 2024-12-13 21:40:40 +00:00
Add back typeof global
This commit is contained in:
parent
9b4ca94c13
commit
4412d02b34
4 changed files with 19 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
use mlua::prelude::*;
|
use mlua::prelude::*;
|
||||||
|
|
||||||
pub fn create(lua: &'static Lua) -> LuaResult<impl IntoLua<'_>> {
|
pub fn create(lua: &Lua) -> LuaResult<impl IntoLua<'_>> {
|
||||||
lua.create_table()
|
lua.create_table()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ use super::util::TableBuilder;
|
||||||
mod g_table;
|
mod g_table;
|
||||||
mod print;
|
mod print;
|
||||||
mod require;
|
mod require;
|
||||||
|
mod r#typeof;
|
||||||
mod version;
|
mod version;
|
||||||
mod warn;
|
mod warn;
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ pub fn inject_all(lua: &'static Lua) -> LuaResult<()> {
|
||||||
.with_value("_VERSION", version::create(lua)?)?
|
.with_value("_VERSION", version::create(lua)?)?
|
||||||
.with_value("print", print::create(lua)?)?
|
.with_value("print", print::create(lua)?)?
|
||||||
.with_value("require", require::create(lua)?)?
|
.with_value("require", require::create(lua)?)?
|
||||||
|
.with_value("typeof", r#typeof::create(lua)?)?
|
||||||
.with_value("warn", warn::create(lua)?)?
|
.with_value("warn", warn::create(lua)?)?
|
||||||
.build_readonly()?;
|
.build_readonly()?;
|
||||||
|
|
||||||
|
|
15
src/lune/globals/typeof.rs
Normal file
15
src/lune/globals/typeof.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
use mlua::prelude::*;
|
||||||
|
|
||||||
|
use crate::roblox::datatypes::extension::RobloxUserdataTypenameExt;
|
||||||
|
|
||||||
|
pub fn create(lua: &Lua) -> LuaResult<impl IntoLua<'_>> {
|
||||||
|
lua.create_function(|lua, value: LuaValue| {
|
||||||
|
#[cfg(feature = "roblox")]
|
||||||
|
if let LuaValue::UserData(u) = &value {
|
||||||
|
if let Some(type_name) = u.roblox_type_name() {
|
||||||
|
return lua.create_string(type_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lua.globals().get::<_, LuaFunction>("typeof")?.call(value)
|
||||||
|
})
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
use mlua::prelude::*;
|
use mlua::prelude::*;
|
||||||
|
|
||||||
pub fn create(lua: &'static Lua) -> LuaResult<impl IntoLua<'_>> {
|
pub fn create(lua: &Lua) -> LuaResult<impl IntoLua<'_>> {
|
||||||
let luau_version_full = lua
|
let luau_version_full = lua
|
||||||
.globals()
|
.globals()
|
||||||
.get::<_, LuaString>("_VERSION")
|
.get::<_, LuaString>("_VERSION")
|
||||||
|
|
Loading…
Reference in a new issue