Chapter     3

File Operations

When creating an app or a game, you need file I/O (input/output). You may not be working with a database, but there will always be the need to save something back to the disk; it could be the levels, the high score, a character the player might have unlocked, or some information regarding in-app purchases.

So, let’s first look at what we have available in terms of functions that offer file operation functionality. Lua has two sets of functions for file operations, one called implicit and the other explicit. The difference between the two is that implicit functions work on the default file as provided by the io namespace, whereas explicit functions work with a file handle provided from a previous operation, such ...

Get Learn Lua for iOS Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.