What is Lingo?
Lingo is Director's programming, or scripting, language. It is mature and powerful and an essential part of creating in-depth interactivity.
Types of Lingo scripts
Lingo scripts can exist in many locations throughout Director ...
-
Sprite scripts (Behaviours) are attached to sprites or groups of sprites in the score.
-
Cast member scripts are attached to individual cast members
-
Frame scripts (Behaviours) are attached to cells in the scores Scripting/Behaviours channel
-
Movie scripts are not attached to anything they are simply written and appear in the cast
Object hierarchy
In Lingo scripts are called Objects. When an event occurs a message is sent through these objects in a specific order ...
-
Scripts attached to the sprite in question eg the button that was clicked.
-
Cast member of the sprite in question.
-
Scripts attached to the current frame.
-
Movie scripts.
Lingo Elements
Handlers
Start with "on" and end with "end". There are 2 types:
-
Event handlers - eg "on mouseUp"
-
Custom handlers - eg "on fred". These handlers are triggered by "calls" rather than events.
Sound control 1 tutorial movie (.dir)
Commands
A Command is an instruction.
eg "go"
eg "delete"
eg "do"
eg "beep"
Functions
A Function gives a result.
eg The "clickOn" function returns the value (or number) of the sprite which has been clicked on.
eg The "date" is a function which returns the current date.
ClickOn function tutorial movie (.dir)
Properties
A Property is a specific value attached to an item. Properties can be changed interactively or over time. Property names are always preceded by "the"
eg the stagecolor
eg the locH (horizontal location)
Interaction 1 tutorial movie (.dir)
Operators
Operators are mathematical expressions.
eg "+"
eg "x"
Keywords
Keywords complete the syntax of a script.
eg "the"
eg "to"
eg "repeat"
Variables
A variable is a "container" (bit of RAM) that may contain either -
-
Expressions
-
Strings (text). Any set of characters enclosed in quotations (") is considered a string.
-
Values (numbers)
-
Booleans (eg true or false, on or of)
-
Integers (whole numbers)
-
etc
There are 4 types of variables:
-
Local variables A local variables only exist inside the handler that initialised it (by naming therefore creating them). Local variables cannot be "interrogated" by other variables.
-
Global variables A global variable may be interrogated at any time by any handler.
-
Arrays (called Lists in Lingo) There are 2 types of lists. 1) Property lists. 2) Lists
-
Constant A variable that once initialised with a value doesn't change, such as - the best score in a game or a players name.
Global variables / field text feedback tutorial movie (.dir)
Sound control 1 tutorial movie (.dir)
Need help downloading these files?
Control statements
Control statements always start with "if". For example ...
if the member of sprite the CurrentSpriteNum = "Button up" then
set the member of sprite the currectSpriteNum = "Button down"
else
nothing
end if
Blending disc tutorial movie (.dir)
Spinning disc tutorial movie (.dir)
Interaction 1 tutorial movie (.dir)
Need help downloading these files?
Repeat loops
Repeat loops start with "repeat" and finish with "end". The statements between them will repeat until a condition is met. There are several types of Repeat Loop such as "repeat while" and "repeat with". The following is a script example:
on startMovie
startTimer
repeat while the timer < 200
beep
end repeat
end
Repeat while loop/Timer movie (.dir)
Repeat with loop/Timer movie (.dir)
Need help downloading these files?
Field text
Ai addition to standard "display" text fields, Lingo uses "live" field text elements which allow user entry and can be used to display results of calculations or other processes.
Calculator tutorial movie (.dir)
Simple quiz tutorial movie (.dir)
Global variables / field text feedback tutorial movie (.dir)
Need help downloading these files?
MIAWs (Movies In A Window)
A MIAW is an object in RAM. It's a movie launched into its own window by another movie which is already running in RAM. Click here for more.