Using Lobster from the command line

Basic usage

If you have a file helloworld.lobster that contains

print "Hello, World!"

then running it like so will compile and run it:

bin/lobster helloworld.lobster

Command line options

Format: lobster [ OPTIONS ] [ FILE ] [ -- ARGS ]

Lobster source code may start with a shebang #! so you can embed the command-line in a Lobster script.

Default directories

It's useful to understand the directories lobster uses, both for reading source code files and any data files the program may use:

Additionally, if any of these folders contains a modules directory, it will load source code from there as well.

Any of the Lobster builtin commands that load data files specify paths relative to either the main or auxiliary directories (and either / or \ may be used as path separators). If you package up a Lobster program for distribution, all these files can be packed into a pakfile, see --pak.

Output

Running lobster may result in a compiler error, that generally look something like this:

mygame.lobster(960): error: unknown identifier: highscor

If compiled correctly, running will give you output from your own print statements, and additionally at some point may cause a runtime error, which can look something like this:

pythtree.lobster(15): VM error: division by zero
in block -> pythtree.lobster(16)
   i = 0
in block -> pythtree.lobster(16)
in function: branch -> pythtree.lobster(29)
   poly = [[1.000000, 0.000000, 0.000000, 0.000000]:xyzw, [-1.000000, ...]:xyzw, ....]
   len = 4
   scale = 0.700000
   max = 11.000000
   n = 0
in block -> pythtree.lobster(29)

This is called a stack trace. Besides the error and the line it happened on, it will show all functions and blocks that called that code, in reverse order, with any local variables and their values. This helps you get an idea where the problem came from and helps in debugging.