Lua is a popular language for computer games.
Lua is a lightweight scripting language that is meant to be embedded in another application. Due to its speed and low memory footprint, it is very popular for PC games, and is used in titles such as "World of Warcraft" and the "Stalker" series. If you are interested in learning more about Lua script writing, you can get started today by writing a simple script that stores a set of coordinates and prints them out. This can serve as a stepping stone to more advanced scripts.
Instructions
1. Right-click on the desktop or any empty area of any folder to open a context menu. Select "New" and choose "Text File" to create a new text file. Name this file "coordinates.lua."
2. Create a two-element table named "coordinates" that holds the coordinates on a two-dimensional plane. Since Lua variables do not have types, you can simply declare a variable name and assign it values, like this:
coordinates = {42, 13}
3. Print the coordinates out to an output window by explicitly accessing each element in the table. Unlike arrays in other programming languages, Lua tables begin counting at 1, not 0. To print out the first element of the table, write the following statement:
print(coordinates[1])
4. Print the second coordinate using the following statement:
print(coordinates[2])
5. Save the file by pressing the key combination "Ctrl" and "S."
6. Open a command prompt and type in "lua coordinates.lua" and press the "Enter" key. The script is executed and the following output is printed:
42
13
Tags: coordinates Print, element table, following statement, following statement print, print coordinates, statement print