Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Sektor 13 on Wed 25/06/2008 18:41:14

Title: Problems with GUI 6
Post by: Sektor 13 on Wed 25/06/2008 18:41:14
Hi

When a add new GUI (possition 6) I get following error:

Error (line 89): expected variable or function after import, not 'FindGUIID'

If i delete GUI (so i only have 5 guis than) game works fine.

It could be possible i overlooked something ?

GLOBAL SCRIPT:
// main global script file

// 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.
    SetVoiceMode(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;
  }
 
  //And now, set all the defaults
  SetMusicMasterVolume(100);
  sldMusic.Value = 200;
  sldSound.Value = 200;
  SetSoundVolume(200);
  SetGameSpeed(40);
  sldSpeed.Value = 40;
  if (IsSpeechVoxAvailable()) {
     SetVoiceMode(eSpeechVoiceAndText);
     btnVoice.Text = "Voice and Text";
     sldVoice.Value = 255;
     SetSpeechVolume(255);
  }
  if (System.SupportsGammaControl) {
    System.Gamma = 100;
    sldGamma.Value = 100;
  }
}

// Called when the game starts, before the first room is loaded
function 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();
  gGUI.Visible = false;
  gIconbar.Visible=false;
  game.text_speed = 12;
  mouse.Mode=eModeInteract;
  // 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 anything you want to happen every game cycle here
}

function show_inventory_window () {
  // This demonstrates both types of inventory window - the first part is how to
  // show the built-in inventory window, the second part uses the custom one.
  // Un-comment one section or the other below.
 
  // ** DEFAULT INVENTORY WINDOW
//  InventoryScreen();

  // ** CUSTOM INVENTORY WINDOW
  gInventory.Visible = true;
  // switch to the Use cursor (to select items with)
  mouse.Mode = eModeInteract;
  // But, override the appearance to look like the arrow
  mouse.UseModeGraphic(eModePointer);

}

// Called when a key is pressed. keycode holds the key's ASCII code
function on_key_press(int keycode) {
  // The following is called before "if game is paused keycode=0", so
  // it'll happen even when the game is paused.
 
  if (keycode==27 && 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==27 && gPanel.Visible) {
    // Use ESC to turn the panel off.
    gPanel.Visible = false;
    mouse.UseDefaultGraphic();
    gIconbar.Visible = true;
    return;
  }
  if (keycode==13) {
    // ENTER, in this case merely confirms restart
    if (gRestartYN.Visible) RestartGame();
  }

  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses

  // FUNCTION KEYS AND SYSTEM SHORTCUTS
  if (keycode==27) {
    // ESC
    gPanel.Visible = true;
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode==17)  QuitGame(1);   // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7
  if (keycode==367) {
    // F9, asks the player to confirm restarting (so much better to always confirm first)
    gRestartYN.Visible = true; 
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   show_inventory_window();  // Tab, show inventory

  // 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.

  // For extra cursor modes, such as pick up, feel free to add as you will.
  // Uncomment the line below if you use the "Pick Up" mode.
  //if (keycode == 'P' || keycode == 'G') mouse.Mode=eModePickup;

  // DEBUG FUNCTIONS
  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
  if (keycode==23 && game.debug_mode) player.PlaceOnWalkableArea(); //Ctrl-W, move to walkable area
}


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)
}

