Skip to content
MMeent edited this page Mar 12, 2014 · 10 revisions

#Nailed Lua

Lua is the way to make your games more server-friendly and easier to manage. The easiest way to get started is to go to the terminal, accessible with the /terminal command.

##Terminal

Once you open the terminal, you'll see there are two tabs open, a tab named shell and a tab named game manager. The first is a normal shell, with some commands. The second tab is the tab where you can start your game, and where you can see some debug info about the game you are playing and have played.

##Shell Commands

There are several shell commands you can use to interact in the lua command line. Here they are:

command arguments explanation
cp <file> <destination> Copies file 'file' to the destination, relative to the current path.
cd <destination> Go to the destination folder. .. can be used for the map upstream.
bg [command] Opens a new tab that will run the command you used as an argument. If no command was given after bg, it opens another shell.
edit <file> Opens file 'file' to edit. After opening the file, you can use the control key to save and exit the editor.
<file> none Runs the file as lua code. This will not work if it is not valid lua.

##Lua Programming

Nailed uses the lua scripting language to make games more interactive. It contains various possibilities, which you can find at the official lua tutorial

###Nailed added functions

Nailed gives every lua program these extra objects:

####Map

The map is the main source of getting player- and team-objects. Possible functions include:

function explanation
.getPlayers() This function returns all the players in the map.
.getTeams() This function returns all the teams in the map.
.forEachPlayer(function(p) ... end) This function executes the function given over every player p in the map. 'p' is the variable the player is stored in in that function.
.forEachTeam(function(p) ... end) This function executes the function given over every team t in the map. 't' is the variable the team is stored in in that function.

####Player

The player is the most extended object in Nailed, and has various functions to it.

function explanation
.getTeam() Returns the team the player is in, nil if the player is in none.
.getUsername() Returns a string with the username of the player
.setTeam(\<team\>) Sets the team of the player to the team given

####Team

The team is ... lorem ipsum

function explanation
.get() Returns

Clone this wiki locally