Author Topic: Permanent Switches on RMXP (I want to make my picture gallery work D8 )  (Read 3343 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
I recently found this really epic picture gallery script: http://www.atelier-rgss.com/RGSS/System/XP_SYS13.html This will work wonders for my game which is part visual novel, part Ib-style horror game.

Thing is, I'll be having several endings, each with their own pictures. And RMXP's annoying lack of permanent switches (aka switches and variables that persist from one savefile to the next) means that whoever who plays my game can never attain 100% completion on the gallery because pictures they unlocked in one savefile will disappear in the next.

Help? ;u; I really want to make this work. Thanks!

I found a permanent switch script for RMVXAce (http://www.rpgmakervxace.net/topic/6462-global-save-file-by-skul/), which I also have, but I've already decided to use RMXP and I can't really convert because I don't know how to map on Ace at all. D:

Question Mark

  • 疑問符の人
  • Mod-Suspect
  • Tier 7
  • *
  • Posts: 1492
  • Gender: Male
You could do what Reives did for DYRML. The game outputs save files at certain points and these save files are searched by the game upon startup and, if found, would unlock the scene button. I'm not sure if I fully understand his system though. I just read the code several times and I'm not sure if it's possible to chuck some sort of encrypted code in the save file so players can't just create a fake savefile via notepad, rename the extension to .rxdata, and bypass the system.

Kirroha

  • 僕はとてもきれいな人だよ!
  • *
  • Tier 7
  • **
  • Posts: 4596
  • Gender: Female
  • ... or so I heard.
  • Current Mood: cheerful cheerful
You could do what Reives did for DYRML. The game outputs save files at certain points and these save files are searched by the game upon startup and, if found, would unlock the scene button. I'm not sure if I fully understand his system though. I just read the code several times and I'm not sure if it's possible to chuck some sort of encrypted code in the save file so players can't just create a fake savefile via notepad, rename the extension to .rxdata, and bypass the system.

I guess that could work. I could always have a file for certain endings. Can I have a sample of the code, please? I don't know how to write it myself. ^^; Thanks!

Question Mark

  • 疑問符の人
  • Mod-Suspect
  • Tier 7
  • *
  • Posts: 1492
  • Gender: Male
Do a script function call (tab3 -> "Script..."), with the code:

Code: [Select]
$game_player.make_saveOne
"make_saveOne" is the name of one of the functions in DYRML. You can name yours whatever you want. Then, in RMXP's script editor, all of DYRML's functions are isolated in their own file. That file's class is "Game_Player." Here's one such code:

Code: [Select]
  def make_saveOne
    file = File.open("Wirt.rxdata", "wb")
    Marshal.dump("   Change my name to-", file)
    file.close
  end

It has been about four years since I last dealt with string-to-file functions so I'm not certain at the above code, but I think "wb" means "write binary." I don't remember the other settings aside from "r" (read) so I don't know if there is a "w" (write), and if there is, how it differs. I'm not really certain what .dump does. I can speculate that it chucks in the string into the binary file before it's closed, but even then, why? Encryption? I don't know.

Above all the save functions, make a simple file check for the save data in question.

Code: [Select]
    if FileTest.exist?("Wirt.rxdata")
      $game_variables[7] = 1
    end

I can only presume that this if-statements are automatically read by RMXP at the start of the game since I know of no other code that calls them.

$game_variables[7] corresponds to variable 7 in RMXP. It's probably safe to use a number that isn't right in the middle of other variables though.
Spoiler: Sidetracking stuff • show
Do note that the other file check if-statements give other values to $game_variables[7], 1 to 6, which determines just how much of the pictures in the scene selection in DYRML to unlock. This is useful if you plan to divide your gallery in two or more categories so that you won't have to use one variable per picture. Let's say that character A would hold $game_variables[10] and he/she has 5 different pictures, you could do a $game_variables[10] = 1 as soon as his/her first picture is hit and do a $game_variables[10] = 2 as soon as the second one is hit on the condition that if $game_variables[10] = 1, unlock only picture 1, but if $game_variables[10] = 2, unlock only picture 1 and 2. This can be done through conditional branches.


 Here's how it looks like in DYRML:

Code: [Select]
Conditional Branch: Variable [0007: Latest Save Point] < 1
    ~present the scene as locked~
Else
    ~present the scene available~

I probably confused myself several times in the course of typing this. Here's how the codes do it in DYRML:
  • At startup, check for specifically named saves.
  • If found, update variables.
  • Read variables, react accordingly
  • Create specifically named saves when told to do so.

And it cycles. I'm not sure if you'll be able to run it. I may have missed an important code or three. I'm not familiar with Ruby.