mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-12 02:53:08 +00:00
Let Lua scripts access userdata metatables
This commit is contained in:
parent
6f707dfbda
commit
9da21a1518
1 changed files with 13 additions and 2 deletions
|
|
@ -240,7 +240,7 @@ static int lib_userdataType(lua_State *L)
|
||||||
|
|
||||||
// Takes a metatable as first and only argument
|
// Takes a metatable as first and only argument
|
||||||
// Only callable during script loading
|
// Only callable during script loading
|
||||||
static int lib_registermetatable(lua_State *L)
|
static int lib_registerMetatable(lua_State *L)
|
||||||
{
|
{
|
||||||
static UINT32 nextid = 1;
|
static UINT32 nextid = 1;
|
||||||
|
|
||||||
|
|
@ -265,6 +265,16 @@ static int lib_registermetatable(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Takes a string as only argument and returns the metatable
|
||||||
|
// associated to the userdata type this string refers to
|
||||||
|
// Returns nil if the string does not refer to a valid userdata type
|
||||||
|
static int lib_userdataMetatable(lua_State *L)
|
||||||
|
{
|
||||||
|
const char *udname = luaL_checkstring(L, 1);
|
||||||
|
luaL_getmetatable(L, udname);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int lib_isPlayerAdmin(lua_State *L)
|
static int lib_isPlayerAdmin(lua_State *L)
|
||||||
{
|
{
|
||||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||||
|
|
@ -3460,7 +3470,8 @@ static luaL_Reg lib[] = {
|
||||||
{"chatprint", lib_chatprint},
|
{"chatprint", lib_chatprint},
|
||||||
{"chatprintf", lib_chatprintf},
|
{"chatprintf", lib_chatprintf},
|
||||||
{"userdataType", lib_userdataType},
|
{"userdataType", lib_userdataType},
|
||||||
{"registermetatable", lib_registermetatable},
|
{"registerMetatable", lib_registerMetatable},
|
||||||
|
{"userdataMetatable", lib_userdataMetatable},
|
||||||
{"IsPlayerAdmin", lib_isPlayerAdmin},
|
{"IsPlayerAdmin", lib_isPlayerAdmin},
|
||||||
{"reserveLuabanks", lib_reserveLuabanks},
|
{"reserveLuabanks", lib_reserveLuabanks},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue