Linking Scripts

This example shows how the link command can also be used to branch to pages in other scripts. This command is similar to the chain command except that it stores the names of the calling script and page on an internal LIFO stack so that the new script can return to the calling script and resume where it left off.

The name file of the target script is required and usually includes a path to a scripts folder as well. Only forward slash symbols (/) can be used in these paths; not backslash symbols (\). An extension of .lws is assumed for scripts. An optional second parameter may also be specified which names a target page in the script. If omitted, the new script will begin execution at the first page in the file. No condition options are allowed for this command.

Several return commands are used in the target script Tutorial_12_Subroutines to return back to this script. The return command always attempts to return from the previous call command first, within the same script. But, if the page call stack is empty, Lightwing then attempts to return to the previous script that executed the last link command, instead. If the script link stack is also empty, Lightwing reports a warning message and continues execution in the current script. The return command has no parameters since the internal stacks supply the required page and script names.

Look at the output in the Lightwing log window or file (lightwing\Log.txt) to see the script execution flow. Also refer to the online Scripting Guide for more details about these commands.

// Scripting Tutorial - Linking Scripts

version: 1.0
shadow: OpenSansBold_100    offset: 5

// Jump to one of seven planet pages based on the day of the week.
page: First
    jump: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday     index: Day

page: Sunday                 time: 1, 3    image: PlanetMercuryBackground.pvr
    text: OpenSansBold_100    time: 1, 2    fade: 1, 1    position: 50, 50    align: CenterCenter        type: DateLong
    link: scripts/Tutorial_13_Subroutines.lws, Sunday

page: Monday                time: 1, 3    image: PlanetVenusBackground.pvr
    text: OpenSansBold_100    time: 1, 2    fade: 1, 1    position: 50, 50    align: CenterCenter        type: DateLong
    link: scripts/Tutorial_13_Subroutines.lws, Monday

page: Tuesday                time: 1, 3    image: PlanetEarthBackground.pvr
    text: OpenSansBold_100    time: 1, 2    fade: 1, 1    position: 50, 50    align: CenterCenter        type: DateLong
    link: scripts/Tutorial_13_Subroutines.lws, Tuesday

page: Wednesday          time: 1, 3    image: PlanetMarsBackground.pvr
    text: OpenSansBold_100    time: 1, 2    fade: 1, 1    position: 50, 50    align: CenterCenter        type: DateLong
    link: scripts/Tutorial_13_Subroutines.lws, Wednesday

page: Thursday              time: 1, 3    image: PlanetJupiterBackground.pvr
    text: OpenSansBold_100    time: 1, 2    fade: 1, 1    position: 50, 50    align: CenterCenter        type: DateLong
    link: scripts/Tutorial_13_Subroutines.lws, Thursday

page: Friday                   time: 1, 3    image: PlanetSaturnBackground.pvr
    text: OpenSansBold_100    time: 1, 2    fade: 1, 1    position: 50, 50    align: CenterCenter        type: DateLong
    link: scripts/Tutorial_13_Subroutines.lws, Friday

page: Saturday               time: 1, 3    image: PlanetUranusBackground.pvr
    text: OpenSansBold_100    time: 1, 2    fade: 1, 1    position: 50, 50    align: CenterCenter        type: DateLong
    link: scripts/Tutorial_13_Subroutines.lws, Saturday

page: End

 

 

<   Chaining Scripts                                             Introduction                                            Video Loops   >