How do you create a Restore and Save Game Dialog

Started by Edwin Xie, Fri 08/10/2004 05:49:37

Previous topic - Next topic

Edwin Xie

The title explains it all and I know it has to do with "SaveGameSlot" and "RestoreGameSlot".... and I don't know about how to do the "Save" or "restore" buttons on the two.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Ishmael

Search the forums for BlueGUI, that's where I found it. If you don't come up with anything, seek for RickJ's signature, there's a link...
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.

Goot

If you haven't, read the manual section about making GUIs. I assume you want it displayed as a list, so you need a list box on your GUI. Use ListBoxSaveGameList or something like that (look it up in the manul) to make a list of saved games. Look up in the manual:

ListBoxGetItemSelected
character[].variables, find the var savegameindex[]

Use them to write your scripts for the buttons.

Edwin Xie

The BlueGUI is very confusing. I just found that out about the list box........
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Edwin Xie

#4

Ok, I try to do what 'BlueGUI' does but I get this error when importing a function in the script header:

---------------------------
Adventure Game Studio
---------------------------
Script link failed: Runtime error: unresolved import 'bgSave'

---------------------------
OKÃ,  Ã, 
---------------------------

The script header has the following:

//STATES FOR THE FUNCTION
#define OKÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 1
#define CANCELÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 0
#define LISTÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 134
#define DIALOGÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 100
// SAVE GAME DIALOG
#define bgSAVE_DLGÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 8
#define bgSAVE_LISTÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  2
#define bgSAVE_TEXTÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  3
#define bgSAVE_OKÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0
#define bgSAVE_CANCELÃ,  Ã,  Ã,  Ã,  Ã,  2

// RESTORE GAME DIALOG
#define bgRESTORE_DLGÃ,  Ã,  Ã,  Ã,  Ã,  9
#define bgRESTORE_LISTÃ,  Ã,  Ã,  Ã,  Ã, 2
#define bgRESTORE_OKÃ,  Ã,  Ã,  Ã,  Ã,  Ã, 0
#define bgRESTORE_CANCELÃ,  Ã,  Ã,  Ã, 1

import function bgSave(int state);
import function bgRestore(int state);

I think that I am missing something. What is the thing I'm missing?


New error when tryin to declare the function:

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



Error (line 137): Already referenced name as import



Do you want to fix the script now? (Your game has not been saved).
---------------------------
Yes   No   
---------------------------

