Author Topic: Global saves possible? (aka, stuff like unlockable gallery in title)  (Read 4287 times)

0 Members and 1 Guest are viewing this topic.

Kirroha

  • 僕はとてもきれいな人だよ!
  • *
  • Tier 7
  • **
  • Posts: 4596
  • Gender: Female
  • ... or so I heard.
  • Current Mood: cheerful cheerful
Is there any way for me to make it such that if the player has played through the game once, or have achieved a certain point in the game, a global save can be created such that new elements are added into the game, like an ending gallery or image gallery?

This is for RMXP, by the way.

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #1 on: April 07, 2011, 10:50:34 AM »
Of course. Global saves are in terms no different from how default RMXP saves work. You could either save the file and then check if it exists, but that's not very safe, and allows the user to just create that file in their game folder to unlock the new features, so you'd probably want a unique code of some sort that only the game knows about.

For instance, at the point in time in your game where you want this save change to happen, you could simply call this code in an event:
Code: [Select]
file = File.open("GameData.rxdata","wb")
Marshal.dump("myGameTitleOrWhatever", file)
file.close
Now this won't directly impact the game at any given time. To make sure it does impact the game correctly, for instance if you want an additional option on the title screen when this save has occured, you could do this as an example in the Scene_Title script (assuming default):
Code: [Select]
# Create command list
list = ["New Game", "Continue", "Shutdown"]
# Load file if exists
if FileTest.exist?("GameData.rxdata")
  data = load_data("GameData.rxdata")
  list << "Image Gallery" if data == "myGameTitleOrWhatever"
end
# Create command window
@command_window = Window_Command.new(160, list)
@command_window.opacity = 0
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 440 - @command_window.height
Naturally you'd need some more modifcations than that to make the new command work, and you'd have to remove the original command window declaration, but I would assume you get the idea.

If there's anything you don't understand, shout!

/Sark

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.

Vasha

  • 小説家
  • *
  • Tier 7
  • **
  • Posts: 10734
  • Gender: Male
  • Relentlessly Gay
    • My Tumblr
  • Current Mood: blank blank
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #2 on: April 09, 2011, 10:28:51 AM »
I also know that Children of the Gods had a bonus option from the main menu, so the guy who made that (KRoP?) could probably help you if you find a way to contact him (if what Sark said isn't what you're looking for).

Kirroha

  • 僕はとてもきれいな人だよ!
  • *
  • Tier 7
  • **
  • Posts: 4596
  • Gender: Female
  • ... or so I heard.
  • Current Mood: cheerful cheerful
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #3 on: April 12, 2011, 07:35:44 AM »
Thanks for helping, Sark, but I'm a complete noob when it comes to scripts ^^; I use a completely evented title screen, so what should I do if that's what I'm using?

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #4 on: April 12, 2011, 08:03:46 AM »
Do the same, but use conditional branches. If you use this event outlet for creating or getting the event commands:

Conditonal Branch: Script: FileTest.exist?("GameData.rxdata")
  Script: $game_variables[999] = load_data("GameData.rxdata")
  Conditional Branch: Script: $game_variables[999] == "myGameTitleOrWhatever"
     Comment: Add constructor commands here to add your new title button
  End
End

That should work. I don't know how your evented title screen is set up, so you can probably change it so it works with the stuff you use.

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.

Kirroha

  • 僕はとてもきれいな人だよ!
  • *
  • Tier 7
  • **
  • Posts: 4596
  • Gender: Female
  • ... or so I heard.
  • Current Mood: cheerful cheerful
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #5 on: April 13, 2011, 08:43:20 AM »
Thanks. So basically, the first script creates a global save at that point, and the second script sees if the save is there before placing the button?

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #6 on: April 13, 2011, 08:46:01 AM »
Thanks. So basically, the first script creates a global save at that point, and the second script sees if the save is there before placing the button?
Yes. The first one creates it, the second checks if the file exists and its contents are correct so people can't create the file manually to cheat :P

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.

Kirroha

  • 僕はとてもきれいな人だよ!
  • *
  • Tier 7
  • **
  • Posts: 4596
  • Gender: Female
  • ... or so I heard.
  • Current Mood: cheerful cheerful
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #7 on: April 18, 2011, 10:00:30 AM »
Can I do something like this?

Conditonal Branch: Script: FileTest.exist?("GameData.rxdata")
  Script: $game_variables[999] = load_data("GameData.rxdata")
  Conditional Branch: Script: $game_variables[999] == "myGameTitleOrWhatever"
     Switch: [GalleryAppears] ON
  End
End

And then I create another event that requires that switch to be on, and put the button there?

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #8 on: April 18, 2011, 10:09:59 AM »
As long as that part of the script runs before the title screen actually shows up, that should be fine. Make sure you only allow it to run once per title, though. Loading the data over and over is not something you want to do.

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.

Kirroha

  • 僕はとてもきれいな人だよ!
  • *
  • Tier 7
  • **
  • Posts: 4596
  • Gender: Female
  • ... or so I heard.
  • Current Mood: cheerful cheerful
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #9 on: April 19, 2011, 09:40:04 AM »
Ok, thanks. By the way, what if I want to implement an "Ending Gallery" kind of thing, which shows different endings depending on whether or not you have experienced them? Will it be very confusing to implement?

Sarkilas

  • *
  • Tier 6
  • **
  • Posts: 429
  • Gender: Male
  • That guy
  • Current Mood: creative creative
Re: Global saves possible? (aka, stuff like unlockable gallery in title)
« Reply #10 on: April 19, 2011, 09:45:01 AM »
Shouldn't be. But that should be a separate scene, right?

Need scripting help? Toss me a PM and I'll see what I can do.
Also able to help with anything RMXP related. Please do not hesitate to ask.