Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Lua Quick Start Guide

You're reading from  Lua Quick Start Guide

Product type Book
Published in Jul 2018
Publisher Packt
ISBN-13 9781789343229
Pages 202 pages
Edition 1st Edition
Languages
Author (1):
Gabor Szauer Gabor Szauer
Profile icon Gabor Szauer

Namespaces

Everything inside Lua Bridge must be declared within a namespace. These namespaces have no connection to C++ namespaces, and within Lua, they are just tables. The concept of a namespace is similar to the concept of a Lua module being loaded as a table.

A global namespace exists, and you can register functions, variables, and classes to that namespace, but it's considered bad practice. You can get the global namespace with the following call:

getGlobalNamespace(lua_State*)

Once you have the global namespace, you can create your own namespace inside it with the beginNamespace(const char*) call. This function takes a string with the name of the namespace as an argument. Once you are done working with the namespace, you must close it with the endNameSpace() call. If you want to add more classes in different parts of the code in a namespace, it can be opened multiple...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}