Name
luaL_checknewid -- get new object identifier from the stack (V5.3)
Synopsis
void luaL_checknewid(lua_State *L, int numArg, lua_ID *id);
Function
This is not an official Lua API but a Hollywood extension. luaL_checknewid() can be used from functions that add a new Hollywood object to a user-defined object list registered using the hw_RegisterUserObject() function. See hw_RegisterUserObject for details.

As you might know, the Hollywood standard for functions that create new Hollywood objects is that the user can either pass a numerical value that the object should use or he can pass Nil to make the function choose a vacant identifier for the new object on its own. See Object identifiers for details. What luaL_checknewid() does is simply to see if a numerical value is on the stack or Nil. In case Nil is at the specified stack index, luaL_checknewid() will set the ptr member of the lua_ID structure to (void *) 1. This is of course not a valid identifier. It is only a temporary set up to tell your function that the user has passed Nil. Your function then has to set the ptr member to the real object identifier and push it into the stack using lua_pushlightuserdata(). If ptr is NULL, however, your function simply has to use the identifier passed in the num member of the lua_ID structure and return nothing.

See Object identifiers for details.

Designer compatibility
Unsupported

Inputs
L
pointer to the lua_State
numArg
stack index to examine
id
pointer to a lua_ID to receive the object identifier passed by the user

Show TOC