Skip to Content
Lua Quick Start Guide
book

Lua Quick Start Guide

by Gabor Szauer
July 2018
Beginner
202 pages
5h 42m
English
Packt Publishing
Content preview from Lua Quick Start Guide

Pushing to the stack

The first step in working with the Lua stack is usually to push some data onto it. The Lua C API provides several functions to push different types of data onto the stack. The following functions can be used to push data:

  • lua_pushnil(lua_State*): Pushes nil onto the stack
  • lua_pushboolean(lua_State*, bool): Pushes a Boolean value onto the stack
  • lua_pushnumber(lua_State*, lua_Number): Pushes a double onto the stack
  • lua_pushinteger(lua_State*, lua_Integer): Pushes a signed integer onto the stack
  • lua_pushstring (lua_State*, const char*): Pushes a NULL terminated string onto the stack

When you push a string onto the stack, Lua creates its own copy of that string. As soon as the push operation is finished, you can modify ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Lua Programming

Beginning Lua Programming

Kurt Jung, Aaron Brown
Vim Masterclass

Vim Masterclass

Jason Cannon

Publisher Resources

ISBN: 9781789343229Supplemental Content