// Inventory Stuff //
if (button == eMouseLeftInv) {
if (mouse.Mode == eModeUseinv) {
inventory[game.inv_activated].RunInteraction(eModeUseinv);
mouse.Mode = eModeInteract;
}
else player.ActiveInventory = inventory[game.inv_activated];//.RunInteraction(mouse.Mode);
}
if (button == eMouseRightInv) {
if (mouse.Mode == eModeUseinv) mouse.Mode = eModeInteract;
inventory[game.inv_activated].RunInteraction(eModeLookat);
}
//end of inv

    if (mouse.IsButtonDown(eMouseLeft)) {
     
    if (GetLocationType (mouse.x, mouse.y) != 0) { // if the mouse is over a hotspot, object, or character


ProcessClick (mouse.x, mouse.y, mouse.Mode);

     if (mouse.Mode != eModeInteract) mouse.Mode = eModeInteract;
}

    else {
       ProcessClick (mouse.x, mouse.y, eModeWalkto);
      if ((GetGlobalInt(498)==1) && ((Region.GetAtRoomXY(mouse.x,mouse.y) == region[9]) || (Region.GetAtRoomXY(mouse.x,mouse.y) == region[10]) || (Region.GetAtRoomXY(mouse.x,mouse.y) == region[15]) || (Region.GetAtRoomXY(mouse.x,mouse.y) == region[11])|| (Region.GetAtRoomXY(mouse.x,mouse.y) == region[12])|| (Region.GetAtRoomXY(mouse.x,mouse.y) == region[13])|| (Region.GetAtRoomXY(mouse.x,mouse.y) == region[14])  )) SkipUntilCharacterStops(player.ID);
      SetTimer(20, 15);
      SetGlobalInt(498, 1);
         mouse.Mode = eModeInteract; // if the mouse isn't over a hotspot, object, or character
}   

}

 
  else if (mouse.IsButtonDown(eMouseRight)) {  //Look at the thing.
 
   
   
   if (mouse.Mode == eModeUseinv) mouse.Mode = eModeInteract;
 
   if (GetLocationType (mouse.x, mouse.y) != 0) ProcessClick(mouse.x, mouse.y, eModeLookat);
   



}

  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 interface_click(int interface, int button) {
  // This function is obsolete, from 2.62 and earlier versions.
}

function btnInvUp_Click(GUIControl *control, MouseButton button) {
  invCustomInv.ScrollUp();
}

function btnInvDown_Click(GUIControl *control, MouseButton button) {
  invCustomInv.ScrollDown();
}

function btnInvOK_Click(GUIControl *control, MouseButton button) {
   // They pressed the OK button, close the GUI
   gInventory.Visible = false;
   mouse.UseDefaultGraphic();
}

function btnInvSelect_Click(GUIControl *control, MouseButton button) {
 
   // They pressed SELECT, so switch to the Get cursor
   mouse.Mode = eModeInteract;
   // But, override the appearance to look like the arrow
   mouse.UseModeGraphic(eModePointer);
}

function btnIconInv_Click(GUIControl *control, MouseButton button) {
 
  show_inventory_window();
}

function btnIconCurInv_Click(GUIControl *control, MouseButton button) {
 
  if (player.ActiveInventory != null)
    mouse.Mode = eModeUseinv;
}

function btnIconSave_Click(GUIControl *control, MouseButton button) {
 
  SaveGameDialog();
}

function btnIconLoad_Click(GUIControl *control, MouseButton button) {
 
  RestoreGameDialog();
}

function btnIconExit_Click(GUIControl *control, MouseButton button) {
 
  QuitGame(1);
}

function btnIconAbout_Click(GUIControl *control, MouseButton button) {
 
  gPanel.Visible=true;
  gIconbar.Visible=false;
  mouse.UseModeGraphic(eModePointer);
}

function cEgo_Look()
{
  Display("Damn, I'm looking good!");
}

function cEgo_Interact()
{
  Display("You rub your hands up and down your clothes.");
}

function cEgo_Talk()
{
  Display("Talking to yourself is a sign of madness!");
}

//START OF CONTROL PANEL FUNCTIONS
function btnSave_OnClick(GUIControl *control, MouseButton button)
{
  gPanel.Visible = false;
  mouse.UseDefaultGraphic();
  gIconbar.Visible = true;
  Wait(1);
  btnIconSave_Click(btnIconSave, eMouseLeft);
}

/*function gControl_OnClick(GUI *theGui, MouseButton button)
{

}
*/
function btnAbout_OnClick(GUIControl *control, MouseButton button)
{
Display("Adventure Game Studio run-time engine default game.");
}

function btnQuit_OnClick(GUIControl *control, MouseButton button)
{
  gPanel.Visible = false;
  Wait(1);
  QuitGame(1);
  gPanel.Visible = true;
  gIconbar.Visible = false;
  mouse.UseModeGraphic(eModePointer);
}

function btnLoad_OnClick(GUIControl *control, MouseButton button)
{
  gPanel.Visible = false;
  mouse.UseDefaultGraphic();
  gIconbar.Visible = true;
  Wait(1);
  btnIconLoad_Click(btnIconLoad, eMouseLeft);
}

