// A function that initializes a bunch of stuff.function initialize_control_panel() { // Centre the control panel gPanel.Centre(); // Centre the Restart dialog as well gRestartYN.Centre(); if (!IsSpeechVoxAvailable()) { // If there is no speech-vox file, and therefore no speech, // disable all the controls related with speech. lblVoice.Visible = false; btnVoice.Visible = false; sldVoice.Visible = false; } else { // If there *is*, then set it to voice and text. It's best to use // both whenever possible, for the player's sake. Speech.VoiceMode = eSpeechVoiceAndText; // And reflect this in the control panel. btnVoice.Text = "Voice and Text"; } if (!System.SupportsGammaControl) { // If we can't change the gamma settings, disable the relevant options. sldGamma.Visible = false; lblGamma.Visible = false; }

// Called when the game starts, before the first room is loadedfunction game_start() { // Put the code all in a function and then just call the function. // It saves cluttering up places like game_start. initialize_control_panel(); // Use the KeyboardMovement module to, per default, replicate the standard // keyboard movement of most Sierra games. See KeyboardMovement.txt for more info KeyboardMovement.SetMode(eKeyboardMovement_Tapping); }

function repeatedly_execute() {

// Put here anything you want to happen every game cycle, even when // the game is paused. This will not run when the game is blocked // inside a command like a blocking Walk()

if (IsGamePaused() == 1) return;

// Put here anything you want to happen every game cycle, but not // when the game is paused.}

function repeatedly_execute_always() {

// Put anything you want to happen every game cycle, even // when the game is blocked inside a command like a // blocking Walk(). // You cannot run blocking commands from this function.

// Called when a key is pressed. keycode holds the key's ASCII codefunction on_key_press(eKeyCode keycode) { // The following is called before "if game is paused keycode=0", so // it'll happen even when the game is paused.

if ((keycode == eKeyEscape) && gRestartYN.Visible) { //Use ESC to cancel restart. gRestartYN.Visible = false; gIconbar.Visible = true; // If the panel's not ON, then the player must have gotten here by tapping F9, // therefore his cursor needs restoring. If the panel IS on, then it doesn't, // because it's already a pointer. Get used to thinking like this!! if (!gPanel.Visible) mouse.UseDefaultGraphic(); return; } if ((keycode == eKeyEscape) && gPanel.Visible) { // Use ESC to turn the panel off. gPanel.Visible = false; mouse.UseDefaultGraphic(); gIconbar.Visible = true; return; } if ((keycode == eKeyEscape) && (gSaveGame.Visible)) { // Use ESC to close the save game dialog close_save_game_dialog(); return; } if ((keycode == eKeyEscape) && (gRestoreGame.Visible)) { // Use ESC to close the restore game dialog close_restore_game_dialog(); return; }

// GAME COMMAND SHORTCUTS if (keycode == 'W') mouse.Mode=eModeWalkto; //Notice this alternate way to indicate keycodes. if (keycode == 'L') mouse.Mode=eModeLookat; //Note that all we do here is set modes. if (keycode == 'U') mouse.Mode=eModeInteract; //If you want something else to happen, such as GUI buttons highlighting, if (keycode == 'T') mouse.Mode=eModeTalkto; //you'll need some more scripting done. if (keycode == 'I') mouse.Mode=eModeUseinv; //But this will, as-is, give you some standard keyboard shortcuts your players will very much appreciate.

function on_mouse_click(MouseButton button) { // called when a mouse button is clicked. button is either LEFT or RIGHT if (IsGamePaused() == 1) { // Game is paused, so do nothing (ie. don't allow mouse click) } else if (button == eMouseLeft) { ProcessClick(mouse.x, mouse.y, mouse.Mode ); } else if (button == eMouseRight || button == eMouseWheelSouth){ // right-click our mouse-wheel down, so cycle cursor mouse.SelectNextMode(); } else if (button == eMouseMiddle) { // Middle-button-click, default make character walk to clicked area (a little shortcut) // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to // leave our options open - what if you have a special script triggered // on "walking" mode? ProcessClick(mouse.x, mouse.y, eModeWalkto); } else if (button == eMouseWheelNorth) { // Mouse-wheel up, cycle cursors // If mode isn't WALK, set the previous mode (notice usage of numbers instead // of eNums, when it suits us)... if (mouse.Mode>0) mouse.Mode=mouse.Mode-1; else { // ...but if it is WALK mode... if (player.ActiveInventory!=null) { //...and the player has a selected inventory item, set mouse mode to UseInv. mouse.Mode=eModeUseinv; } else { // If they don't, however, just set it to mode TALK (change this line if you add more cursor modes) mouse.Mode=eModeTalkto; } } }}

function sldVoice_OnChange(GUIControl *control){ // Sets voice volume. Note that we don't check for the existence of speech.vox - // we did that in game_start, so if it's not there the slider won't even be available. SetSpeechVolume(sldVoice.Value); }

function sldGamma_OnChange(GUIControl *control){ // Set the gamma. Note there's no need to check for anything else, as we ensured, // in game_start, that the slider won't even appear if it's not possible to do this. System.Gamma = sldGamma.Value; }

function btnRestartNo_OnClick(GUIControl *control, MouseButton button){ gRestartYN.Visible = false; gIconbar.Visible = true; // If the panel's not ON, then the player must have gotten here by tapping F9, // therefore his cursor needs restoring. If the panel IS on, then it doesn't, // because it's already a pointer. Get used to thinking like this!! if (!gPanel.Visible) mouse.UseDefaultGraphic(); }