Line 137:  function bgCursor(int state) {           // Setup cursor modes

I didn't declare it two times...what's wrong?
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Gilbert

Did you put an import function bgCursor(...); line in the global script? You shouldn't put that there.

Edwin Xie

No, it just started with function bgCursor(...);
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Gilbert

Can you post the whole global script here for us to check for the problem?

Edwin Xie

#8
// main global script file
//=========================================================================
// SAVE GAME DIALOG - The following functions implement the Save Game
// interface. The SAVE GAME dialog is normally activated via a user
// click on the ICON BAR.
//
// bgSave(state)
// This function opens the dialog box and performs the operations initiated
// by controls within the dialog box.
//
// state - This parameter determines the behavior of dialog as follows:
//Ã,  Ã,  DIALOGÃ,  - Open the Save dialog box
//Ã,  Ã,  CANCELÃ,  - Close dialog box without performing any operation
//Ã,  Ã,  OKÃ,  Ã,  Ã,  - Save the selected game slot
//Ã,  Ã,  LISTÃ,  Ã,  - Get user selection from listbox
//
//=========================================================================
Ã,  Ã, stringÃ,  bg_save_buf;Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // text buffer
Ã,  Ã, intÃ,  Ã,  Ã, bg_save_idx;Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // index
Ã,  Ã, intÃ,  Ã,  Ã, bg_save_slot;Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // save game id

function bgSave(int state) {
Ã,  Ã, // SAVE icon was pressed, open dialog
Ã,  Ã, if (state==DIALOG) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  bgCursor(6);
Ã,  Ã,  Ã,  GUIOn(bgSAVE_DLG);
Ã,  Ã,  Ã,  ListBoxSaveGameList(bgSAVE_DLG,bgSAVE_LIST); // Populate listbox with previous saves
Ã,  Ã,  Ã,  bg_save_idx = ListBoxGetNumItems(bgSAVE_DLG,bgSAVE_LIST);
Ã,  Ã,  Ã,  if (bg_save_idx <= 20) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Less than max saves
Ã,  Ã,  Ã,  Ã,  Ã, ListBoxAdd(bgSAVE_DLG,bgSAVE_LIST,"<new>");
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Max number of saves exceeded
Ã,  Ã,  Ã,  Ã,  Ã, bg_save_idx = 0;Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Setup overwrite of existing slot
Ã,  Ã,  Ã,  Ã,  Ã, ListBoxGetItemText(bgSAVE_DLG,bgSAVE_LIST,bg_save_idx,bg_save_buf);
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  ListBoxSetSelected(bgSAVE_DLG,bgSAVE_LIST,bg_save_idx);
Ã,  Ã,  Ã,  ListBoxGetItemText(bgSAVE_DLG,bgSAVE_LIST,bg_save_idx,bg_save_buf);
Ã,  Ã,  Ã,  if (StrComp(bg_save_buf,"<new>")==0) StrCopy(bg_save_buf,"");
Ã,  Ã,  Ã,  SetTextBoxText(bgSAVE_DLG,bgSAVE_TEXT,bg_save_buf); // Setup text entry box
Ã,  Ã, }

Ã,  Ã, // List element was clicked, copy selected item's text to the TextBox
Ã,  Ã, else if (state==LIST) {
Ã,  Ã,  Ã,  bg_save_idx = ListBoxGetSelected(bgSAVE_DLG,bgSAVE_LIST);
Ã,  Ã,  Ã,  ListBoxGetItemText(bgSAVE_DLG,bgSAVE_LIST,bg_save_idx,bg_save_buf);
Ã,  Ã,  Ã,  if (StrComp(bg_save_buf,"<new>")==0) StrCopy(bg_save_buf,"");
Ã,  Ã,  Ã,  SetTextBoxText(bgSAVE_DLG,bgSAVE_TEXT,bg_save_buf);
Ã,  Ã, }

Ã,  Ã, // SAVE button was pressed, save the game
Ã,  Ã, else if (state==OK) {
Ã,  Ã,  Ã,  SetRestartPoint();Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Restart here
Ã,  Ã,  Ã,  bg_save_idx=ListBoxGetSelected(bgSAVE_DLG,bgSAVE_LIST); // Save game in new save game slot
Ã,  Ã,  Ã,  ListBoxGetItemText(bgSAVE_DLG,bgSAVE_LIST,bg_save_idx,bg_save_buf);
Ã,  Ã,  Ã,  if (StrComp(bg_save_buf,"<new>")==0) {Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  Ã,  Ã, bg_save_slot = ListBoxGetNumItems(bgSAVE_DLG,bgSAVE_LIST);
Ã,  Ã,  Ã,  Ã,  Ã, GetTextBoxText(bgSAVE_DLG,bgSAVE_TEXT,bg_save_buf);Ã, 
Ã,  Ã,  Ã,  Ã,  Ã, if (StrComp(bg_save_buf,"")==0) StrFormat(bg_save_buf,"Game-%d",bg_save_slot);
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Over-write an existing save game
Ã,  Ã,  Ã,  Ã,  Ã, bg_save_slot=savegameindex[bg_save_idx]; // slot with name from textbox.
Ã,  Ã,  Ã,  Ã,  Ã, GetTextBoxText(bgSAVE_DLG,bgSAVE_TEXT,bg_save_buf);Ã, 
Ã,  Ã,  Ã,  Ã,  if (StrComp(bg_save_buf,"")==0) ListBoxGetItemText(bgSAVE_DLG,bgSAVE_LIST,bg_save_idx,bg_save_buf);
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  GUIOff(bgSAVE_DLG);Ã,  Ã,  Ã,  Ã,  Ã,  // Close dialog amd return
Ã,  Ã,  Ã,  SaveGameSlot(bg_save_slot, bg_save_buf); // Perform save operation last otherwise
Ã,  Ã,  Ã,  Display("Saved as: %s", bg_save_buf);Ã,  Ã,  // SAVE dialog will be active on restore
Ã,  Ã,  Ã,  bgCursor(0);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã, }

Ã,  Ã, // CANCEL button was pressed, cancel operation
Ã,  Ã, else if (state==CANCEL) {
Ã,  Ã,  Ã,  GUIOff(bgSAVE_DLG);Ã,  Ã,  Ã,  Ã,  Ã,  // Close dialog and return
Ã,  Ã,  Ã,  bgCursor(6);Ã, 
Ã,  Ã, }
}

//=========================================================================
// RESTORE GAME DIALOG - The following routines implement restore game
// interface. The RESTORE GAME dialog is normally activated via a user
// click on the ICON BAR.Ã, 
//
// bgRestore(state)
// This function opens the dialog box and performs the operations initiated
// by controls within the dialog box.
//
// state - This parameter determines the behavior of dialog as follows:
//Ã,  Ã,  DIALOGÃ,  - Open the Restore dialog box
//Ã,  Ã,  CANCELÃ,  - Close dialog box without performin any operation
//Ã,  Ã,  OKÃ,  Ã,  Ã,  - Restore the selected game slot
//Ã,  Ã,  LISTÃ,  Ã,  - Get user selection from listbox
//
//=========================================================================
Ã,  Ã, stringÃ,  bg_restore_buf;Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // text buffer
Ã,  Ã, intÃ,  Ã,  Ã, bg_restore_idx;Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // index

function bgRestore(int state) {
Ã,  Ã, // RESTORE icon was pressed, open dialog
Ã,  Ã, if (state==DIALOG) {
Ã,  Ã,  Ã,  bgCursor(6);Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  GUIOn(bgRESTORE_DLG);Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  ListBoxSaveGameList(bgRESTORE_DLG,bgRESTORE_LIST);
Ã,  Ã, }

Ã,  Ã, // CANCEL button was pressed, cancel operation
Ã,  Ã, else if (state==CANCEL) {
Ã,  Ã,  Ã,  GUIOff(bgRESTORE_DLG);Ã,  Ã,  Ã,  Ã, // Close dialog and return
Ã,  Ã,  Ã,  bgCursor(6);
Ã,  Ã, }

Ã,  Ã, // RESTORE button was pressed, restore the game
Ã,  Ã, else if (state==OK) {
Ã,  Ã,  Ã,  bg_restore_idx=ListBoxGetSelected(bgRESTORE_DLG,bgRESTORE_LIST); // Perform save operation
Ã,  Ã,  Ã,  if (bg_restore_idx==-1) {Ã,  Ã,  Ã,  Ã,  Ã,  // No selection, nothing to restore
Ã,  Ã,  Ã,  Ã,  Ã, Display("Please make a slection first...");
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  elseÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ok continue restoring game
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã, ListBoxGetItemText(bgRESTORE_DLG,bgRESTORE_LIST,bg_restore_idx,bg_restore_buf);
Ã,  Ã,  Ã,  Ã,  Ã, RestoreGameSlot(savegameindex[bg_restore_idx]);
Ã,  Ã,  Ã,  Ã,  Ã, Display("Restored from: %s",bg_restore_buf);
Ã,  Ã,  Ã,  Ã,  Ã, GUIOff(bgRESTORE_DLG);Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  Ã,  Ã, bgCursor(6);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  }
Ã,  Ã, }

Ã,  Ã, // LIST box was clicked
Ã,  Ã, else if (state==LIST) {
Ã,  Ã,  Ã,  // nothing to do
Ã,  Ã, }
}
//=========================================================================
Ã,  Ã, int bg_cursor_type;
Ã,  Ã, int bg_cursor_id;
Ã,  Ã, int bg_cursor_delay;

function bgCursor(int state) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Setup cursor modes
Ã,  Ã, if (state==1) {
Ã,  Ã,  Ã,  SetCursorMode(1);
Ã,  Ã, }
Ã,  Ã, else if (state==3) {
Ã,  Ã,  Ã,  SetCursorMode(3);
Ã,  Ã, }
Ã,  Ã, else if (state==4) {
Ã,  Ã,  Ã,  SetCursorMode(4);
Ã,  Ã, }
Ã,  Ã, else if (state==2) {
Ã,  Ã,  Ã,  SetCursorMode(2);
Ã,  Ã, }
Ã,  Ã, else if (state==6) {
Ã,  Ã,  Ã,  SetMouseCursor(6);
Ã,  Ã, }
Ã,  Ã, else if (state==0) {
Ã,  Ã,  Ã,  SetDefaultCursor();
Ã,  Ã, }
Ã,  Ã, else if (state==7) {
Ã,  Ã,  Ã,  SetCursorMode(7);
Ã,  Ã, }
}

