Module os

This is the Lua "os" standard module, as extended by blitwizard.

(Check here for the documentation of the Lua "os" standard functions)

Blitwizard extends Lua's "os" module with a few additional functions as documented here. Hopefully they'll be useful with your game building!

Info:

  • Copyright: 2011-2013
  • License: zlib
  • Author: Jonas Thiem (jonas.thiem@gmail.com)

Functions

sysname () Return the name of the operating system your game is currently running on.
sysversion () Return the detailed version of the operating system your game is currently running on.
exists (path) Check if a given path to a file or directory exists (it points to a valid file or directory).
isdir (path) Check if the given path points to a directory or not.
ls (directory, virtual_files) Returns a table array containing all the file names of the files in the specified directory.
getcwd () Get an absolute path to the current working directory (sometimes(!) this is where the blitwizard binary is located - but not necessarily)
chdir (directory) Change the current working directory to the specified directory
openConsole () Open a visible console window (in addition to the regular blitwizard graphics output window) where the standard output of blitwizard can be read.
templatedir () Get the absolute folder path of the template directory.
forcetemplatedir (path) Set the template folder to a given path if not previously set.
gameluapath () Get the path of the game.lua file which has been loaded at startup.
reload () This function reloads the game.lua file that has been initially loaded by blitwizard on startup.


Functions

sysname ()
Return the name of the operating system your game is currently running on.

Returns:

    string Operating system name
sysversion ()
Return the detailed version of the operating system your game is currently running on.

Returns:

    string Operating system version
exists (path)
Check if a given path to a file or directory exists (it points to a valid file or directory). Returns true if that is the case, or false if not.

Parameters:

  • path string file or directory path

Returns:

    boolean true if target exists, false if not
isdir (path)
Check if the given path points to a directory or not. If it points to a file or to nothing, this function returns false. If it points to a directory, it returns true.

Parameters:

Returns:

    boolean true if target is directory, false if not
ls (directory, virtual_files)
Returns a table array containing all the file names of the files in the specified directory.

Important: this function lists both files from actual directories on hard disk, and virtual directories loaded through loaded zip resource archives. Virtual files will take precedence over real files (you won't receive duplicates).

If you don't want virtual files listed (e.g. because you want to examine any directory supplied by the user and not part of your project)

Parameters:

  • directory string path, empty string ("") for current directory
  • virtual_files boolean (optional) Specify true to list virtual files inside virtual directories aswell (the default behaviour), false to list only files in the actual file system on disk

Usage:

       -- list all files in current directory:
       for i,file in ipairs(os.ls("")) do
           print("file name: " .. file)
       end
getcwd ()
Get an absolute path to the current working directory (sometimes(!) this is where the blitwizard binary is located - but not necessarily)

Returns:

    string absolute directory path
chdir (directory)
Change the current working directory to the specified directory

Parameters:

openConsole ()
Open a visible console window (in addition to the regular blitwizard graphics output window) where the standard output of blitwizard can be read. This function only has an effect on Windows, where applications are rarely launched from a terminal.

If you write a console application on Windows, you will want to call this on program startup.

templatedir ()
Get the absolute folder path of the template directory. Returns nil if no template directory was found.

The template directory contains common Lua extensions for blitwizard which offer font rendering and more.

Returns:

    string absolute folder path of template directory (or nil if none). Can be a relative path if loaded from a .zip archive
forcetemplatedir (path)
Set the template folder to a given path if not previously set. You will most likely never use this function, the templates need them to work in some cases.

Parameters:

  • path string template directory
gameluapath ()
Get the path of the game.lua file which has been loaded at startup.

Returns:

    string absolute file path to game.lua if a file on disk, relative path to game.lua if loaded from a .zip archive
reload ()
This function reloads the game.lua file that has been initially loaded by blitwizard on startup.

For a well-written game.lua, this will reload the game code without affecting the game state (the game will continue to run from where it left off).

This function is provided by the templates and only present if you use them.

generated by LDoc 1.3.11