function btnResume_OnClick(GUIControl *control, MouseButton button)
{
  gPanel.Visible = false;
  mouse.UseDefaultGraphic();
  //gIconbar.Visible = true;
}

function sldMusic_OnChange(GUIControl *control)
{
  SetMusicMasterVolume(sldMusic.Value); 
}

function sldSound_OnChange(GUIControl *control)
{
  // This sets the sound volume. Note it'll also affect MOD and XM music - read the manual
  SetSoundVolume(sldSound.Value);
}

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 btnVoice_OnClick(GUIControl *control, MouseButton button)
{
  // 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 button won't even be available.
  if (btnVoice.Text == "Voice and Text") {
    SetVoiceMode(eSpeechVoiceOnly);
    btnVoice.Text = "Voice only";
  }
  else if (btnVoice.Text == "Voice only") {
    SetVoiceMode(eSpeechTextOnly);
    btnVoice.Text = "Text only";
  }
  else if (btnVoice.Text == "Text only") {
    SetVoiceMode(eSpeechVoiceAndText);
    btnVoice.Text = "Voice and Text";
  }
}

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 btnDefault_OnClick(GUIControl *control, MouseButton button)
{
  // Reset everything to default. You'll have to edit these as well as the sliders
  // if you'd rather have different default parameters.
  SetMusicMasterVolume(100);
  sldMusic.Value = 200;
  sldSound.Value = 200;
  SetSoundVolume(200);
  sldSpeed.Value = 40;
  SetGameSpeed(40);
  if (IsSpeechVoxAvailable()) {
     SetVoiceMode(eSpeechVoiceAndText);
     btnVoice.Text = "Voice and Text";
     sldVoice.Value = 255;
     SetSpeechVolume(255);
  }
  if (System.SupportsGammaControl) {
    System.Gamma = 100;
    sldGamma.Value = 100;
  }
}
//END OF CONTROL PANEL FUNCTIONS

function sldSpeed_OnChange(GUIControl *control)
{
  SetGameSpeed(sldSpeed.Value);
}

function btnRestart_OnClick(GUIControl *control, MouseButton button)
{
  gRestartYN.Visible=true;
  gIconbar.Visible=false;
}

function btnRestartYes_OnClick(GUIControl *control, MouseButton button)
{
  RestartGame();
}

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();
}

function gGggaga_OnClick(GUI *theGui, MouseButton button)
{

}

//////end of global script
Title: Re: Problems with GUI 6
Post by: SSH on Wed 25/06/2008 20:18:12
What did you call the GUI #6 (and #5, just to be sure), is it a reserved word or built-in function by any chance?

EDIT:
Let me guess, #5 is gGUI? Call it something else.
Title: Re: Problems with GUI 6
Post by: Shane 'ProgZmax' Stevens on Fri 27/06/2008 07:36:35
I have 8 working guis and I am using the current build of AGS.  Check the controls on the gui and make sure none of them are using names already in use by another one.
Title: Re: Problems with GUI 6
Post by: Sektor 13 on Sat 28/06/2008 09:52:07
SSH was right, no. 5 was named GUI, but i still don't know why no. 6 would work because of that !?

Now it work, still odd problem !?

thanx
Title: Re: Problems with GUI 6
Post by: Khris on Sat 28/06/2008 12:14:38
Well, obviously/apparently naming a GUI 'gGUI' screws up internal AGS stuff. Why would it be an odd problem?
Title: Re: Problems with GUI 6
Post by: Pumaman on Sat 28/06/2008 13:11:13
I'll look into that, the editor should probably stop you from naming it like that.
Title: Re: Problems with GUI 6
Post by: Sektor 13 on Sat 28/06/2008 16:04:03
Quote from: KhrisMUC on Sat 28/06/2008 12:14:38
Well, obviously/apparently naming a GUI 'gGUI' screws up internal AGS stuff. Why would it be an odd problem?
Its odd because gui 5 is named gGUI and works fine ! But next GUI (6) doesnt work no matter how you name it...



Yes, AGS should warn about "wrong" names :)