fn: lua_addnsmfns
[contents]

Contents

Syntax

The syntax for lua_addnsmfns calls is:

f++:  
lua_addnsmfns()

n++:  
@lua_addnsmfns()

Description

The lua_addnsmfns function adds the following Nift specific functions to Lua:

syntax example about
nsm_setnumber(string / lightuserdata, number) nsm_setnumber("i", 0) set Nift variable from number
nsm_setstring(string / lightuserdata, string) nsm_setstring("str", "hello!") set Nift variable from string
nsm_tolightuserdata(string) nsm_tolightuserdata("x") get pointer to Nift variable
nsm_tonumber(string) nsm_tonumber("i") get number from Nift variable
nsm_tostring(string) nsm_tostring("str") get string from Nift variable
nsm_write(ostream, params) nsm_write(console, "x: ", x, endl) write to console, output file (ofile), or a stream
syntax example about

f++ example

Example of lua_addnsmfns being used with f++:

:=(int, x=10)
lua_addnsmfns
lua
{
	nsm_write(console, "x: ", nsm_tonumber("x"), endl)
}

n++ example

Example of lua_addnsmfns being used with n++:

@:=(int, x=10)
@lua_addnsmfns
@lua
{
	nsm_write(console, "x: ", nsm_tonumber("x"), endl)
}

Sponsors