SLUDGE

Variables


SLUDGE has only one variable structure - the "var" - which can hold many different types of data. The different data types which can be held in a SLUDGE variable are:

Undefined:

Not much use, but it's the value to which variables are initialised, and the default return value from user defined functions.

Numbers:

For those of you who know C or C++, they're long signed integers. For everyone else, they're big but they can't do decimal points. Whoever heard of an adventure game saying "It's a bag of 482.66666666667 gold coins"?

Strings:

Used for holding text. All of the other data types can be turned into strings automatically, making debugging a lot simpler - see the Treating Variables as Strings page.

File handles:

How do you get a picture, sound, sprite bank or floor into your code? Here's how. Read up on these in the File Handling section.

Object types:

Objects, actions and characters. More information on creating and using these is available in the Object Types and Events section.

Stacks:

These double as arrays, but you don't have to set any boundaries. Stacks can hold any number (including 0) of other variables of any - or mixed - data types. And yes, that includes other stacks. See the section about The Multi-Purpose Stack / Array / Queue Type for more information.

Function handles:

Pass a function around like a variable! Fun, fun, fun. There's more information here.

Animations:

Created using the anim function.

Costumes:

Created using the costume function.

Local and global variables:

Variables can be local or global. Local variables (defined inside a function) exist for only the duration of the function in which they are defined; global variables (defined outside of all the functions) are accessible to everything. For example:

var thisIsGlobal = 5;

sub someFunction () {
   var thisIsLocal = 10;
   say (ego, thisIsGlobal + thisIsLocal);
   # Fine
}

sub someOtherFunction () {
   say (ego, thisIsGlobal + thisIsLocal);
   # Not fine... in this function we have no idea what "thisIsLocal" is
}

More on this subject:

Treating Variables as Booleans

Treating Variables as Strings

The Multi-Purpose Stack / Array / Queue Type

Variable Operations