• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help with variables

Status
Not open for further replies.
Level 2
Joined
Nov 9, 2013
Messages
10
I created a variable WNES as data type integer to store numbers.

I'm trying to set up a trigger that will do the following:

Event: A unit enters Region 001
Action: This is the part I'm having problems with. In "Action Type" I select "Game Cache". From the drop down list below it, I then select "Store Integer". That's when it gets confusing. The area beneath it then reads...

Store Value as Label of Category in (Last created game cache).

I click on Value, select the radio button for Value at the bottom and enter the number I want to store... in this case "1".

What do I put into the remaining three sections of the formula? What goes in "Label"? What goes in "Category"? And do I leave "Last created game cache" as it is?

Thanks.
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
Actions => Set variable => pick your variable => set it to a value. Boom.


Game Cache can be used to save variables from map to map like if you were playing a campaign, you likely wont be using it.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
Just to make sure:
You do know that Game Caches are used mostly when you want to save something and load it in different map, right? Is this what you want to do? (e.g. in official blizz campaign, you level up your hero, find some items, then you finish map, the next one starts and there is your hero - with the same level and items as it had at the end of the previous map. That is done through Game Caches).

If you just want to save an integer into a variable and use it later in the map, then it is done through different action (under -General => Set Variable).

As for your question:
If you really want to know how to save integer in game cache, look in the hidden tab:

First you need to create a "Game Cache"-type variable which you will use instead of "Last created Game Cache".
Then you need to create the Game Cache, assign the variable to last created Game Cache.
e.g.
  • Actions
    • Game Cache - Create a game cache from MapName.w3v
    • Set Game_Cache_var = (Last created game cache)
Now it is prepared and you can save things in it.
I think that the 3 parameters - "Value", "Label" and "Category" are more for you than for anything else.
In value you write the value of the integer.
As Label, I think it's just how you will name this integer.
Category is simply a category => for example "Ability levels" etc.
e.g.
  • Game Cache - Store (Level of Acid Bomb for *some unit*) as AcidBomb of Spells in Game_Cache_var
Now when you load next map and load things from game cache, you can give correct level of Acid Bomb to your unit by loading the label "AcidBomb" from Spells category.

The category may be needed for clearing things I think - for example you load all your spells, so then you clear the "Spells" category (= you delete all integers and labels in that category)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
What do I put into the remaining three sections of the formula? What goes in "Label"? What goes in "Category"? And do I leave "Last created game cache" as it is?
This is not the action you want. You want "Set variable". Game caches are something entirely different, which is why they have more than the 2 fields you expect.

A game cache is used for singleplayer persistence. It defines a named object that can store values using a compound key of 2 strings.

I advise reading other people's code to get an understanding of how GUI works. If you know some programing languages already, skip GUI entirely and go to JASS as that is far easier to understand in that case.
 
Level 2
Joined
Nov 9, 2013
Messages
10
Thanks for the info, guys. I'm not sure if cache is what I should be using, and by the sound of things it looks like I'm in the wrong place.

There are two things I need to do...

A) store a number in a variable using the Actions part of a trigger, and

B) read the number in a variable using the Conditions part of other triggers. One trigger fires if X = 1, another trigger fires if X = 2, etc.

I know how to create a variable, set its type to integer, and give it a name. But when I'm trying to store a number into that variable in the Actions part of a trigger, I do not see "Set Variable" or anything like that from the drop down list of choices.

In the other triggers that need to reference the variable, I don't know what to select in the Conditions drop down menu either.

These aren't variables that can simply be set during game design. I want to be able to have triggers store and change the variables during game play, and have other triggers read them in their conditions.

Any help would be great. Thanks, guys.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
It is in there :)
Actions like "wait", "For loop integer" and of course "Set variable" can be found under the "-General" tab in the action list.
Pressing "S" key like Maker wrote is the easiest way (unless you have your WE in different language in which case it may be different)
 
Level 2
Joined
Nov 9, 2013
Messages
10
Right on, thanks Nichilus. It even has If/Then/Else and For/Next Loops. I guess they call them For Each. I rely on all these heavily in Visual Basic. It sure opens up a lot of possibilities.

I'm working on an assembly-line-style mining and logging map. It'll be crude, but should be fun.
 
Status
Not open for further replies.
Top