fn: lua_tonumber
[contents]

Contents

Syntax

The syntax for lua_tonumber calls is:

f++:  
lua_tonumber(int)

n++:  
@lua_tonumber(int)

Description

The lua_tonumber function returns the number value on the Lua stack at the given acceptable index, it is a binding for this function. The value on the Lua stack at the specified index must be a number or a string convertible to a number (see §2.2.1), otherwise lua_tonumber returns 0.

f++ example

Example of lua_tonumber being used with f++:

  1. lua
  2. {
  3. x = 10
  4. }
  5. lua_getglobal("x")
  6. console(lua_tonumber(1))

n++ example

Example of lua_tonumber being used with n++:

  1. @lua
  2. {
  3. x = 10
  4. }
  5. @lua_getglobal("x")
  6. @console(@lua_tonumber(1))