fn: lua_setglobal
[contents]

Contents

Syntax

The syntax for lua_setglobal calls is:

f++:  
lua_setglobal(string)

n++:  
@lua_setglobal(string)

Description

The lua_setglobal function takes a single string parameter, pops a value from the Lua stack and sets it as the value for a Lua global variable given the name of the input parameter, it is a binding for this function.

f++ example

Example of lua_setglobal being used with f++:

  1. lua_pushstring("hello, world!")
  2. lua_setglobal("str")
  3. lua
  4. {
  5. print(str)
  6. }

n++ example

Example of lua_setglobal being used with n++:

  1. @lua_pushstring("hello, world!")
  2. @lua_setglobal("str")
  3. @lua
  4. {
  5. print(str)
  6. }