fn: lua_pushlightuserdata

[contents]

Contents

Syntax

The syntax for lua_pushlightuserdata calls is:

f++:  
lua_pushlightuserdata(var)

n++:  
@lua_pushlightuserdata(var)

Description

The lua_pushlightuserdata function takes a single variable parameter and pushes a pointer to the variable on to the Lua stack as a lightuserdata, it is a binding for this function.

f++ example

Example of lua_pushlightuserdata being used with f++:

  1. :=(string, str)
  2. lua_pushlightuserdata(str)
  3. lua_setglobal("s")
  4. lua_addnsmfns
  5. lua
  6. {
  7. nsm_setstring(s, "hello, world!")
  8. }
  9. console(str)

Note: You can achieve essentially the same as above as follows:

  1. :=(string, str)
  2. lua_addnsmfns
  3. lua
  4. {
  5. s = nsm_tolightuserdata("str")
  6. nsm_setstring(s, "hello, world!")
  7. }
  8. console(str)

n++ example

Example of lua_pushlightuserdata being used with n++:

  1. @:=(string, str)
  2. @lua_pushlightuserdata(str)
  3. @lua_setglobal("s")
  4. @lua_addnsmfns
  5. @lua
  6. {
  7. nsm_setstring(s, "hello, world!")
  8. }
  9. @console(str)