Not sure what you would call this? [SOLVED]

Started by Candle, Mon 10/01/2005 13:56:16

Previous topic - Next topic

Candle

If you move the mouse over a item  you can show somewhere  on the screen what they are looking at . is this hard to do ?

Ishmael

I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Candle

Thank you Ishmael , that should work for me :) if I need help I'll be back to ask .

Candle

---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was in 'Global script':



Error (line 58): Parse error: unexpected 'if'
Code: ags

///////////////////////////////////////////////////////////
// RON TEMPLATE ///////////////////////////////////////////
// BY EDMUNDO RUIZ (netmonkey) ////////////////////////////
// SAVE/LOAD CODE BORROWED FROM GAC'S SAVE/LOAD TUTORIAL //
///////////////////////////////////////////////////////////

// main global script file

// SAVE, LOAD, and INVENTORY FUNCTIONS

string text;
int index;

function Save() {
  SetMouseCursor(6);
  SetTextBoxText(SAVE,1,"");		// Clear Text box
  ListBoxSaveGameList(SAVE,3);		// Fill List Box with saved games
  index = ListBoxGetNumItems(SAVE,3);	// Count how many saved games there are           
  if (index > 19) 			// If saved games 20 (maximum) 
    DisplayMessage(990); 		// Display warning 
  index = 0;
  InterfaceOn(SAVE);			// Bring Save interface on     
}

function Load() {
 SetMouseCursor(6);
 ListBoxSaveGameList(LOAD,0);		// Fill List box with saved games  
 InterfaceOn(LOAD); 			// Bring restore Interface on 
}

function show_inventory_window () {
  if(game.num_inv_items > 0) {		// ** CUSTOM INVENTORY WINDOW
    GUIOn (INVENTORY);    		// switch to the Use cursor (to select items with)
    SetCursorMode (MODE_USE);  		// But, override the appearance to look like the arrow
    SetMouseCursor (6);
    GUIOff(ICONBAR);
  }
  else DisplayMessage(996);
}

// THE REST

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
  CentreGUI(LOAD);
  CentreGUI(SAVE);
  CentreGUI(INVENTORY);
  }
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
}

if (GetCursorMode()==0) SetLabelText(0,0,"Walk to @OVERHOTSPOT@")
  if (GetCursorMode()==1) SetLabelText(0,0,"Look at @OVERHOTSPOT@")
  if (GetCursorMode()==2) SetLabelText(0,0,"Interact with @OVERHOTSPOT@")
  if (GetCursorMode()==3) SetLabelText(0,0,"Talk to @OVERHOTSPOT@")
  if (GetCursorMode()==4) {
    string usinginv;
    string useinvtxt;
    StrCopy (useinvtxt, "Use ");
    GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);
    StrCat (useinvtxt,usinginv);
    StrCat (useinvtxt," with ");
    StrCat (useinvtxt,"@OVERHOTSPOT@");
    SetLabelText(0,0,useinvtxt);
}

#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  QuitGame(1);   // Ctrl-Q
  if (keycode==363 && GetCursorMode() != 7) Save();   // F5
  if (keycode==365) Load();  // F7
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9 && GetCursorMode() != 7) show_inventory_window();  // Tab, show inventory

  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
}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int 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==LEFT)
    ProcessClick(mouse.x, mouse.y, GetCursorMode());
  else if (button == RIGHT && GetCursorMode() != 6 && GetCursorMode() != 7)   // right-click, so cycle cursor
      SetNextCursorMode();
  else if (button == WHEELNORTH) {
    if(IsGUIOn(INVENTORY) && game.top_inv_item > 0) 
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    else { // Set Previous Cursor Mode
      int current_mode = GetCursorMode();
      if(current_mode >= 0) {	// if it's the standard actions...
        current_mode--;
        if ((current_mode < 0) & (character[GetPlayerCharacter()].activeinv >= 0)) current_mode = 4; 
        else if (current_mode < 0) current_mode = 3;
        SetCursorMode(current_mode);
        }
      }
    }
  else if(button == WHEELSOUTH)
    if(IsGUIOn(INVENTORY) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed))
      game.top_inv_item = game.top_inv_item + game.items_per_line;
    else SetNextCursorMode();
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 4) {  // show inventory
      show_inventory_window();
    }
    else if (button == 5) {   // use selected inventory
      if (character[ GetPlayerCharacter() ].activeinv >= 0)
        SetCursorMode(4);
    } 
    else if (button == 6)    // save game
      Save();
    else if (button == 7)   // load game
      Load();
    else if (button == 8)   // quit
      QuitGame(1);
    else if (button == 9)    // about
      Display("Reality-on-the-Norm[[Made with Adventure Game Studio[Copyright (c) 1999-2003 Chris Jones");
  }  // end if interface ICONBAR

  if (interface == INVENTORY) {
    // They clicked a button on the Inventory GUI
    
    if (button == 1) {
      // They pressed SELECT, so switch to the Get cursor
      SetCursorMode (MODE_USE);
      // But, override the appearance to look like the arrow
      SetMouseCursor (6);
    }
    
    if (button == 2) {
      // They pressed LOOK, so switch to that mode
      SetActiveInventory(-1);
      SetCursorMode(MODE_LOOK);  
    }
    if (button == 3) {
      // They pressed the OK button, close the GUI
      GUIOff (INVENTORY);
      GUIOn(ICONBAR);
      SetDefaultCursor();
    }

    if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
      // scroll down
      game.top_inv_item = game.top_inv_item + game.items_per_line;
    }
    if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }
  }
  
  if (interface == SAVE) {			// if save interface
    if (button == 3) {
      ListBoxGetItemText(SAVE, 3, ListBoxGetSelected(SAVE, 3), text);
      SetTextBoxText(SAVE, 1, text);
      index = 21;
    }
    if (button == 1 || button == 5) {
      GetTextBoxText(SAVE,1,text); 		// Get the typed text
      if (StrCaseComp(text, "") != 0) { 	// If text not empty
        InterfaceOff(SAVE);			// Close interface
        SetDefaultCursor();
        if (index < 20)	{			// if less than 20
          index = ListBoxGetNumItems(SAVE,3);
          SaveGameSlot(index+1,text); 		// Save game (text as description)
        }
        else {					// if saved games are 20
          index = ListBoxGetSelected(SAVE,3);	// Get the selected save game
          SaveGameSlot(savegameindex[index],text);  // Overwrite the selected game
        }
      }
    }
    if (button == 4) {
      InterfaceOff(SAVE);			// if cancel is pressed close interface
      SetDefaultCursor();
    }
  }

  if (interface == LOAD) {
    if (button == 1) { 				// if cancel is pressed
      InterfaceOff(LOAD);		        // Close interface
      SetDefaultCursor();
    }
    else if (button == 3) {
      index = ListBoxGetSelected(LOAD,0);	// else get the selected game
      RestoreGameSlot(savegameindex[index]); 	// restore the game
    }
  }
}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE




