Scripting Basics - GameGrumpsJointJustice/courtengine GitHub Wiki

Intro

The script for a trial is formatted as a .script text file containing only the following:

  • Non-indented lines beginning with commands, which appear fully capitalized
  • Indented lines containing parameters for the previous command
  • Comment lines beginning with //, which are ignored by the engine.

Special Commands

Select Scene Type

SET_SCENE_TYPE [sceneType]

A script is expected to start with this command to designate what type of scene it should be. Current options for sceneType are either INVESTIGATION or TRIAL.

End Scene

END_SCENE

This must be the last command in a .script file, to notify the Game Engine to go to the next script.

End the game

GAME_OVER

If the player has reached a point where the game should be over, this command will bring them to that flow. Currently, this just quits the game.

Game Definitions

DEFINE [definitionName]
    [definitionScript]
END_DEFINE

Various commands in the game engine will support using a pre-defined script block to trigger a different part of a script when something happens. In each of these cases, the block must start with DEFINE, end with END_DEFINE, and have a unique definitionName for the other command to reference them by.

The commands that definitions are typically used for:

Setting the Scene

Background

The following commands are supported for controlling the background displayed during the game.

JUMPCUT [backgroundFileName]
CLEAR_LOCATION [backgroundFileName]

Note that backgroundFileName is expected to correspond with a PNG file name in /backgrounds, e.g.:

JUMPCUT LOBBY
// This will display the /backgrounds/lobby.png image as the background

For convenience, we support both of the following options for switching to a black background, with the only current difference being the transition.

JUMPCUT BLACK_SCREEN
FADE_TO_BLACK

Music

The following commands are supported for controlling the music played during the game.

PLAY_MUSIC [musicFileName]
STOP_MUSIC

Note that musicFileName is expected to correspond with an MP3 file name in /music, e.g.:

PLAY_MUSIC PRELUDE
// This will play /music/prelude.mp3

If PLAY_MUSIC is called when the song is already playing, it will not be interrupted. To restarted a song, call STOP_MUSIC first.

Sound Effects

The following commands are supported for playing a sound effect during the game.

SFX [sfxFileName]

Note that sfxFileName is expected to correspond with a WAV file name in /sounds, e.g.:

SFX lightbulb
// This will play /sounds/lightbulb.wav

Misc Effects

At any point, the following commands may also be called for effect:

SCREEN_SHAKE
WAIT [number of seconds to pause for]

Initialization

The following must be configured prior to their use.

Characters

Characters must first be initialized with CHARACTER_INITIALIZE before used.

CHARACTER_INITIALIZE [characterName] [folderName] [gender]

    characterName - The name that this character will be called in other commands
    folderName - The name of the folder within `/characters` that contains the spritesheets for this character
    gender - The voice SFX that should be played during the talk animation. Current options: Male, Female.

Example:

CHARACTER_INITIALIZE Arin arin MALE

Profiles

Profiles must first be initialized with PROFILE_INITIALIZE before used.

EVIDENCE_INITIALIZE [profileName] [profileDisplayName] [age] [description] [fileLocation]
    profileName - The name that this evidence will be called in other commands
    profileDisplayName - The name this profile will be shown with in Court Records
    age - The age of the character associated with the profile
    description - The description that should appear in Court Records
    fileLocation - Where the engine should look to find the PNG for this profile

Example:

PROFILE_INITIALIZE Mia "Mia Fey" 27 "Chief Attorney at Fey & Co. My boss, and a very good defense attorney." profiles/mia.png

After initialization, profiles can be added to the Court Records UI with the following:

COURT_RECORD_ADD PROFILES [profileName]

Example:

COURT_RECORD_ADD PROFILES Mia

Evidence

Evidence must first be initialized with EVIDENCE_INITIALIZE before used.

EVIDENCE_INITIALIZE [evidenceName] [evidenceDisplayName] [description] [fileLocation]
    evidenceName - The name that this evidence will be called in other commands
    evidenceDisplayName - The name this piece of evidence will be shown with in Court Records
    description - The description that should appear in Court Records
    fileLocation - Where the engine should look to find the PNG for this evidence

Example:

EVIDENCE_INITIALIZE BrokenWineGlass "Broken Wine Glass" "It's sharp and pointy, useful for murder." evidence/broken_wine_glass.png

After initialization, evidence can be added to the Court Records UI with the following:

COURT_RECORD_ADD EVIDENCE [evidenceName]

Example:

COURT_RECORD_ADD EVIDENCE BrokenWineGlass