Bitfighter  021
The Bitfighter Lua Documentation - Robots, Levelgens, and Plugins
global Class Reference

Static Member Functions

findFile(filename)
 Finds a specific file to load from various Lua folders.
 
getMachineTime()
 Get the time according to the system clock.
 
getRandomNumber(m, n)
 Better random number generated than that included with Lua. [details]
 
getVersion()
 Get the current Bitfighter version as a string. [details]
 
logprint(val)
 Print to bitfighter's logging engine. [details]
 
print(val)
 Print to the in-game console. [details]
 
readFromFile(filename)
 Reads in a file from our sandboxed IO directory. [details]
 
writeToFile(filename, contents, append)
 Write or append to a file on the filesystem. [details]
 

Member Function Documentation

◆ global.findFile(filename)

Arg types: filename: string  |  returns string
static

Finds a specific file to load from various Lua folders.

Scans our scripts, levels, and robots directories for a file, in preparation for loading.

Parameters
filenameThe file you're looking for.
Returns
The path to the file in question, or nil if it can not be found.

◆ global.getMachineTime()

returns int
static

Get the time according to the system clock.

Returns
Machine time (i.e. wall clock time) in milliseconds.

◆ global.getRandomNumber(m, n)

Arg types: m: int, n: int  |  returns num
static

Better random number generated than that included with Lua.

General structure and peculiar error messages taken from lua math lib. Docs for that are as follows; we should adhere to them as well:

This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.) When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n] where m, n is greater than or equal to 0.

Parameters
m(optional) Used for either [1, m] or [m, n] as described above.
n(optional) Used for [m, n] as described above.
Returns
A random number as described above

◆ global.getVersion()

returns string
static

Get the current Bitfighter version as a string.

Returns
Bitfighter Version.

◆ global.logprint(val)

Arg types: val: any  |  returns nothing
static

Print to bitfighter's logging engine.

This will (currently) print to the bitfighter log file as well as stdout.

Parameters
valThe value you wish to print.

◆ global.print(val)

Arg types: val: any  |  returns nothing
static

Print to the in-game console.

This hijacks Lua's normal 'print' command that goes to stdout and instead redirects it to the in-game console.

Parameters
valThe value you wish to print.

◆ global.readFromFile(filename)

Arg types: filename: string  |  returns string
static

Reads in a file from our sandboxed IO directory.

Reads an entire file from the filesystem into a string.

Parameters
filenameThe filename to read.
Returns
The contents of the file as a string.
Note
This function will only look for files in the screenshot directory of the Bitfighter resource folder.

◆ global.writeToFile(filename, contents, append)

Arg types: filename: string, contents: string, append: bool  |  returns nothing
static

Write or append to a file on the filesystem.

This is in a sandboxed environment and will only allow writing to a specific directory.

Parameters
filenameThe filename to write.
contentsThe contents to save to the file.
append(optional) If true, append to the file instead of creating a new one.
Note
This function will only write to files in the screenshot directory of the Bitfighter resource folder.