Where would that if be  ?
Code: ags

Ashen

#4
On line 58 which, if I counted right, is in the rep_ex. Looking at it, you have the closing brace for the section, then the statusline code:

#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here
} // This brace is the problem, take it out.

if (GetCursorMode()==0) SetLabelText(0,0,"Walk to @OVERHOTSPOT@"); // this was line 58
Ã,  if (GetCursorMode()==1) SetLabelText(0,0,"Look at @OVERHOTSPOT@");
Ã,  if (GetCursorMode()==2) SetLabelText(0,0,"Interact with @OVERHOTSPOT@");
Ã,  if (GetCursorMode()==3) SetLabelText(0,0,"Talk to @OVERHOTSPOT@");
Ã,  if (GetCursorMode()==4) {
Ã,  Ã,  string usinginv;
Ã,  Ã,  string useinvtxt;
Ã,  Ã,  StrCopy (useinvtxt, "Use ");
Ã,  Ã,  GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);
Ã,  Ã,  StrCat (useinvtxt,usinginv);
Ã,  Ã,  StrCat (useinvtxt," with ");
Ã,  Ã,  StrCat (useinvtxt,"@OVERHOTSPOT@");
Ã,  Ã,  SetLabelText(0,0,useinvtxt);
}
#sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE

Try that and see.

Edited: Sorry, I didn't even check the ;'s, since that was mentioned in the other thread.
I know what you're thinking ... Don't think that.

Candle

Well it was missing the ; after all the ) but got that fix but I don't see it doing anything when I have it over a hotspot ? dod I have to add something to the gui I made for it ?
Name is GUI6  .

Ashen

Well, you'll need to have a label on the GUI, and update all the SetLabelText(0,0.....); lines, e.g.:

Code: ags

if (GetCursorMode()==0) SetLabelText(GUI6,0,"Walk to @OVERHOTSPOT@");
  if (GetCursorMode()==1) SetLabelText(GUI6,0,"Look at @OVERHOTSPOT@");
  if (GetCursorMode()==2) SetLabelText(GUI6,0,"Interact with @OVERHOTSPOT@");
  if (GetCursorMode()==3) SetLabelText(GUI6,0,"Talk to @OVERHOTSPOT@");
  if (GetCursorMode()==4) {
    string usinginv;
    string useinvtxt;
    StrCopy (useinvtxt, "Use ");
    GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);
    StrCat (useinvtxt,usinginv);
    StrCat (useinvtxt," with ");
    StrCat (useinvtxt,"@OVERHOTSPOT@");
    SetLabelText(GUI6,0,useinvtxt);

(Assuming the label is still object 0 on GUI6)
I know what you're thinking ... Don't think that.

Candle

#7
Well it is GUI6 but not sure what you mean  label 0  where would I find that . man hate working with these gui's .
got this error when I ran it and the game crashed right away .
---------------------------
Adventure Game Studio
---------------------------
An error has occured. Please contact the game author for support, as this
is likely to be a scripting error and not a bug in AGS.
(ACI version 2.63.780)

(Global script line 56)
Error: SetLabelTexT: invalid object number


Found what I had not done yet ..
To add text to a GUI, you add a label. Click the "Add label" button, then drag out a rectangle like you did when adding a button. You can change the text displayed in the label by editing the "Text" property. Notice that the text automatically wraps round to fit inside the rectangle you drew.
Works now . thank you for the help .


SMF spam blocked by CleanTalk