Main Menu
  • Welcome to The RPG Maker Resource Kit.

Memorize Screen Tone

Started by heisenman, April 23, 2011, 12:42:28 AM

0 Members and 1 Guest are viewing this topic.

heisenman

Memorize Screen Tone
24 4 2011




Summary
I tried to convert ccoa's Memorize Screen Tone from XP, but alas  :V

Features Desired

  • a script call to memorize the current screen tone
  • another one to return the memorized screen tone

Games its been in

  • I suppose this was created for Memento Vivere

What other scripts are you using?

  • lol too many. The ones that could interfere with screen tinting might be Tone Tester
  • Battle Screen Effects
  • Battle Engine Melody does have melodies that allow the change of screen tone in battles, not sure this is relevant.




Did you search?
Yes

Where did you search?

  • Google

What did you search for?

  • memorize screen tone rmvx
  • memorize screen tint rmvx
  • same thing with inverted words

modern algebra


Aurelia

Just one question, what are you ganna do with this script o_O? It doesn't sound like something you can't manually set
I support \\(>O<)b




heisenman

Thanks MA, I'm sure this is a easy task for you xD

Quote from: Aurelia on April 23, 2011, 12:55:32 AM
Just one question, what are you ganna do with this script o_O? It doesn't sound like something you can't manually set
It's because I have a parallel process running in every map that will change screentone when a key is pressed (kinda like night goggles), and when they key's pressed again the tone goes back to what it was before, but since not all the maps have the same tone, I cannot have it to return to just a single value.
I could do this with events, but it'll require too many conditional branches and I want to keep the parallel process as light as possible to avoid lag.

modern algebra

#4
Here:

#==============================================================================
# ** Game Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new instance variable - ma_memorized_tone
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :ma_memorized_tone
end

#==============================================================================
# ** Game Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new methods - memorize_screen_tone; restore_screen_tone
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Memorize Screen Tone
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def memorize_tone
    $game_map.ma_memorized_tone = $game_map.screen.tone.clone
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Restore Screen Tone
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def restore_tone (duration = 0)
    $game_map.screen.start_tone_change ($game_map.ma_memorized_tone, duration) unless $game_map.ma_memorized_tone.nil?
  end
end


To use it, just use the following code in an evented script call to memorize it:


memorize_tone


And use the following to restore it:


restore_tone (x)


where x is the duration. So 60 would be 60 frames. If you don't include it, so just:

restore_tone

then it will do it immediately (ie 0 frames)

ForeverZero

That won't save the data, though. You need to store the data in a class that gets marshalled.

heisenman

Quote$game_map.screen.tone.dup
Ah, I used clone as in ccoa's version...

QuoteThat won't save the data, though. You need to store the data in a class that gets marshalled.
I don't know what it means, but I tried memorizing, changing tone, saving, F12ing, and calling the memorized tone. It worked, so I suppose the thing gets stored in the savefile.

Thanks again MA (:

ForeverZero

Did you try saving the file, shutting it off, then loading the file?
I may be wrong about the whole thing, I am more of an XP person than VX.  :P


modern algebra

#9
No, he's right that the script doesn't work. Well, not quite for those reasons - the class will get marshalled since they are always saved to variables within classes that do get marshalled (Game_Event; Game_CommonEvent; Game_Map). But making it an instance variable was silly since it won't work through any of the other interpreters - IE you couldn't restore it or memorize it through any parallel process events or common events or even child interpreters. I should have either put it in a class like Game_Map or made it a class variable.

I've changed it to a class variable since that was easier. Grab it again from the previous post.

But yeah; thanks for the catch ForeverZero - I wouldn't have given that choice a second thought if you hadn't popped in. I definitely should have been smarter about it. Also, putting it in another class like Game_Map would probably be smarter than using a class variable, but adding three extra @s was slightly faster and I'm lazy.

Also, @heisenman - clone would have worked too. They're the same method except clone is a more complete copy as it includes freeze status and singleton methods. Are you sure that was that the only difference?

heisenman

#10
Before I make myself sound sillier than I actually am, I did try if it worked but not on my parallel process, just on some dummy events :tpg:

Quote@heisenman - clone would have worked too. They're the same method except clone is a more complete copy as it includes freeze status and singleton methods. Are you sure that was that the only difference?
Nope, that wasn't the only difference at all, the reason why it wasn't working is surely because I copypasted things at random out of desperation.

EDIT: After quitting, loading and calling the common event again.


modern algebra

#11
Alright, I fixed it this time for real and wasn't as lazy. I replaced it in the first post.

I knew that class variables weren't marshalled; it didn't make any sense. I had tested it using F12 though and it worked, so I stupidly assumed that I had been wrong. Dumb me :)

heisenman

All right, the third time is the lucky one.
It works both ways:

1) Open > Use goggles to change tone > Save > Quit > Load > Use goggles again > Just fine. (It crashed here before)
2) Open > Use goggles to change tone> Use goggles to resore tone > Save > Quit > Load > Use goggles again > Just fine.

I cannot think of other ways to test if works correctly. If I run into other problems I'll come back begging for assistance.


Thanks MA for the patience, and thanks ForeverZero for helping (: