Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

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

Code:
 

#==============================================================================

# ** Game_Cache

#------------------------------------------------------------------------------

#This Script Adds Cache Functions to RGSS

#==============================================================================

$game_cache=[]

  def dump_cache()

    save_data($game_cache , "Data/Cache.rxdata")

    $game_cache=[]

  end

  def load_cache()

    $game_cache = load_data("Data/Cache.rxdata")

  end

 
 

Zeriab

Sponsor

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.
Code:
 

dump_cache()

load_cache()

 
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:
Code:
 

$game_data=["check 1"]

dump_cache()

#At a script before title.

#=========================

#Checker

#=========================

load_cache()

if $game_cache[0]=="check 1"

     print("Now checking Game.exe")

end

 
 
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 >.>
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top