Bonus Material Upon Game Completion

Started by MoodyBlues, Wed 06/05/2009 14:17:45

Previous topic - Next topic

MoodyBlues

I know I saw this question asked somewhere else, but I didn't know where to find it.

What I want to do is make a new button visible on the title screen after the player completes the game.  I also want this button to remain visible even after the player quits and starts up the game again.  Is this possible?
Atapi - A Fantasy Adventure
Now available!: http://www.afwcon.org/

Gilbert

One easy way to do this is to use the File functions to write a small file when the player completed your game and upon starting the game it will check whether the file exists, so you may do whatever addition stuff you want to reward the player.

If you don't want people to cheat and fake it just write some small content to that file so the game can check whether it's genuine.

Trent R

There's also the Encrypted File Module which will prevent people from cheating.

Another idea (which may or may not work) is simply to create a save file at the end of the game (let's say, number 83) and then check the directory if that file exists. Just make sure the user can't load/save/delete that file, which is why a high number should work.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

Using an encrypted file won't do much good; you can still use the file from someone else.
Except if the contents is derived from some unique machine parameter. I don't think AGS can get any of these though.

MoodyBlues

Thanks, guys.  That helps a lot.

I'm having a problem, though:

I save a new game (99) on the last screen.  When I load the title screen, I get an "Object not specified" error here:

function room_Load()
{
 

if (Game.GetSaveSlotDescription(99) != null)
  object[4].Visible = true;
else object[4].Visible = false;

}

Do I need to declare an instance of Game?  If not, what am I doing wrong?
Atapi - A Fantasy Adventure
Now available!: http://www.afwcon.org/

Khris

I think the error refers to the line "object[4].Visible = true;".
Make sure there is an object with an ID of 4. (Should be the fifth object.)

Btw, in room scripts, you can reference objects using their actual names; doing it via the object[] array is only necessary in the global script.

MoodyBlues

#6
I don't think it's object[4] because when I start up the game again after beating it and quitting, the object is visible.

Here's what I do right before going to the title screen:

    SaveGameSlot(99, "win");

    Wait(120);
    EndCutscene();
        StopMusic();
    StopAmbientSound (4);
   
    cEgo.ChangeRoom(26);
   
   
Atapi - A Fantasy Adventure
Now available!: http://www.afwcon.org/

Khris

Well, I opened my default game I use for tests and put this in room_Load of the first room script:
Code: ags
  if (Game.GetSaveSlotDescription(99) != null) Display("It exists.");
  object[4].Visible = true;

(The room has just one object.)

Running the game highlighted the object[4] line and displayed the error "invalid object specified".

I can't imagine "Game" not being specified at the time of a room_Load.
Please double-check the exact line and wording of the error.

MoodyBlues

#8
Okay, I think you're right - it's a problem with the room object, not Game.

I tried doing this instead after naming my object "Bonus:"

if (Game.GetSaveSlotDescription(99) != null)

  Bonus.Visible = true;
else Bonus.Visible = false;

But I got this error:

Error:  Unable to create local script: Runtime error: unresolved import 'Bonus'

And yes, I'm sure I have an object named "Bonus."

Oddly enough, when I try this with other objects, it works fine.  I guess there's something about Bonus the compiler doesn't like.
Atapi - A Fantasy Adventure
Now available!: http://www.afwcon.org/

RickJ

Object names have a lower case 'o' prefix that is automatically attached to the name you enter by the AGS editor.   So if you named an object Bonus then it is referenced in the script as oBonus as shown below.   

Code: ags

if (Game.GetSaveSlotDescription(99) != null)

  oBonus.Visible = true;
else oBonus.Visible = false;

MoodyBlues

Hmm, I tried that, and it didn't work.

When I used a different object, I just used its name (RestoreGame) and it worked fine.
Atapi - A Fantasy Adventure
Now available!: http://www.afwcon.org/

Khris

Since Version 3, there's no 'o' added to Object names any longer. (And no 'h', 'c', aso.)

Make sure you've entered the name "Bonus" as the Name property, not Description property.
I've tested this, and I can create and change the visibility of my object Bonus just fine.

The auto-complete should kick in as soon as you've typed "Bon".

Btw, I noticed that if I don't name the object Bonus but try to address it in script, the error I get says "Undefined token".
You're getting an unresolved import, so my guess is there's something else also named Bonus interfering with the object.

MoodyBlues

Okay, I tried naming it something else, but nothing worked.  It doesn't matter what I name the dang thing; I still get an error.

Eh, I've kind of given up on it.  When I used a preexisting button (2), it worked better.

Thanks for your help, guys.  I really hope I didn't miss anything really obvious.
Atapi - A Fantasy Adventure
Now available!: http://www.afwcon.org/

SMF spam blocked by CleanTalk