Book description
Lua offers a wide range of features that you can use to support and enhance your applications. With this book as your guide, you'll gain a thorough understanding of all aspects of programming with this powerful language. The authors present the fundamentals of programming, explain standard Lua functions, and explain how to take advantage of free Lua community resources. Complete code samples are integrated throughout the chapters to clearly demonstrate how to apply the information so that you can quickly write your own programs.
Table of contents
- Copyright
- About the Authors
- Credits
- Acknowledgments
- Introduction
- 1. Getting Situated
-
2. First Steps
- 2.1. Numbers and Arithmetic Operations: Basic Interpreter Usage
- 2.2. Interpreter Know-How
- 2.3. Numerical Gotchas
- 2.4. Variables and Assignment
- 2.5. Strings
- 2.6. Relational Operators and Boolean Values
- 2.7. The nil Value
- 2.8. Boolean Operators
- 2.9. The Concatenation, Length, and Modulo Operators
- 2.10. Automatic Conversion of Operands
- 2.11. Precedence and Associativity
- 2.12. Variables and Values
- 2.13. Comments
- 2.14. Expressions and Statements
- 2.15. Compound Statements
- 2.16. Summary
- 2.17. Exercises
-
3. Extending Lua with Functions
- 3.1. Return Values
- 3.2. Chunks as Functions
- 3.3. Variable Scope
- 3.4. Understanding Side Effects
- 3.5. Functions Calling Functions
- 3.6. Functions as Values
- 3.7. Whitespace, Semicolons, and Function Calls
- 3.8. Upvalues and Closures
- 3.9. Summary
- 3.10. Exercises
-
4. Working with Tables
- 4.1. Tables Introduced
- 4.2. A Shorter Way to Write Some Keys
- 4.3. Altering a Table's Contents
- 4.4. Tables as Arrays
- 4.5. Array Length
- 4.6. Looping through Tables
- 4.7. Tables of Functions
- 4.8. Functions with Variable Numbers of Arguments
- 4.9. Keyword Arguments
- 4.10. Different but the Same
- 4.11. Building Other Data Structures from Tables
- 4.12. Custom-Made Loops
- 4.13. Global Variable Environments
- 4.14. Summary
- 4.15. Exercises
-
5. Using Strings
- 5.1. Basic String Conversion Functions
- 5.2. String Length
- 5.3. Converting Between Characters and Character Codes
- 5.4. Formatting Strings and Numbers with string.format
- 5.5. Input/Output
-
5.6. Pattern-Matching
- 5.6.1. Searching for a Specific String
- 5.6.2. Matching Any of Several Characters
- 5.6.3. Matches of Varying Lengths
- 5.6.4. Captures
- 5.6.5. Matching Balanced Delimiters
- 5.6.6. More on string.find, string.match, and string.gsub
- 5.6.7. Iterating Through All Matches
- 5.6.8. Tricks for the Tricky
- 5.6.9. Magic Characters Chart
- 5.7. Summary
- 5.8. Exercises
- 6. Handling and Avoiding Errors
- 7. Using Modules
- 8. Extending Lua's Behavior with Metamethods
-
9. Handling Events Naturally with Coroutines
- 9.1. Coroutines and Program Control
- 9.2. Managing Concurrent Tasks
- 9.3. Retaining State
- 9.4. Handling Events Simply
- 9.5. Summary
- 9.6. Exercises
- 10. Looking Under the Hood
-
11. Exploring Lua's Libraries
-
11.1. Core Library
- 11.1.1. Environment Functions
- 11.1.2. Metatable Functions
- 11.1.3. Chunk-Loading Functions
- 11.1.4. Error-Containment Functions
- 11.1.5. Module Functions
- 11.1.6. The Garbage-Collection Function
- 11.1.7. Type and Conversion Functions
- 11.1.8. Basic Output
- 11.1.9. Error-Condition Functions
- 11.1.10. Table Traversal Functions
- 11.1.11. Vararg-Related Functions
- 11.2. Coroutine Library
- 11.3. Package Library
- 11.4. String Library
- 11.5. Table Library
-
11.6. Math Library
- 11.6.1. Trigonometric Functions
- 11.6.2. Inverse Trigonometric Functions
- 11.6.3. Hyperbolic Functions
- 11.6.4. Exponent Functions
- 11.6.5. Logarithm Functions
- 11.6.6. Adjustment Functions
- 11.6.7. Floating Point Representation
- 11.6.8. Angle Conversion Functions
- 11.6.9. Pseudo-Random Number Functions
- 11.6.10. Modulus Functions
- 11.6.11. Minimum and Maximum Functions
- 11.6.12. Constants
- 11.7. Input/Output Library
- 11.8. Operating System Library
- 11.9. Debugging Library
- 11.10. Summary
-
11.1. Core Library
- 12. Using Community Libraries
- 13. Interfacing Lua with Other Languages
- 14. Managing Information with Databases
-
15. Programming for the Web
- 15.1. A Web Server Primer
- 15.2. Dynamic Web Content
- 15.3. Executing CGI Scripts
- 15.4. Installing a Web Server
- 15.5. Testing Your Web Server with Static Content
- 15.6. Serving Dynamic Web Content
- 15.7. Interactive CGI Applications
- 15.8. The Kepler Project
- 15.9. Summary
- 15.10. Exercises
-
16. Connecting to a Larger World
- 16.1. Installing LuaSocket
- 16.2. Network Overview
- 16.3. Using LuaSocket for Network Communication
- 16.4. Handling Multiple Persistent Connections
- 16.5. The Application Protocols
- 16.6. Networking with Lua and Streams
- 16.7. Summary
- 16.8. Exercises
- 17. Programming Games with Lua
- 18. Carrying Lua with You
- 19. Fitting into the Lua Community
- A. Answers
Product information
- Title: Beginning Lua Programming
- Author(s):
- Release date: February 2007
- Publisher(s): Wrox
- ISBN: 9780470069172
You might also like
book
Creating Solid APIs with Lua
Learn how you can build APIs by integrating the Lua and C programming languages. These APIs …
book
Boost C++ Application Development Cookbook - Second Edition
Learn to build applications faster and better by leveraging the real power of Boost and C++ …
book
Programming Languages: Concepts and Implementation
Programming Languages: Concepts and Implementation teaches language concepts from two complementary perspectives: implementation and paradigms. It …
video
Data-Oriented Programming in C#
Manning authors leverage powerful advanced features in C# to apply Data-Oriented Programming principles. They will help …