#sectionstart game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
Ã,  // called when the game starts, before the first room is loaded
Ã,  GiveScore(100);
Ã,  SetGlobalInt(24,0);
Ã,  InterfaceOff(6);
}
#sectionend game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
// LEC Statusline

Ã,  Ã,  string bunky;
Ã,  Ã,  string texty;
Ã,  Ã,  int cursy;

Ã,  Ã,  StrCopy (texty, "");
Ã,  Ã,  cursy=GetCursorMode();

Ã,  Ã,  if (cursy==0) StrCat(texty,"Walk to ");
Ã,  Ã,  else if (cursy==1) StrCat (texty,"Look at ");
Ã,  Ã,  else if (cursy==2) StrCat(texty,"Use ");
Ã,  Ã,  else if (cursy==3) StrCat(texty,"Talk to ");
Ã,  Ã,  else if (cursy==4) {
Ã,  Ã,  Ã,  Ã,  StrCat(texty,"Use ");
Ã,  Ã,  Ã,  Ã,  GetInvName (player.activeinv, bunky);
Ã,  Ã,  Ã,  Ã,  StrCat(texty,bunky);
Ã,  Ã,  Ã,  Ã,  StrCat(texty," with ");
Ã,  Ã,  }
Ã,  Ã,  else if (cursy==5) StrCat(texty, "Pick up ");
Ã,  Ã,  else if (cursy==8) StrCat(texty, "Open ");

