Tutorial Game Cache

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Introduction: In this tutorial, I will cover the basics how to use game cache – how to store, retrieve and move information between maps.


Question: What is game cache?​
A game cache is basically a memory area where you can store and, later,
restore previously stored data or information.


Question: Can I switch between maps in multiplayer?​
No, you cannot. You can use game cache in multiplayer to enchance spells or gameplay, but you cannot switch between maps. It is only for single player.


Step 1 – Storing the information and moving it to another map


Lets get started by creating a map and naming it DemoMap. After that, open the variable editor (
variableseditors.jpg
) and create a game cache type variable. Name it Cache.

Now, you are ready for some information storing, but firstly, you need to initialize the game cache. Create an initialization trigger, and create the cache.

pilt1.gif


After the cache is initialized, lets move ahead to storing some information. The event and conditions don’t matter in this tutorial, so I will use the classic way, which is used in the Rexxar campaigans, also – a unit enters a region, store some information and load the new map.

pilt5a.gif


After an event and some basic conditions have been created, you need to store the triggering unit and might as well the gold&lumber the owner of the unit has. (When storing data, each, eg, stored unit has to have an unique label, otherwise, the stored unit will overwrite the previous one.)

Note: Both maps - the one where you store and the other, where you restore - need the same instance of the unit you are storing. Otherwise, the game wont load the unit at all. (e.g. You have a modified hero called "Druglord", all the maps need the same instance of, where you are planning to store and restore it)​

pilt5b.gif


Do not forget to save the game cache after that!

pilt3.gif


Lastly, you need to load the new map. Note, the map has to be in a specified category in your computer and assumes you have the other map already created. In my case, the other maps name is DemoMap2 and it is located in the Warcraft III installation folder, under Maps\DemoMap2.w3x.

pilt4.gif


The complete trigger looks like this:

pilt5.gif



Step 2 – Retrieving the stored information


To retrieve the stored data to DemoMap2, you need to initialize the game cache again, from the DemoMap.

pilt1.gif


It is up to you, when you retrieve your information. I will restore it at map initialization.

To restore booleans, integers, reals or strings, you need to create corresponding types of variables to load the information to. We stored gold&lumber, so we need 2 integer variables. Create and name them respectively Gold and Lumber.

Tip: You do not need to create a variable for every value you want to store and restore later. You can use specified typed variable arrays.​

As I said, you need to load the information to a variable. You need to use the exact same labels and categories, what you used to store the data.

goldsss.gif


loadgold.gif


pilt1a.gif


Note
: To reference the stored unit somehow, you need a unit variable. Create the variable, name it - Rexxar, in my case - and set the restored unit into a variable as "Last restored unit".​

rexxxxxar-1.gif


Because we saved the information to variables, the content of the game cache is not needed anymore, so we might as well clear and save it. (If you need the content later, skip this step)

pilt2a.gif


Lastly, you just need to set the players gold and lumber to the values as they were in DemoMap originally.

pilt3a.gif


The complete trigger looks like this:

pilt4a.gif


Having followed these steps correctly, you should be able to store, move and restore data between two different maps.

Have fun and feedback is always appriciated.
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
Good Job it realy cleared for me a lot of stuff i didn't knew on game cache (+Rep :D)
 

D.K.

New Member
Reaction score
11
I don't really get what game cache is. Is it when you have a map imported... and you load that other map.... the game cache moves information like gold and hero lvl to that other map?
 

Master

Thou shall be helped by...The Black Adder!
Reaction score
72
Good tutorial, similar to this.
Yet the more the variety the better the knowledge ;)
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
A game cache is basically a memory area where you can store and later,
restore data, information. That allows you to store and restore units/gold &
lumber/food/etc. between maps.


The other tutorial does not explain how to store and restore integers or reals.


//This tutorial explains how to store, move and restore information between maps.
I will not explain how to use game cache with more advanced functions in
JASS, what are used for making spells MUI. (There are spell tutorials, which
teach that already. E.g emjir3 tutorials)
 

Master

Thou shall be helped by...The Black Adder!
Reaction score
72
Okay. I did not read the other one, I supposed they were the same.
But neat done nevertheless.
 

ayumilove

Youtube account suspended! youtube.com/ayumilove8
Reaction score
110
Nice tutorial Andrew! <3 +rep

~ Ayumilove

ps: how did you make the picture for the (event + condition + action)
without the white color background?

pilt4a.gif
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
Nice tutorial Andrew! <3 +rep

~ Ayumilove

ps: how did you make the picture for the (event + condition + action)
without the white color background?

pilt4a.gif
u can do it easly in photoshop just choose only the white color without the words (u do it with this wand looking tool i forgot it's name) and than delete it and u are left with only what written without the words in it

Edit: now that i see it in the quote i can see it's not deleted he just made it in the color of the forum's post but on the quest the color is different so u can the difference :D
 

lh2705

Just another Helper
Reaction score
111
It looks more like he saved the screenshot of the triggers and cut the picture out and pasted it. Anyways, Pretty nice..
 

Tinki3

Special Member
Reaction score
418
Good tutorial Andrewgosu (+rep), but, maybe explain how to use a handel vars system, as well as just storing units and integers?

I know its a weird suggestion, but, since it uses a Game Cache, it has some relevance to your tutorial.
 

Chocobo

White-Flower
Reaction score
409
Good tutorial Andrewgosu (+rep), but, maybe explain how to use a handel vars system, as well as just storing units and integers?

I know its a weird suggestion, but, since it uses a Game Cache, it has some relevance to your tutorial.

Andrewgosu said:
//This tutorial explains how to store, move and restore information between maps.
I will not explain how to use game cache with more advanced functions in
JASS, what are used for making spells MUI. (There are spell tutorials, which
teach that already. E.g emjir3 tutorials)

Read posts :p
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
u can do it easly in photoshop just choose only the white color without the words (u do it with this wand looking tool i forgot it's name) and than delete it and u are left with only what written without the words in it

Yes. But you have to save it in gif. format and it makes the text unreadable. Thus the same background colour.

Good tutorial Andrewgosu (+rep), but, maybe explain how to use a handel vars system, as well as just storing units and integers?

I know its a weird suggestion, but, since it uses a Game Cache, it has some relevance to your tutorial.

I know handle vars use game cache, but explaining how to use them in this tutorial would be confusing for GUI users, who just want to store stuff and move them between maps. You can always ask for help in the JASS section.
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
yep i already got it's like the background color :p(look at my edit)
 

Sooda

Diversity enchants
Reaction score
318
It gives you idea how to transfer data between map A to map B with few data examples what to save/ load. Good and easy to understand/ read. everything else what you want to save should be made like in tutorial.
 

2-P

I will work hard tomorrow
Reaction score
325
Good tutorial. You could add a part about campaigns, since that's usually where you use game caches to transfer stuff.

I think transfering units between single maps can get risky when there are differences in the object data. Not sure though.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top