Lua lets you insert dynamic objects into your game code.
Lua is a basic coding language, typically used for dynamic graphics in two-player games. Lua retrieves values from other parts of the game code, using a series of IDs, and represents that information in graphical form. For this reason, Lua is particularly suitable for creating scoreboards. As the players trigger the various console commands, the scoreboard reflects the dynamics of the game. For example, in a two person beat-em-up game, the scoreboard may show "1" when player 1 hits player 2.
Instructions
1. Open a blank plain text document, such as Microsoft Notepad.
2. Define a table in Lua code. To define a table in Lua, input a pair of curly brackets, or "{ }." The table you define in Lua must correspond to a table that already exists in the other code. For example, if the main part of the game is in Flash or HTML, copy and paste the ID code from that section between the two parameters. The Lua table is a graphical representation of a function occurring elsewhere in the code. So if a player scores a goal in the game and the code is written so when that happens, the values in the HTML or Flash table alter, the Lua table represents this on the scoreboard graphic.
3. Write a list of fixed parameters in the table, separated by commas, between the brackets. Do this by using an ID that corresponds to fixed parameters elsewhere in the game code. For example, "Player," which may correspond to a graphic or command.
4. Input dynamic values by inserting them between the curly brackets, separated by commas. Naturally these will be variable values. For example, if you are making a scoreboard for a basketball game, the "Home Team" and "Visitors" titles will remain constant, while the scores are variable. You can retrieve these values from the game code. Browse the code for the lines containing the console commands, such as "Hit player 1." To the left of this command, you'll see a command ID, for example "{runconsolecommand1}."
5. Input object values between the brackets. The scoreboard is defined in Lua as an "object." Object values are those that govern how the object appears, for example colors and vectors. The colors are represented by numbers, for example "125" for red. You can set level of opaqueness too. The maximum opaque setting is "255." Separate these values by commas.
6. Log into your Lua account using the credentials you gave when you signed up.
7. Copy the completed code from the plain text editor into the main body of the code editor. If you haven't signed up for a free Lua account, you can use the demo editor.
8. Click "Run" to view the scoreboard.
Tags: game code, between brackets, code example, code from, console commands, curly brackets