Ã,  Ã,  GetLocationName(mouse.x,mouse.y,bunky);
Ã,  Ã,  StrCat(texty,bunky);
Ã,  Ã,  SetLabelText (0,0,texty);

Ã,  Ã,  if (IsGUIOn(1) || IsGUIOn(3) || IsGUIOn(4) || IsGUIOn(8) || IsGUIOn(9)) {
Ã,  Ã,  Ã,  Ã,  SetMouseCursor(6);
Ã,  Ã,  Ã,  Ã,  SetLabelText(0,0, " ");
Ã,  Ã,  }
Ã,  if (game.score == 0){
Ã,  Ã,  Display("Sorry, you died. Don't worry, you played well, you just got killed. Sigh, well, try again.");
Ã,  Ã,  RestartGame();
Ã,  Ã,  }
}
#sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE


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
Ã,  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);
}

#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
Ã,  int bg_save_idx;
Ã,  string bg_save_buf;
Ã,  if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  else if (keycode==17)Ã,  GUIOn(4);Ã,  Ã, // Ctrl-Q
Ã,  else if (keycode==363) bgSave(DIALOG);Ã,  Ã, // F5
Ã,  else if (keycode==365) bgRestore(DIALOG);Ã,  // F7
Ã,  else if (keycode==367) RestartGame();Ã,  // F9
Ã,  else if (keycode==434) SaveScreenShot("scrnshot.bmp");Ã,  // F12
Ã,  else if (keycode==9)Ã,  Ã, show_inventory_window();Ã,  // Tab, show inventory

