HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to use game cache

04-05-2006, 11:48 PM#1
Immoralis
how do you use game cache?, i heard it can store locals.
04-06-2006, 12:06 AM#2
karukef
I wouldn't say that "gamecache can store locals".

Rather, gamecache can store pretty much any values you want to.

It is a way to dynamically store and retreive variables.

You can for example tell the gamecache to store an integer named "some_integer" and then later retreive it.

If you make a global variable of type gamecache named "cache" then you can do the following (in jass, but the same functions exist for gui):

//Store a value
call StoreInteger(udg_cache, "some_category", "some_label", 100)
//Retreive it
set some_integer = GetStoredInteger(udg_cache, "some_category", "some_label")

There is a lot of powerful things you can do with this kind of variable storage. It is for example possible to convert any object into a string so you can basically do:

//NOT REAL CODE
call StoreInteger(udg_cache, some_timer, "unit", some_unit)

This is what is known as handle-vars or more accurately, attachable variables.

The exact process of doing this has been explained elsewhere and you should seek it out on this forum if it interests you. Or, just ask any other specific questions, and someone will surely give you a good answer.
04-06-2006, 11:59 AM#3
Chuckle_Brother
Just a quick thing to note. For F3 you should research tables(Vex has a massive readme in the CS), this is because the map already has the tables present in the map(the generic damage and the shooting system).
04-10-2006, 02:56 AM#4
knutz
What about saving and loading?

Saw some natives:
SaveGameCacheBJ
InitGameCacheBJ

Do these save and load caches to disk? If so, can you load a cache that another map has saved?
04-10-2006, 07:13 AM#5
Anitarf
Yes, you can, that's how hero transfers work in blizz campaigns. You can only do it in single player, though.
04-10-2006, 07:55 AM#6
PerfectlyInsane
K here is some GUI from the map Mechcraft.. I have no idea if it work or not.. infact I've only taken alook at the triggers havent tried it yet. From the looks of things this is a multiplayer map where people can load their mechs from cache.. But from the incomplete load triggers I assume it didnt work in the end.. lol

Trigger:
create cache
Collapse Events
Map initialization
Conditions
Collapse Actions
Game Cache - Create a game cache from Galactic Warriors Craft v 0.99.w3v
Set cmechstorage = (Last created game cache)
Game Cache - Save cmechstorage

Trigger:
store mech
Collapse Events
Player - Player 1 (Red) types a chat message containing -store as An exact match
Player - Player 2 (Blue) types a chat message containing -store as An exact match
Player - Player 3 (Teal) types a chat message containing -store as An exact match
Player - Player 4 (Purple) types a chat message containing -store as An exact match
Player - Player 5 (Yellow) types a chat message containing -store as An exact match
Player - Player 6 (Orange) types a chat message containing -store as An exact match
Player - Player 7 (Green) types a chat message containing -store as An exact match
Player - Player 8 (Pink) types a chat message containing -store as An exact match
Player - Player 9 (Gray) types a chat message containing -store as An exact match
Player - Player 10 (Light Blue) types a chat message containing -store as An exact match
Conditions
Collapse Actions
Unit Group - Pick every unit in (Units currently selected by (Triggering player)) and do (Game Cache - Store (Picked unit) as ((String(icacheunits)) + 3) of Mech in cmechstorage)
Set icacheunits = (icacheunits + 3)
Set scacheunit = (String(icacheunits))
Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: (The Stored Mech's Code is: + (String(icacheunits)))
Game Cache - Save cmechstorage


Trigger:
load mech
Collapse Events
Player - Player 1 (Red) types a chat message containing (-load + last) as An exact match
Conditions
Collapse Actions
Game Cache - Restore (String(icacheunits)) of Mech from cmechstorage for (Triggering player) at (Random point in boss area cleared exit <gen>) facing 270.00
Camera - Pan camera for (Triggering player) to (Center of boss area cleared exit <gen>) over 0.00 seconds
04-10-2006, 07:07 PM#7
Blade.dk
You can't load from gamecache in multiplayer.