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.
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...
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.
The BlueGUI is very confusing. I just found that out about the list box........
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?
Did you put an import function bgCursor(...); line in the global script? You shouldn't put that there.
No, it just started with function bgCursor(...);
Can you post the whole global script here for us to check for the problem?
// 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
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.
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
---------------------------
What's line 232. You have probably declared the int twice, or you have a function with the same name as a integer.
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.
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.
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);
bump
Seriously, no one knows the answer to this problem?
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).
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.
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).
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?
If it works fine for you.........there is a bad script in the global script.......I will need someone else to read the whole script for any error because I couldn't find any errors.
Bump
Try delete all saved games from your game\compiled\ folder and see if it helps.
If it still doesn't work then I can invite you to try the following save/load dialog:
http://www.geocities.com/scorpiorus82/saveloadgui_v1_1.zip (copy and paste) [edit: replaced with v1.1]
Feel free to ask, if you have any questions regarding its functionality.
What do I have to do if I wanted the save and load slots to be 100 (or 99) rather than 20? And what if I wanted to have both of them be separate GUIs?
uhh, bump?
edwin, JEEZ! you've been here long enough to understand the rules. no bumping a thread unless its falling off the first page. we all live in different time zones, plus we dont all hang out here 24 hours a day. we have lives too.
you have to set up your array to handle the amount of save slots you want. you can't edit the already made save/load system.
QuoteWhat do I have to do if I wanted the save and load slots to be 100 (or 99) rather than 20?
Yeah, as Scummbuddy pointed out, you then have to script the whole thing and have an array to store the correct order of slots. Otherwise, it wouldn't know which slot must be listed first, which - second, etc. AGS handles this with savegameindex[20] array which has a limit of 20 slots.
QuoteAnd what if I wanted to have both of them be separate GUIs?
The script can easily be adjusted to handle different GUIs for save and load as well.
Here is another version of the script:
Save/load script (version 1.1):http://www.geocities.com/scorpiorus82/saveloadgui_v1_1.zip [18kb] (
Copy & paste)
Now, is savegameindex[20] hardcoded? And which codes in your script are unnecessary for separate GUIs?
Quote from: Edwin Xie on Tue 19/10/2004 06:19:58Now, is savegameindex[20] hardcoded?
Yes, kind of. But it is the array that is used by AGS to inform us about the correct order of save slots, i.e. when you display save slots on a listbox with ListBoxSaveGameList they are arranged starting from the most recent one.
I'll think about the implementation with a custom savegameindex-like array so that a twenty slots limit can be increased.
QuoteAnd which codes in your script are unnecessary for separate GUIs?
The whole script is essential as it implemets basic functionality such as save, load and delete. In fact, to add separate GUIs for save and load I just wrote two extra simple functions:
function OpenSaveDialog() {
//=---------------------------------------------------------------------=
//Ã, Opens the *save* dialog:
//=---------------------------------------------------------------------=
Ã, Ã, //Ã, Setting up the GUI (pass -1 if the GUI object is unused!):
Ã, Ã, //Ã, ------------------------GUI---tbox--lbox--save--load--del--cancel
Ã, Ã, PrepareSaveLoadDialog(Ã, Ã, GUISAVE,Ã, 0,Ã, Ã, 1,Ã, Ã, 2,Ã, Ã, -1,Ã, Ã, 3,Ã, Ã, 4Ã, );
Ã, Ã,Â
Ã, Ã, //Ã, Open GUI:
Ã, Ã, OpenDialogGUI();
}
function OpenLoadDialog() {
//=---------------------------------------------------------------------=
//Ã, Opens the *load* dialog:
//=---------------------------------------------------------------------=
Ã, Ã, //Ã, Setting up the GUI (pass -1 if the GUI object is unused!):
Ã, Ã, //Ã, ------------------------GUI---tbox--lbox--save--load--del--cancel
Ã, Ã, PrepareSaveLoadDialog(Ã, Ã, GUILOAD, -1,Ã, Ã, 0,Ã, Ã, -1,Ã, Ã, 1,Ã, -1,Ã, Ã, 2Ã, );
Ã, Ã,Â
Ã, Ã, //Ã, Open GUI:
Ã, Ã, OpenDialogGUI();
}
savegameindex[20] isn't writen bold. So it cna be changed, right? I never had the nerve to do it.
Yep, it is possible to write into savegameindex but the issue here is that this array is, instead, used as an output parameter to provide us with the necessary information about the arrangement of save slots.
The problem is, that I think PrepareSaveLoadDialog does nothing, is that the case?
On the contrary, it initializes the dialog by setting GUI and GUI objects numbers. It is important to tell the script what dialog (save or load) we want to appear.
I do not mean that, I meant, that there isn't really a script I can find that can save or load, it's pretty complicated to find a script that does not refer to the Save/Load GUI.....maybe I can create a Save/Load GUI but block that one from any access.
download this and check it all out:
http://bluegui.netfirms.com/
Uh, I downloaded that but there was this listbox error.
Quote from: Edwin Xie on Thu 21/10/2004 05:27:13I do not mean that, I meant, that there isn't really a script I can find that can save or load, it's pretty complicated to find a script that does not refer to the Save/Load GUI.....maybe I can create a Save/Load GUI but block that one from any access.
So, do you just want to save/load without a dialog? You can then use SaveGameSlot and RestoreGameSlot, for example:
SaveGameSlot (100, "autosave"); // save a game to slot 100;
RestoreGameSlot (100); // restore a game from slot 100;
I just want a script for separate save and load GUIs.
The script I posted a link to has OpenSaveDialog() to open a save GUI and OpenLoadDialog() to open a load GUI. You don't have to use the GUISAVELOAD gui - you can delete this GUI as well as the OpenSaveLoadDialog() function from the global script. The SAVE and LOAD GUIs do use the same function to operate but that's more practical since their functionality is rather similar. For instance, both have a listbox to list existent slots, a cancel button and may optionally share the delete button as well.
The only problem I am having is that clicking any button will do nothing.
Generally that means that you haven't scripted anything for that button... Check to make sure that the button you are clicking is the button# you used in interface_click(int button)... And try posting the script as well...
// main global script file
#define SAVELOAD_SLOTS_MAX 20 Ã, // Ã, the max number of saved slots (*must* be 20 or less!);
// Slot name if user doesn't specify one:
#define SLD_DESCRIPTION_DEFAULT "Unnamed slot"
// Default warning messages:
#define SLD_MESSAGE_TooManyGameSlots Ã, Ã, Ã, "There are too many game slots. Please, choose an already existing item to overwrite!"
#define SLD_MESSAGE_NoItemSelectedToLoad Ã, "Please, choose an item to load!"
#define SLD_MESSAGE_NoItemSelectedToDelete "Please, choose a slot to delete!"
//--------
// Flags:
//--------
// Close the dialog GUI after saving the game (1 - yes, 0 - no):
int sld_bCloseGUIAfterSave = 0;
// Save the game on 'Enter' pressed:
int sld_bDoSaveOnEnterPressed = 1;
// Save/Load dialog GUI:
int sldGUI = -1; Ã, Ã, Ã, Ã, Ã, // Ã, saveload dialog GUI (-1 until opened);
// Save/Load dialog GUI objects:
int sldTextbox Ã, Ã, Ã, = -1; Ã, // Ã, saveload textbox GUI object number;
int sldListbox Ã, Ã, Ã, = -1; Ã, // Ã, saveload listbox GUI object number;
int sldSaveButton Ã, = -1; Ã, // Ã, saveload save Ã, button GUI object number;
int sldLoadButton Ã, = -1; Ã, // Ã, saveload load Ã, button GUI object number;
int sldDeleteButton = -1; Ã, // Ã, saveload delete button GUI object number;
int sldCancelButton = -1; Ã, // Ã, saveload cancel button GUI object number;
//-----------------------
// Functions:
//-----------------------
function PrepareSaveLoadDialog(
Ã, int GUI,
Ã, int textbox,
Ã, int listbox,
Ã, int saveButton,
Ã, int loadButton,
Ã, int deleteButton,
Ã, int cancelButton) {
//=---------------------------------------------------------------------=
// Ã, Prepares a save/load dialog GUI (setting necessary GUI objects),
//=---------------------------------------------------------------------=
Ã, Ã, // Ã, if GUI wasn't specified:
Ã, Ã, if (GUI == -1)
Ã, Ã, {
Ã, Ã, Ã, Ã, // Ã, display error message and abort the game:
Ã, Ã, Ã, Ã, Display("Error: Save/Load dialog GUI hasn't been set up!");
Ã, Ã, Ã, Ã, QuitGame(0);
Ã, Ã, }
Ã, Ã, sldGUI = GUI; Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, set saveload GUI;
Ã, Ã, sldTextbox Ã, Ã, Ã, = textbox; Ã, Ã, Ã, // Ã, set saveload textbox GUI object number;
Ã, Ã, sldListbox Ã, Ã, Ã, = listbox; Ã, Ã, Ã, // Ã, set saveload listbox GUI object number;
Ã, Ã, sldSaveButton Ã, = saveButton; Ã, Ã, // Ã, set saveload save Ã, button GUI object number;
Ã, Ã, sldLoadButton Ã, = loadButton; Ã, Ã, // Ã, set saveload load Ã, button GUI object number;
Ã, Ã, sldDeleteButton = deleteButton; Ã, // Ã, set saveload delete button GUI object number;
Ã, Ã, sldCancelButton = cancelButton; Ã, // Ã, set saveload cancel button GUI object number;
}
Ã,Â
function on_event_SaveLoadDialogGUI(int event, int data) {
//=---------------------------------------------------------------------=
// Ã, Processes events catched through the on_event function.
// Ã, Note: it must be called from within the on_event function!
//=---------------------------------------------------------------------=
Ã, Ã, // We have to catch a click over a textbox here as
Ã, Ã, // the interface_click function isn't triggered
Ã, Ã, // if such an event happens!
Ã, Ã, // Ã, if there is click over a textbox:
Ã, Ã, if (event == GUI_MDOWN)
Ã, Ã, {
Ã, Ã, Ã, Ã, if (data == sldGUI)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, if (GetGUIObjectAt(mouse.x ,mouse.y) == sldTextbox)
Ã, Ã, Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, remove listbox highlight (textbox has a focus now!):
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, ListBoxSetSelected(sldGUI, sldListbox, -1);
Ã, Ã, Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, }
Ã, Ã, }
}
function UpdateSaveLoadDialogGUI() {
//=---------------------------------------------------------------------=
// Ã, Updates the saveload dialog GUI to reflect the changes being made
// Ã, and returns the total number of saved slots.
//=---------------------------------------------------------------------=
Ã, Ã, // Ã, store an old value (to restore it later): Ã,Â
Ã, Ã, int selectedItem = ListBoxGetSelected(sldGUI, sldListbox);
Ã, Ã,Â
Ã, Ã, // Ã, update the savegame list (seleted item is reset here ot 0!):
Ã, Ã, ListBoxSaveGameList(sldGUI, sldListbox);
Ã, Ã,Â
Ã, Ã, // Ã, get the number of slots (it's == number of the items in a listbox):
Ã, Ã, int totalSlots = ListBoxGetNumItems(sldGUI, sldListbox);
Ã, Ã,Â
Ã, Ã, // Ã, if we have exceeded the limits display a warning message:
Ã, Ã, //if (totalSlots > SAVELOAD_SLOTS_MAX) Display("too many slots!");
Ã, Ã,Â
Ã, Ã, // restore an old value (stored in selectedItem);
Ã, Ã, ListBoxSetSelected(sldGUI, sldListbox, selectedItem);
Ã,Â
Ã, Ã, // Ã, return the number of saved slots:
Ã, Ã, return totalSlots;
}
function OpenDialogGUI() {
//=---------------------------------------------------------------------=
// Ã, Initializes and then finally opens the save/load dialog:
//=---------------------------------------------------------------------=
Ã, Ã, CentreGUI(sldGUI); Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, centre the save/load GUI;
Ã, Ã, GUIOn(sldGUI); Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, turn the related GUI on;
Ã, Ã, UpdateSaveLoadDialogGUI(); Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, refresh GUI's content (show saved games);
Ã, Ã, ListBoxSetSelected(sldGUI, sldListbox, -1); Ã, Ã, Ã, // Ã, remove the highlight:
Ã, Ã,Â
Ã, Ã, // Ã, if the textbox is specified:
Ã, Ã, if (sldTextbox != -1)
Ã, Ã, {
Ã, Ã, Ã, Ã, SetTextBoxText(sldGUI, sldTextbox, ""); Ã, Ã, Ã, // Ã, clear textbox;
Ã, Ã, }
Ã, Ã,Â
Ã, Ã, Wait(1); Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, update the screen to show the GUI;
Ã, Ã, SetMouseCursor(6); Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, override cursor to look like an arrow;
}
function CloseSaveLoadDialog() {
//=---------------------------------------------------------------------=
// Ã, Closes the save/load dialog:
//=---------------------------------------------------------------------=
Ã,Â
Ã, Ã, SetDefaultCursor(); Ã, Ã, Ã, Ã, // Ã, restore cursor appearence;
Ã, Ã, GUIOff(sldGUI); Ã, Ã, Ã, Ã, Ã, Ã, // Ã, turn the related GUI off;
Ã, Ã, sldGUI = -1; Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, free save/load dialog GUI;
}
function interface_click_SaveLoadDialogGUI(int button) {
//=---------------------------------------------------------------------=
// Ã, Processes clicks on a save/load dialog GUI.
// Ã, Note: it must be called from within the interface_click function!
//=---------------------------------------------------------------------=
//-------------------------------------------------------------------
Ã, Ã, // if click on a *listbox item*:
Ã, Ã, if Ã, Ã, Ã, (button == sldListbox)
Ã, Ã, {
Ã, Ã, // Ã, Show currently selected saved slot's description in a textbox:
Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, give us a temp buffer to transfer string:
Ã, Ã, Ã, Ã, string buffer;
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, get selected item:
Ã, Ã, Ã, Ã, int selectedItem = ListBoxGetSelected(sldGUI, button);
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, copy saved game description into 'buffer':
Ã, Ã, Ã, Ã, ListBoxGetItemText(sldGUI, button, selectedItem, buffer);
Ã, Ã, Ã, Ã, // Ã, and finally, if the textbox exists:
Ã, Ã, Ã, Ã, if (sldTextbox != -1)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, fill the textbox with what is stored in 'buffer':
Ã, Ã, Ã, Ã, Ã, Ã, SetTextBoxText(sldGUI, sldTextbox, buffer);
Ã, Ã, Ã, Ã, }
Ã, Ã, }
//-------------------------------------------------------------------
Ã, Ã, // if click on a *save button* or *enter key* is pressed:
Ã, Ã, else if ( (button == sldSaveButton) || ((button == sldTextbox) && (sld_bDoSaveOnEnterPressed == 1)) )
Ã, Ã, {
Ã, Ã, // Save a game to slot:
Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, get total the number of slots:
Ã, Ã, Ã, Ã, int totalSlots = UpdateSaveLoadDialogGUI();
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, get selected item:
Ã, Ã, Ã, Ã, int selectedItem = ListBoxGetSelected(sldGUI, sldListbox);
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, allocate string to transfer slot description:
Ã, Ã, Ã, Ã, string strDescription;
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, fill 'strDescription' with the message in a listbox:
Ã, Ã, Ã, Ã, GetTextBoxText(sldGUI, sldTextbox, strDescription);
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, if there is no text description then set default SLD_DESCRIPTION_DEFAULT:
Ã, Ã, Ã, Ã, if (StrLen(strDescription) == 0) StrCopy(strDescription, SLD_DESCRIPTION_DEFAULT);
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, if it's not out of bounds...
Ã, Ã, Ã, Ã, if ( ( selectedItem >= 0 ) && ( selectedItem < SAVELOAD_SLOTS_MAX ) )
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, overwrite save game slot (with a GUI temporarily disabled):
Ã, Ã, Ã, Ã, Ã, Ã, GUIOff(sldGUI);
Ã, Ã, Ã, Ã, Ã, Ã, SetDefaultCursor();
Ã, Ã, Ã, Ã, Ã, Ã, SaveGameSlot(savegameindex[selectedItem], strDescription);
Ã, Ã, Ã, Ã, Ã, Ã, SetMouseCursor(6);
Ã, Ã, Ã, Ã, Ã, Ã, GUIOn(sldGUI);
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, // Ã, if there is no slot selected...
Ã, Ã, Ã, Ã, else if ( (selectedItem == -1) && (totalSlots < SAVELOAD_SLOTS_MAX) )
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, save to a new slot (with a GUI temporarily disabled):
Ã, Ã, Ã, Ã, Ã, Ã, GUIOff(sldGUI);
Ã, Ã, Ã, Ã, Ã, Ã, SetDefaultCursor();
Ã, Ã, Ã, Ã, Ã, Ã, SaveGameSlot(totalSlots + 1, strDescription);
Ã, Ã, Ã, Ã, Ã, Ã, SetMouseCursor(6);
Ã, Ã, Ã, Ã, Ã, Ã, GUIOn(sldGUI);
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, else
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, display a warning message (slots limit was exceeded):
Ã, Ã, Ã, Ã, Ã, Ã, Display(SLD_MESSAGE_TooManyGameSlots);
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, update the save/load GUI
Ã, Ã, Ã, Ã, UpdateSaveLoadDialogGUI();
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, remove the highlight:
Ã, Ã, Ã, Ã, ListBoxSetSelected(sldGUI, sldListbox, -1);
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, clear a textbox;
Ã, Ã, Ã, Ã, SetTextBoxText(sldGUI, sldTextbox, "");
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, if the sld_bCloseGUIAfterSave flag is true then close the GUI:
Ã, Ã, Ã, Ã, if (sld_bCloseGUIAfterSave == 1)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, CloseSaveLoadDialog(); // close the save/load GUI;
Ã, Ã, Ã, Ã, }
Ã, Ã, }
//-------------------------------------------------------------------
Ã, Ã, // if click on a *load button*:
Ã, Ã, else if (button == sldLoadButton)
Ã, Ã, {
Ã, Ã, // Try to delete a saved slot:
Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, get selected item:
Ã, Ã, Ã, Ã, int selectedItem = ListBoxGetSelected(sldGUI, sldListbox);
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, if it's not out of bounds...
Ã, Ã, Ã, Ã, if ( ( selectedItem >= 0 ) && ( selectedItem < SAVELOAD_SLOTS_MAX ) )
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, restore game from the slot:
Ã, Ã, Ã, Ã, Ã, Ã, RestoreGameSlot(savegameindex[selectedItem]);
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, else // Ã, otherwise...
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, display a message (as slot isn't selected):
Ã, Ã, Ã, Ã, Ã, Ã, Display(SLD_MESSAGE_NoItemSelectedToLoad);
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, update the save/load GUI
Ã, Ã, Ã, Ã, UpdateSaveLoadDialogGUI();
Ã, Ã, }
//-------------------------------------------------------------------
Ã, Ã, // if click on a *delete button*:
Ã, Ã, else if (button == sldDeleteButton)
Ã, Ã, {
Ã, Ã, // Try to delete a saved slot:
Ã, Ã, Ã, Ã, // Ã, get selected item:
Ã, Ã, Ã, Ã, int selectedItem = ListBoxGetSelected(sldGUI, sldListbox);
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, // Ã, if it's not out of bounds...
Ã, Ã, Ã, Ã, if ( ( selectedItem >= 0 ) && ( selectedItem < SAVELOAD_SLOTS_MAX ) )
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, delete the slot:
Ã, Ã, Ã, Ã, Ã, Ã, DeleteSaveSlot(savegameindex[selectedItem]);
Ã, Ã, Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, update the save/load GUI and get the number of items:
Ã, Ã, Ã, Ã, Ã, Ã, int totalSlots = UpdateSaveLoadDialogGUI();
Ã, Ã, Ã, Ã,Â
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, When we delete *the last* slot the highlight is
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, removed, so we should get it back by highlighting
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, a new last slot:
Ã, Ã, Ã, Ã, Ã, Ã, if (ListBoxGetSelected(sldGUI, sldListbox) == -1)
Ã, Ã, Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Ã, highlight the last item if required:
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, ListBoxSetSelected(sldGUI, sldListbox, totalSlots - 1);
Ã, Ã, Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, else // Ã, otherwise...
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // Ã, display a message (as slot isn't selected):
Ã, Ã, Ã, Ã, Ã, Ã, Display(SLD_MESSAGE_NoItemSelectedToDelete);
Ã, Ã, Ã, Ã, }
Ã, Ã, }
//-------------------------------------------------------------------
Ã, Ã, // if click on a *cancel button*:
Ã, Ã, else if (button == sldCancelButton)
Ã, Ã, {
Ã, Ã, Ã, Ã, CloseSaveLoadDialog(); // close the save/load GUI;
Ã, Ã, }
}
function OpenSaveLoadDialog() {
//=---------------------------------------------------------------------=
// Ã, Opens the *save/load* combo dialog:
//=---------------------------------------------------------------------=
Ã, Ã, // Ã, Setting up the GUI (pass -1 if the GUI object is unused!):
Ã, Ã, // Ã, ------------------------GUI---tbox--lbox--save--load--del--cancel
Ã, Ã, PrepareSaveLoadDialog( Ã, Ã, Ã, 10, Ã, 0, Ã, Ã, 1, Ã, Ã, 4, Ã, Ã, 3, Ã, 5, Ã, Ã, 6 Ã, );
Ã, Ã,Â
Ã, Ã, // Ã, Open GUI:
Ã, Ã, OpenDialogGUI();
}
function OpenSaveDialog() {
//=---------------------------------------------------------------------=
// Ã, Opens the *save* dialog:
//=---------------------------------------------------------------------=
Ã, Ã, // Ã, Setting up the GUI (pass -1 if the GUI object is unused!):
Ã, Ã, // Ã, ------------------------GUI---tbox--lbox--save--load--del--cancel
Ã, Ã, PrepareSaveLoadDialog( Ã, Ã, Ã, 8, Ã, Ã, 3, Ã, Ã, 2, Ã, Ã, 0, Ã, -1, Ã, 5, Ã, Ã, 1 Ã, );
Ã, Ã,Â
Ã, Ã, // Ã, Open GUI:
Ã, Ã, OpenDialogGUI();
}
function OpenLoadDialog() {
//=---------------------------------------------------------------------=
// Ã, Opens the *load* dialog:
//=---------------------------------------------------------------------=
Ã, Ã, // Ã, Setting up the GUI (pass -1 if the GUI object is unused!):
Ã, Ã, // Ã, ------------------------GUI---tbox--lbox--save--load--del--cancel
Ã, Ã, PrepareSaveLoadDialog( Ã, Ã, Ã, 9, Ã, Ã, -1, Ã, Ã, 0, Ã, -1, Ã, Ã, 1, Ã, -1, Ã, Ã, 2 Ã, );
Ã, Ã,Â
Ã, Ã, // Ã, Open GUI:
Ã, Ã, OpenDialogGUI();
}
function on_event(int event, int data) {
Ã, // called when an event happens (see AGS manual for details)
Ã,Â
Ã, Ã, // Ã, inform our save/load GUI of the event;
Ã, Ã, on_event_SaveLoadDialogGUI(event, data);
}
And that is only part of it. Since I can't exceed the 20000 characters limit in these forums. I am forced to double post and here is the rest of it:
http://www.2dadventure.com/ags/edsglobalscript1.zip
sorry for the zip file, 2dadventure does not allow txt files.....
You forget to add one essential line into interface_click:
function interface_click(int interface, int button) {
Ã, //Ã, calling our function for clicks over sldGUI:
Ã, if (interface == sldGUI) interface_click_SaveLoadDialogGUI(button);
...
...
Thanks. Uhoh, now I realized that when I read your post it took almost 100 seconds. With 19 queries. Maybe I was downloading that game at 10kbps when it should normally be about 4kbps.
I have one final question to ask, which lines do I have to modify to make it so that the player can save a limit of 100 save game slots?
It's not currently possible to rise the limit beyond 20. As I said before, I'll look into how it can be increased and reply back then. ;)
It is currently possible, just not using the savegameindex[] array... :P You have to use SaveGameSlot(int slot, string description) and RestoreGameSlot(int slot). However, this changes the way you have to set up your listbox. You could use something like:
function ListBox(int gui, int object){
string buffer, description;
int counter;
ListBoxClear(gui, object);
while (counter<100){
StrFormat(buffer, "%d. ", counter+1);
if (GetSaveSlotDescription(counter+100, description)!=1) StrCopy(description, "");
StrCat(buffer, description);
ListBoxAdd(gui, object, buffer);
counter++;
}
ListBoxSetTopItem(gui, object, 0);
ListBoxSetSelected(gui, object, -1);
}
Thanks to Proskrito for the script... I don't know if you wanted your listbox items numbered, but if not, you can just do:
function ListBox(int gui, int object){
string description;
int saveslot;
ListBoxClear(gui, object);
while (saveslot<100){
if (GetSaveSlotDescription(saveslot+100, description)!=1) StrCopy(description, "");
ListBoxAdd(gui, object, description);
saveslot++;
}
ListBoxSetTopItem(gui, object, 0);
ListBoxSetSelected(gui, object, -1);
}
Or something like that... ;)
A minor plug - version 1.1 of my Black Cauldron remake contains a custom save/restore dialog box with support for more than 20 slots. In retrospect I could have optimised it further, since I didn't know about the GetSaveSlotDescription method, but you may get some good ideas for it. Basically, I use a custom file to store the current ordering of save game slots, and then use it to load the listbox with the save games in the correct order.
http://tg_comics.tripod.com/bc.html