Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorKurt Jung, Aaron Brown

Lua offers a wide range of features that you can utilize 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. It will walk you through the basics, covering everything from installing Lua on your system to developing games and web sites.Experts Jung and Brown first present the fundamentals of programming and explain standard Lua functions. They then show you how to take advantage of all of the free Lua community resources that are available. Complete code samples are integrated throughout the chapters to clearly demonstrate how to apply the information. Diagrams are also included to highlight important Lua features such as stacks, hash tables, garbage collection, and function closures. All of this will help you to quickly write your own effective programs.What you will learn from this book * Ways to extend Lua's operators with metamethods * Methods on how to use tables, strings, and modules * How to handle events naturally with coroutines * Techniques for managing information with databases * Tips for handling and avoiding programming errors * Ways to create your own innovative games * How to enhance application development using packages contributed by the Lua community * Steps for presenting dynamic information on your web site Who this book is forThis book is for beginning programmers, game developers, and web site developers who are interested in a simple yet powerful introduction to programming.Wrox Beginning guides are crafted to make learning programming languages and technologies easier than you think, providing a structured, tutorial format that will guide you through all the techniques involved.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical, beginner-friendly guide to Lua that takes you from installing the language to building games and dynamic websites, ideal for new programmers, game developers, and web hobbyists who want a simple yet powerful tool. 【Book Arc】 - **Opening (~0%–9%)**: Covers installation on Windows, macOS, and Linux, including environment variables, tarballs, and prebuilt binaries, solving the first hurdle of getting Lua running. - **Early (~16%–25%)**: Introduces core syntax—assignment, variables, datatypes (numbers, strings, Booleans, nil), and control flow like loops and break, establishing the fundamentals for writing simple programs. - **Early (~25%–34%)**: Delves into functions, covering return, scope, local variables, recursion, and closures, explaining how to structure reusable code and manage variable lifetimes. - **Middle (~38%–47%)**: Explores tables as the central data structure, including indexing, sorting, concatenation, and keyword arguments, plus practical patterns like simulating named parameters. - **Late (~50%–75%)**: Moves to advanced topics—metamethods, coroutines, modules, and error handling—showing how to extend Lua’s operators and manage complex events naturally. - **Ending (~75%–100%)**: Applies everything to real-world projects: database integration, game development, and web scripting, plus leveraging community packages to enhance productivity. 【Key Takeaways】 - **Lua’s gentle learning curve makes it ideal for beginners** (Early): Simple syntax and minimal boilerplate let you write effective programs quickly, even without prior programming experience. - **Variables and assignment are straightforward but have nuances** (Early): The equal sign is a command, not a statement of fact, and uninitialized variables default to nil, which represents absence of value. - **nil is a unique datatype for emptiness** (Early): It’s the only value of its type, used to clear variables or pad assignments, and understanding it prevents common bugs. - **Functions are first-class and support closures** (Early): Local variables can be captured as upvalues, allowing functions to remember state, which is powerful for callbacks and configuration. - **Tables are the backbone of Lua data structures** (Middle): They serve as arrays, dictionaries, and objects, with built-in functions like table.sort and table.concat for efficient manipulation. - **Keyword arguments can be simulated with tables** (Middle): By passing a single table to a function, you can name parameters, improving readability and flexibility without special syntax. - **Metamethods extend operator behavior** (Late): You can redefine operations like addition or comparison for custom types, enabling elegant domain-specific solutions. - **Coroutines handle events naturally** (Late): They allow cooperative multitasking, making asynchronous code easier to write and read compared to callbacks. 【Reading Tips】 - **Skim the installation chapters** (Opening): If you’re on a common platform, jump to the quick-start sections; revisit only if you hit environment issues. - **Deep-read the functions and tables chapters** (Early–Middle): These are the heart of Lua; practice writing closures and table manipulations to solidify understanding. - **Pay attention to scope and upvalues** (Early): This is a common stumbling block; trace through examples like ScopeTest3 to see how locals shadow and persist. - **Use the code samples as exercises** (Throughout): Type and run them yourself, then modify them—this reinforces learning better than passive reading. - **Skip advanced topics initially** (Late): If you’re a beginner, focus on core syntax first; return to metamethods and coroutines when you need them for projects. 【Coverage Limits】 This guide synthesizes the first half of the book (up to ~47%), covering installation, syntax, functions, and tables. Later chapters on databases, games, and web development are not detailed here due to excerpt limitations.
Page 12
Chapter 1: Getting Situated 1 Choosing How to Install Lua 1 Building Lua Yourself 2 Selecting Prebuilt Lua 3 Finding Your System’s Shell 3 Windows Shells 3 S...
View in text
Excerpt 2
/07 7:53 PM Page 40 Chapter 2: First Steps The nil Value Assigning an initial value to a variable is called initializing it. A variable that has had no va...
View in text
Excerpt 3
7 7:54 PM Page 97 Chapter 3: Extending Lua with Functions These locations will be listed (in stack order) if an error happens inside C. For instance, if tw...
View in text
Excerpt 4
u want to count the nonpositive indexes). Keyword Arguments In the previous chapter, you saw that a function call whose sole argument is a literal string doe...
View in text
Excerpt 5
teCreditCard, however, depends only on the fact that string.find’s first result will be true if there’s a match and nil if there’s no match. When this result...
View in text
Excerpt 6
ere are no global assignments other than the intended ones: 10 [95] SETGLOBAL 3 0 ; ObjectDescribe 12 [102] SETGLOBAL 3 1 ...
View in text
Excerpt 7
d above). 280 12_069172 ch09.qxp 1/2/07 8:08 PM Page 291 Chapter 9: Handling Events Naturally with Coroutines local Wnd, Msg local Loop = true while Loop ...
View in text
Excerpt 8
btain the elements in a vararg expression and their number: *** Entering Test *** OneTwoThree TwoThree Three *** Entering Test *** OneTwo Two *** Entering Te...
View in text
Tags
AI categories
ProgrammingTechnologyEducation
ISBN: 0470069171
Publisher: Wiley/Wrox
Publish Year: 2007
Language: English
Pages: 673
File Format: PDF
File Size: 8.5 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…