Hi, Tried this in beginners tech, doesnt seem like anyone there can figure it out, its a pretty urgent issue for the continuance of my game:
I have a predefined string "nick" which the player enters into a text box.
I would like for the game to use this "nick" as the save game name.
I would like it to use that string no matter if the save game list has 0 index or not.
This is the code I'm playing with.
function btnIconSave_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = true;
// Get the list of save games
lstSaveGamesList.FillSaveGameList();
if (lstSaveGamesList.ItemCount > 0)
{
// If there is at least one, set the default text
// to be the first game's name
txtNewSaveName.Text = lstSaveGamesList.Items[0];
}
else
{
// No save games yet, default empty text.
txtNewSaveName.Text = "";
}
mouse.UseModeGraphic(eModePointer);
gIconbar.Visible = false;
}
And this is what I'm trying to do with it, not seeming to work though.
function btnIconSave_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = true;
// Get the list of save games
lstSaveGamesList.FillSaveGameList();
if (lstSaveGamesList.ItemCount > 0)
{
// If there is at least one, set the default text
// to be the first game's name
txtNewSaveName.Text = lstSaveGamesList.Items[0];
}
else
{
// was trying to change this to
txtNewSaveName.Text = nick;
//but it appeared to have no effect
//also this only effects it if the index is 0 i would like it to use the nick string
//in any case
}
mouse.UseModeGraphic(eModePointer);
gIconbar.Visible = false;
}
I tried monkeys suggestion of:
function btnIconSave_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = true;
// Get the list of save games
lstSaveGamesList.FillSaveGameList();
// removed the if-else block entirely
txtNewSaveName.Text = nick;
mouse.UseModeGraphic(eModePointer);
gIconbar.Visible = false;
}
With the wonderful result of:
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x00427CC0 ; program pointer is +6, ACI version 3.21.1115, gtags (6,15)
AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.
in "GlobalScript.asc", line 1429
Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.
An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
OK
---------------------------
Any ags genius out there that can help!?!?!?
Don't cross post. People check both forums.
Do you want to allow multiple save games or not?
Because if you don't all you need is
SaveGameSlot(1, nick);
(Afaik, using an existing name for the save game overwrites the old save, so having multiple save games all named nick isn't possible anyway.)
Also, how does a minor save technicality keep you from continuing your game...‽
Well, I do want multiple saves, but a temporary solution will do.
The save game issue is so important because I need to start building the beginning statistics addition at the beginning, and the users will be angry if they have to do their statistics over and over Also it kinda makes the game seem kinda disposable andI'm in dire need of beta testers which might be awarded special items for the help.Among other reasons.
I thank you greatly for the reply :D
PS. nick is a predefined string nick which is inputted by the user using:
[EDITED]
String nick;
nick = Game.InputBox("Enter a nick name (A-Za-z0-9_):");
Yay, Its working mostly now. Now all i need to be able to do is save multiple nicks and make it autosave on quit!
[edit]
got the multiple nicks part :D
Working on autosave
Ok, this is my last retarded question of this post.
Is there some way i can jam this all into the games quit button:
//////actual save button on the gSaveGame panel//////////////
function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
txtNewSaveName.Text = nick;
int gameSlotToSaveInto = lstSaveGamesList.ItemCount + 1;
int i = 0;
while (i < lstSaveGamesList.ItemCount)
{
if (lstSaveGamesList.Items[i] == txtNewSaveName.Text)
{
gameSlotToSaveInto = lstSaveGamesList.SaveGameSlots[i];
}
i++;
}
SaveGameSlot(gameSlotToSaveInto, txtNewSaveName.Text);
close_save_game_dialog();
}
//////////////button on the gpanel that opens the gsavegame panel/////
function btnIconSave1_OnClick(GUIControl *control, MouseButton button)
{
int gameSlotToSaveInto = lstSaveGamesList.ItemCount + 1;
gSaveGame.Visible = true;
// Get the list of save games
lstSaveGamesList.FillSaveGameList();
if (lstSaveGamesList.ItemCount > 0)
{
//If there is at least one, set the default text
//to be the first game's name
txtNewSaveName.Text = lstSaveGamesList.Items[0];
}
else
{
txtNewSaveName.Text = "";
}
mouse.UseModeGraphic(eModePointer);
gIconbar.Visible = false;
}
where it will emulate as if i had clicked the save button.
Trying to make sort of an autosave on quit, I've gotten everything else working exactley as needed.
This takes the nick string from textbox and saves it in a new slot for every new name.
All i need it to do now is basically somehow execute the combined code of both functions by clicking the quit button and my brain is fried from what i've done so far.
If someone could shine some light it would be greatly appreciated :D
btnSaveGame_OnClick(btnSaveGame, eMouseLeft);
btnIconSave1_OnClick(btnIconSave1, eMouseLeft);
Awesome, never knew you could do that!, still not working because i guess a command or 2 need to be made butI'm sure i can figure something out on that note
Thx bud :D
Going to consider this one solved.
Yeah, they're functions just like any other.
All you need to do is supply the button itself and the used mouse key.
If you aren't using the parameters, you can instead do
btnSaveGame_OnClick(null, 0);