Cafu Engine
Console Class Reference

Use the methods of this library for printing strings to the Cafu in-game console. More...

Public Member Functions

 Print (string s)
 Prints a message to the in-game console. More...
 
 DevPrint (string s)
 Prints a developer message to the in-game console. More...
 
 Warning (string s)
 Prints a warning to the in-game console. More...
 
 DevWarning (string s)
 Prints a developer warning to the in-game console. More...
 
table GetDir (string dir, string mode="")
 Returns an array (a table) with the file and directory entries of the given directory. More...
 

Detailed Description

Use the methods of this library for printing strings to the Cafu in-game console.

Note that you don't have to create instances of this class yourself. Instead this class is used like a (Lua) library: A global instance Console is automatically available. See the function details below for examples on usage.

Member Function Documentation

DevPrint ( string  s)

Prints a developer message to the in-game console.

If the "developer" console variable is set, this prints the string s, prepended by "[Dev] ", to the Cafu in-game console. If the "developer" console variable is not set, nothing is printed.

Example:
Console.DevPrint("Hello world!\n") -- Prints "[Dev] Hello world!" to the in-game console (in developer mode).
Parameters
sThe developer message to print to the console.
DevWarning ( string  s)

Prints a developer warning to the in-game console.

If the "developer" console variable is set, this prints the string s, prepended by "[Dev] Warning: ", to the Cafu in-game console. If the "developer" console variable is not set, nothing is printed.

Example:
Console.DevWarning("Hello world!\n") -- Prints "[Dev] Warning: Hello world!"
-- to the in-game console (in developer mode).
Parameters
sThe developer warning to print to the console.
table GetDir ( string  dir,
string  mode = "" 
)

Returns an array (a table) with the file and directory entries of the given directory.

  • If the string "f" is passed as a second parameter, only entries of type file are returned,
  • if the string "d" is passed as a second parameter, only entries of type directory are returned,
  • all entries are returned in all other cases.
TODO:
This function should be implemented independently from the "Console" interface (i.e. elsewhere where it is a better topical fit), but for now the "Console" interface is the only interface that is included in all of our Lua instances (console interpreter, GUIs, map scripts, ...)!
IDEA:
Can we make ConVars and ConFuncs directly available not only in the console Lua instance, but in arbitrary many Lua instances?? Then the GUI and map scripts could directly access ConVars and ConFuncs, too...! (And GetDir() would be a regular ConFunc.)
Parameters
dirThe name of the directory to get the entries for.
modeWhether only file entries ("f"), only directory entries ("d"), or all entries should be returned. See above for details.
Print ( string  s)

Prints a message to the in-game console.

Example:
Console.Print("Hello world!\n") -- Prints "Hello world!" to the in-game console.
Parameters
sThe message to print to the console.
Warning ( string  s)

Prints a warning to the in-game console.

This is similar to Print(), except that the text "Warning: " is automatically prepended to the output.

Example:
Console.Warning("Problem here!\n") -- Prints "Warning: Problem here!" to the in-game console.
Parameters
sThe warning to print to the console.