Game_Cache

Game_Cache
Version: 1.0.0.0
By:Lionel

Introduction
This Script Adds Cache Functions to RGSS
Dump_Cache saves $game_cache to Cache.rxdata
Load_Cache puts data from Cache.rxdata into $game_cache
Script

script Spoiler
  1.  
  2. #==============================================================================
  3. # ** Game_Cache
  4. #------------------------------------------------------------------------------
  5. #This Script Adds Cache Functions to RGSS
  6. #==============================================================================
  7. $game_cache=[]
  8.   def dump_cache()
  9.     save_data($game_cache , "Data/Cache.rxdata")
  10.     $game_cache=[]
  11.   end
  12.   def load_cache()
  13.     $game_cache = load_data("Data/Cache.rxdata")
  14.   end
  15.  
Expand to see the code.
Hi Lionel,

Since this basically is a snippet it might fare better in the Scripter's Corner. Tell me if you want to move it over there.

I suggest you follow the conventions. I.e. method variable names being lower case. ($Game_Cache => $game_cache and Dump_Cache => dump_cache)
I also suggest presenting an example or two of how to use it.

Why do you clear the cache when you dump it?
How do you define a cache to start with?
What is the idea behind your script? There is already RPG::Cache, so why is it interesting having $Game_Cache as well?
To be honest I don't see the purpose in this :huh:

*hugs*
I would be fine to move it to Scripter's Corner, If there is a lot of reasons to do so.(Sorry if I sound harsh.)
And I honestly didn't know there was RPG::Cache.
Now to answer questions.
Q:Why do you clear the cache when you dump it?
A:When you dump something your moving it (Dump=moving),so your moving that to Cache.rxdata ,but when you move it can't be split, because that would be copying,but if you don't want $game_cache to be cleared just do this.
  1.  
  2. dump_cache()
  3. load_cache()
  4.  
Expand to see the code.

Q:How do you define a cache to start with?
A: You put the script before ALL custom scripts(Including SDK and MACL),
To refer to the cache you use $game_cache[#] or $game_cache=[Data].
Uses:
You could use so at the end of the game(shutdown)
It stores in $game_cache[0] "Shutdown hit"
You dump it.
When the game restarts, you have a special script that checks in Cache.rxdata(using load_cache())
If $game_cache[0]="Shutdown hit"
it will display a message box or something.
Examples:
  1.  
  2. $game_data=["check 1"]
  3. dump_cache()
  4. #At a script before title.
  5. #=========================
  6. #Checker
  7. #=========================
  8. load_cache()
  9. if $game_cache[0]=="check 1"
  10.      print("Now checking Game.exe")
  11. end
  12.  
Expand to see the code.
No really, why would we need this? It still seems to be redundant code.
The save_data method just calls a single Marshal.dump. It's not moving any data or anything, so clearing the array serves no purpose.

Basically what this is is a less useful version of two built-in funtions.
It really is pretty useless >.>
I agree, it's 100% useless.
It's still usable thought!

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=69917