Ã,  else if (keycode==19 && GetGlobalInt(24)==1){
Ã,  Ã,  Debug(0,0);Ã,  // Ctrl-S, give all inventory if GetGlobalInt(24)==1
Ã,  Ã,  }
Ã,  else if (keycode==22 && GetGlobalInt(24)==1){
Ã,  Ã,  Debug(1,0);Ã,  // Ctrl-V, version if GetGlobalInt(24)==1
Ã,  Ã,  }
Ã,  else if (keycode==1 && GetGlobalInt(24)==1){
Ã,  Ã,  Debug(2,0);Ã,  // Ctrl-A, show walkable areas if GetGlobalInt(24)==1
Ã,  Ã,  }
Ã,  else if (keycode==24 && GetGlobalInt(24)==1){
Ã,  Ã,  Debug(3,0);Ã,  // Ctrl-X, teleport to room if GetGlobalInt(24)==1
Ã,  Ã,  }
}
#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 {Ã,  Ã, // right-click, so cycle cursor
Ã,  Ã,  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)Ã,  Ã,  // game controls
Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  InterfaceOff(1);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  SetCursorMode(6);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  InterfaceOn(3);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (button == 6)Ã,  Ã,  // save game
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  GUIOn(SAVE);
Ã,  Ã,  Ã,  Ã,  else if (button == 7)Ã,  Ã, // load game
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  GUIOn(LOAD);
Ã,  Ã,  Ã,  Ã,  else if (button == 8)Ã,  Ã, // quit
Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  GUIOn(4);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (button == 9)Ã,  Ã,  // about
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 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);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã, 
Ã,  Ã,  Ã,  Ã,  else if (button == 2) {
Ã,  Ã,  Ã,  Ã,  // They pressed LOOK, so switch to that mode
Ã,  Ã,  Ã,  Ã,  SetActiveInventory(-1);
Ã,  Ã,  Ã,  Ã,  SetCursorMode(MODE_LOOK);Ã, 
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (button == 3) {
Ã,  Ã,  Ã,  Ã,  // They pressed the OK button, close the GUI
Ã,  Ã,  Ã,  Ã,  GUIOff (INVENTORY);
Ã,  Ã,  Ã,  Ã,  SetDefaultCursor();
Ã,  Ã,  Ã,  Ã,  }

Ã,  Ã,  Ã,  Ã,  else 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;
Ã,  Ã,  Ã,  Ã,  }

Ã,  Ã,  Ã,  Ã,  else if ((button == 5) && (game.top_inv_item > 0))
Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // scroll up
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  game.top_inv_item = game.top_inv_item - game.items_per_line;
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (button == 6) {Ã,  Ã, // use selected inventory
Ã,  Ã,  Ã,  Ã,  Ã,  if (character[ GetPlayerCharacter() ].activeinv >= -1)
Ã,  Ã,  Ã,  Ã,  SetCursorMode(4);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }



Ã,  Ã,  CentreGUI(3);

Ã,  Ã,  if (interface == 3){
Ã,  Ã,  Ã,  if (button ==Ã,  8) SetGameSpeed(GetSliderValue(3,8));
Ã,  Ã,  Ã,  else if (button ==Ã,  9) SetMusicMasterVolume(GetSliderValue(3,9));
Ã,  Ã,  Ã,  else if (button == 10) game.text_speed = GetSliderValue(3,10);
Ã,  Ã,  Ã,  else if (button ==Ã,  0) GUIOn(9);
Ã,  Ã,  Ã,  else if (button ==Ã,  1) GUIOn(8);
Ã,  Ã,  Ã,  else if (button ==Ã,  2) GUIOn(4);
Ã,  Ã,  Ã,  else if (button ==Ã,  3){
Ã,  Ã,  Ã,  Ã,  SetCursorMode(6);
Ã,  Ã,  Ã,  Ã,  RestartGame();
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (button == 4 && GetGlobalInt(24) == 1){
Ã,  Ã,  Ã,  Ã,  Ã,  SetGlobalInt(24,0);
Ã,  Ã,  Ã,  Ã,  Ã,  Display("Debug mode has been turned off.");
Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  Ã,  else if (button == 4 && GetGlobalInt(24) == 0){ // If debug mode has already been turned off
Ã,  Ã,  Ã,  Ã,  Ã,  Display("Hey, debug mode has already been turned off!");
Ã,  Ã,  Ã,  Ã,  Ã,  Display("Unless this was an excuse to act like you got the password right for the thing there....");
Ã,  Ã,  Ã,  Ã,  Ã,  }

Ã,  Ã,  Ã,  Ã,  else if (button == 11){
Ã,  Ã,  Ã,  Ã,  Ã,  InterfaceOff (3);
Ã,  Ã,  Ã,  Ã,  Ã,  InterfaceOn (ICONBAR);
Ã,  Ã,  Ã,  Ã,  Ã,  SetCursorMode (1);
Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  }



Ã,  Ã,  if (interface == 4)
Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã, if (button == 0)Ã,  QuitGame(0);
Ã,  Ã,  Ã,  Ã, else if (button == 1) {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GUIOff(4);
Ã,  Ã,  Ã,  Ã,  if (character[BOB].room == 100){
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SetCursorMode(6);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, }
Ã,  Ã,  Ã,  Ã,  Ã, else { //If the player isn't in room 100, set the cursor mode to MODE_WALK
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SetCursorMode(MODE_WALK);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, }
Ã,  Ã,  Ã,  Ã, }

Ã,  Ã,  }
Ã,  Ã,  if (interface == 6) {Ã,  Ã,  //starts parsing, including any global commands
Ã,  Ã,  Ã,  if (button == 2){
Ã,  Ã,  Ã,  string forparser;
Ã,  Ã,  Ã,  StrCopy(forparser,"");
Ã,  Ã,  Ã,  GetTextBoxText(6,2,forparser);
Ã,  Ã,  Ã,  InterfaceOff(6);
Ã,  Ã,  Ã,  if (StrComp(forparser,"")){
Ã,  Ã,  Ã,  Ã,  ParseText(forparser);
Ã,  Ã,  Ã,  Ã, // These are things that should happen in any room
Ã,  Ã,  Ã,  if (Said("xxxxxxxxx")){ //No lookie at my password!
Ã,  Ã,  Ã,  Ã,  Display ("Yes, that is the correct password!");
Ã,  Ã,  Ã,  Ã,  SetGlobalInt(24,1);
Ã,  Ã,  Ã,  Ã,  Display ("Debug options are now on!");
Ã,  Ã,  Ã,  Ã,  Display ("Reference: [[ Ctrl+S : Give all inventory [[ Ctrl+V : Version [[ Ctrl+A : Shows walkable areas [[ Ctrl+X : Teleports to room X");
Ã,  Ã,  Ã,  Ã,  InterfaceOff(6);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else { //If the word isn't the password do this
Ã,  Ã,  Ã,  Ã,  Display ("Sorry, this isn't the password. Please try again, or you can just stop trying to cheat.");
Ã,  Ã,  Ã,  Ã,  InterfaceOn(6);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  Ã,  Ã,  if (button == 3){
Ã,  Ã,  Ã,  Ã,  Display("That's ok, you didn't have to type in the password.");
Ã,  Ã,  Ã,  Ã,  InterfaceOff(6);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  } // previous interface
Ã,  Ã,  Ã,  CentreGUI(8);
Ã,  Ã,  Ã,  CentreGUI(9);
Ã,  Ã,  Ã,  // SAVE DIALOG
Ã,  Ã,  if (interface==bgSAVE_DLG) {Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  if (button==bgSAVE_LIST) bgSave(LIST);Ã,  Ã, 
Ã,  Ã,  Ã,  else if (button==bgSAVE_TEXT) bgSave(OK);
Ã,  Ã,  Ã,  else if (button==bgSAVE_OK) bgSave(OK);
Ã,  Ã,  Ã,  else if (button==bgSAVE_CANCEL) bgSave(CANCEL);Ã,  Ã, 
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  // RESTORE DIALOG
Ã,  Ã,  if (interface==bgRESTORE_DLG) {Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  if (button==bgRESTORE_LIST) bgRestore(LIST);
Ã,  Ã,  Ã,  else if (button==bgRESTORE_OK) bgRestore(OK);
Ã,  Ã,  Ã,  else if (button==bgRESTORE_CANCEL) bgRestore(CANCEL);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
#sectionend interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory4_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function inventory4_a() {
Ã,  // script for inventory4: Interact inventory item
game.score = 0;
}
#sectionend inventory4_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory4_bÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function inventory4_b() {
Ã,  // script for inventory4: Talk to inventory item
game.score = 0;
}
#sectionend inventory4_bÃ,  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart character0_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function character0_a() {
Ã,  // script for character0: Use inventory on character
game.score = 0;Ã, 
}
#sectionend character0_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Gilbert

Ah, the problem is obvious now, just move the declaration part of bgCursor() up in the script.

Teh reason was that you called bgCursor() several times in your script BEFORE declaring the function, as forward reference is not allowed yet in AGS, it'll cause an error. So you just need to move its declaration up in the script so it's before all of its usage.

Edwin Xie

New problem:

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



Error (line 232): Variable 'bg_save_idx' is already defined



Do you want to fix the script now? (Your game has not been saved).
---------------------------
Yes   No   
---------------------------
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Goot

What's line 232. You have probably declared the int twice, or you have a function with the same name as a integer.

Edwin Xie

#12
You should have known from the previous topic I had. Furthermore, I did not declare the integer twice. Ah, I see, there was no reason:

  int bg_save_idx;
  string bg_save_buf;

should be in on_key_press. Thanks for all your help though.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Gilbert

Indeed you'd declared that at least twice, I can find at least one near the top of the script and one inside on_key_pressed(), I was too lazy to check further, but the search function for teh script editor is always your friend.


Edwin Xie

AHH!!!! Now I get this problem when I am trying to save.  :( :
---------------------------
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.61.747)

(Global script line 82)
Error: ListBoxGetItemText: invalid item specified

---------------------------
OK   
---------------------------

In case anyone gets confused, global script line 82 is:
ListBoxGetItemText(bgSAVE_DLG,bgSAVE_LIST,bg_save_idx,bg_save_buf);

and here is the script header script (again):

//STATES FOR THE FUNCTION
#define OK                         1
#define CANCEL                 0
#define LIST                   134
#define DIALOG              100
// SAVE GAME DIALOG
#define bgSAVE_DLG          8
#define bgSAVE_LIST          2
#define bgSAVE_TEXT         3
#define bgSAVE_OK            0
#define bgSAVE_CANCEL    2

// RESTORE GAME DIALOG
#define bgRESTORE_DLG       9
#define bgRESTORE_LIST       2
#define bgRESTORE_OK          0
#define bgRESTORE_CANCEL  1

import function bgSave(int state);
import function bgRestore(int state);
import function bgCursor(int state);
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Edwin Xie

bump

Seriously, no one knows the answer to this problem?
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Gilbert

#16
No need to bump this, as it's just less than an hour, and your thread's still on the first page. This is a forum, not a chatroom, so you may need to wait (especially when I need to go for lunch ;)).

Your error is a runtime error right ? (ie when testing the game, not when compiling or saving your game).
That error indicates that bg_save_idx most likely refering to an item which does not exist. You may need to check further on your codes.

Something to note, that indices like bg_save_idx are usually something retrieved by using teh functions ListBoxGetSelected() or ListBoxGetNumItems(), in either case, there's something you need to be aware of:

1) If no item is selected on teh list, ListBoxGetSelected() returns -1, which is not a valid item number, and can cause problem if you want to retrieve the text of slot -1 (which doesn't exists), you you may need to use if.... to take care of this situation.
2) The valid number for list index is:
from 0 to (num_of_items - 1)
So say, if you use ListBoxGetNumItems() and it returns 15 for a list box, that means the valid indices are:
from 0 to 14
if you try to retrieve the text from slot 15 (which doesn't exist) teh game will crash.

So you may need to invest on your codes. (I'm just too lazy to read long stuffs).

Edwin Xie

Yeah, this is a runtime error....... but the wierd thing is, that in other games, it works........but in this one it displays the error everytime I try to save a game (within the game a.k.a. a runtime error). But then there is no item preset on the list....but, in the regular save game dialog, you can still save even though there is no preset item on the list.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Gilbert

#18
The regular save interface is internal to the engine, it's different, you have to take care of possible problems yourself if you have to design your own GUI.

Can you post around line #82 of your codes (preferrably showing the part on how you set bg_save_idx for use later) so we can invest on the problem ?
(As looking at your originally posted codes I can't say which part corresponds to that line 82 portion in problem).

Ishmael

I copied the save and restore functions, their #define's and Global Script declared variables to my game, and it worked fine... have you done any changes to the functions? Any at all?
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.

SMF spam blocked by CleanTalk