Scrupp 0.4 Manual
Create your own 2D games and applications

Architecture

architecture of applications using Scrupp

This figure shows the architecture of an application created with Scrupp. The whole development happens on the right side using Lua.

Operating systems

Windows

On Windows the easiest way to use Scrupp is to let the installer associate script files (*.slua) and archives (*.sar) with Scrupp. That way, a double-click on one of these filetypes automatically runs the file with Scrupp.

Another possibility is to drop either a script file, an archive, or a directory on the executable scrupp.exe. The dropped file or directory becomes the first command line argument. See Using the Command Line for details.

Linux

On Linux you can either configure your file manager to open the script files (*.slua) and archives (*.sar) with Scrupp, or use the command line.

Drag and drop is supported as well (see Windows).

Mac OS X

On Mac OS X the nescessary filetypes should be automatically associated with Scrupp. Thus, a double click on a script file (*.slua) or an archive (*.sar) should invoke Scrupp.

Drag and drop is supported as well (see Windows).

Using archives

Scrupp supports zip archives. You can compress all the files belonging to your application to a single zip file. The extension of the file is not important, but the default for a Scrupp archive is *.sar. Scrupp can load the archive and executes the main script file called main.slua. It is important that this file is located in the root of the zip file.

wrong:

archive.sar
  \-- myApp (folder)
        \-- main.slua

right:

archive.sar
  \-- main.slua

Using the Command Line

The following list shows the possibilitis for running Scrupp from the command line.

  1. No command line arguments
    $ scrupp [-- arg1 arg2 ... argN]

    Scrupp tries to open the file main.slua. The working directory of the script will be the one containing the executable. If this file is not found, Scrupp will try to open the zip archive main.sar which has to contain the file main.slua. If both files are not found, an error will be thrown. Extra arguments to the script have to be separated from the executable's name by --.

  2. A Lua file as argument
    $ scrupp <Lua file> [arg1 arg2 ... argN]

    Scrupp tries to execute the Lua file. The working directory will be the one containing the Lua file. It is possible to give extra arguments to the Lua file.

  3. A zip archive as argument
    $ scrupp <zip archive> [arg1 arg2 ... argN]

    The archive is prepended to the search path. The directory that contains the archive becomes the working directory. After this Scrupp tries to execute main.slua which should be located inside this archive. It is possible to give extra arguments to the Lua file.

  4. A directory as argument
    $ scrupp <directory> [arg1 arg2 ... argN]

    The directory is prepended to the search path and set as the working directory. After this Scrupp tries to execute main.slua which should be located inside this directory. It is possible to give extra arguments to the Lua file.

Script arguments

Before running a Lua file, Scrupp collects all command line arguments in the global table arg. The name of the chosen Lua file, directory or archive becomes the element at index 0 in that table. Additional arguments are stored in index 1, 2 and so on. The name of the executable goes to index -1. The script can access these arguments by using arg[1], arg[2], etc. or the vararg expression '...'.

-- print the name of the script
print("name of the script:", arg[0])

-- print the number of arguments to the script
print("number of arguments:", select('#', ...) )

-- print all arguments
print("arguments:", ...)

-- this prints the first argument
print("Argument 1: ", arg[1] or "none")

-- exiting Scrupp
scrupp.exit()

Just save this example code in a file called argtest.lua and run

$ scrupp argtest.lua arg1 arg2

This can be done with every example from the manual. To get started have a look at the General Functions, save the example in a file and run this file with Scrupp.


Hosted by
SourceForge.net Logo

Valid XHTML 1.0!

Last modified Tue Jun 16, 2009