• 🏆 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!

Save/Load system HELP!

Status
Not open for further replies.
Level 4
Joined
Jul 5, 2009
Messages
41
I've been searching a long time in the spell section, most of them are just copy & paste spells, but what should that help when you don't understand shit about variables? I suggest you post the triggers and explain instead of letting people working at their own. PLEASE HELP! I've been working so long to get a Save/Load system, BUT NOTHING WORKS! You can't do it without variables, I KNOW! THAT'S WHY I NEED HELP :cry:!
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
...you can't do anything without variables, instead of asking for a save/load-code explanation, ask someone to explain variables.
You won't be able to create a map without using variables, I can assure you that.


BASICS:


Variables are a very easy way to store and load data,
this data cannot be removed unless you have removed it manually.

A simple example is a unit variable called "Hero" in an RPG.
You can store the hero of a player in that variable
and then you can use the variable to easily recall him.

Though that isn't the only use of variables, here are some thing I use them for:
  • Leak fixing
  • Special effects (changing the offset/degrees as well)
  • Triggered abilities
  • Every system
  • Multiboards/leaderboards
  • ... (a lot more).

There are 2 types of variables:
  • Globals (variables that can be used in every trigger over the entire map)
  • Locals (variables that are defined for a single trigger and do not exist in others).

Globals are for both JASS and GUI, but Locals are only for JASS.
You can also check the box which says "array", for storing a lot of data in an efficient way.


BASIC GLOBAL:


Now we know what a global is, we'll create one.
I am going to use a leak-fixing variable as example, so we will create a unit group variable.

Go to your trigger editor and press CTRL + B (or press the yellow 'X'-icon).
Then press CTRL + N (or press the green 'X'-icon in the varaible editor).

Variable Name: your choice (I will use "Group")
Variable Type: "Unit Group"

Leave the array and initial value as they are, that's for later ;)

Now we need to set the variable first (of course, otherwise there is no data in it)
As I've said before, it's for leak fixing, so I will do just that.

  • Trigger
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) equal to Apocalypse
    • Actions
      • Set Group = (Units in (Playable map area) owned by Player 12 (Brown))
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Custom script: call DestroyGroup(udg_Group)
Allright, I'll admit it: this is useless...
This immeadiately kills all units owned by player 12 when an ability is cast.
But it's just for the example, right?

I do not need to explain the event and condition I guess, so let's go over the actions
The first action is simple: I set the variable we've created to the data I want.
In this case, the data is "(Units in (Playable map area) owned by Player 12 (Brown))".

Then I will recall that data, which is very simple: I just need to pick the variable.
I do that with the unit group-action and then setting the standard "(Units in (Playable map area))"
to the variable "Group".

The last thing is to fix the leak, I don't know if you know how to do that.
In any case, if you want a good tutorial about leaks, you can search a leak-tutorial on the hive.


BASIC LOCAL:


NOTE: IF YOU DO NOT USE JASS, SKIP THIS PART!


Locals are a very good way to make spells MUI, since locals cannot be overwritten,
unless you overwrite it in the same trigger.
Though if the trigger runs multiple times, the local variable from the first loop can
have different data than the local from the second loop and it will not overwrite.

Maybe that doesn't explain much... well, let's just go over the rest and I'll explain
this principle throughout the rest of this part.

A local is very easy to create, you do not need the variable editor for this.
I will use this local in a useless way, but useful for the tutorial and explanation
of the MUI-part.

JASS:
function Tutorial takes nothing returns nothing
    local unit u = GetTriggerUnit()
    call TriggerSleepAction(2)
    call RemoveUnit(u)
    set u = null
endfunction

Yeah, it doesn't have any event/condition and it uses a TriggerSleepAction (a wait).
but it doesn't matter ^^ just think it activates when someone casts a spell.

Now, if 2 or more units activate this function within 2 seconds,
you would think the last one would overwrite the previous ones.
This, however is not true. All units will be removed.

For example:
a paladin casts a spell, he is now set to the variable
1 second later, an archmage casts the same spell and he is also set to the same variable
The normal logic would be that the archmage has overwritten the paladin.
This would happen in Global variables, but with locals they will both be removed.


As you can see, this is really useful and easy to set up,
but you also need to null the variables after usage, it's about the same as leak fixing.


ARRAYS:


Arrays are really useful, I will create a special effect (GUI) so you can see it yourself.
The trigger will still be easy, but it is a pretty basic effect.
In the variable editor (we're using globals again), create 1 variables:

  • Name: "Loc" (another name is also good)
  • Type: 'Point'
  • Array: 'yes'
  • Initial Value: None (standard)

  • Trigger
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) equal to Apocalypse
    • Actions
      • Set Loc[1] = (Position of (Triggering unit))
      • Special Effect - Create a special effect at Loc[1] using [Special Effect Type]
      • Special Effect - Destroy (Last created special effect)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Loc[2] = (Loc[1] offset by 256.00 towards (30.00 x (Real((Integer A)))) degrees)
          • Special Effect - Create a special effect at Loc[2] using [Special Effect Type]
          • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_Loc[1])
      • Custom script: call RemoveLocation(udg_Loc[2])
Since "point with offset" uses 2 locations, it also has 2 leaks
therefore you will need either an array, or multiple variables to fix the leaks.

The trigger creates a circle of special effects around the caster.

I know that the Integer A-loop isn't as good as Variable-loops,
but GUI is more commonly used...

Local arrays can be created like this: "local unit array u"
So the only thing you need to add is the "array", the rest stays the same.
When calling for a local array, always use the square brackets (e.g.: u[1]).
 
I've been searching a long time in the spell section, most of them are just copy & paste spells, but what should that help when you don't understand shit about variables? I suggest you post the triggers and explain instead of letting people working at their own. PLEASE HELP! I've been working so long to get a Save/Load system, BUT NOTHING WORKS! You can't do it without variables, I KNOW! THAT'S WHY I NEED HELP :cry:!

knowing variables is one of the basics of mapping/triggering.... learn it first before you complain about the spells in the spells sections...... read what apocalypse wrote for you and i hope you understand it.
 
You should realy learn the variables you dont need to learn the hole thing just a bit so you can do the most simple commands with them....If you make a TD they are important if you dont use there variables you will just get a mass spawned and probably(as in my cases)bugged/not moving and blocking the waves that have to come.
Try and find an easy spell or system that uses variables open and edit it a bit and see what you will get :D
 
Level 4
Joined
Jul 5, 2009
Messages
41
Whoaw, thanks for all the help. All these effects and stuff... whatever it helped :D. But i just can't find out a way with that helped me in my Thread? I was needing help to a Save/Load system, not some effects. However that really helped me, but that wasn't really my problem xD.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Whoaw, thanks for all the help. All these effects and stuff... whatever it helped :D. But i just can't find out a way with that helped me in my Thread? I was needing help to a Save/Load system, not some effects. However that really helped me, but that wasn't really my problem xD.
Those were just examples to teach you about variables.
Once you know how to use variables, editing the save/load system is very easy (well, editing most save/load systems, I guess the JASS-systems are a bit too complex for you right now).

Can you show me the save/load-system you are using and try to explain what isn't working and what you want to edit, those kind of things.
 
Level 4
Joined
Jul 5, 2009
Messages
41
I can tell you that i've been searching som places around... Tried anything, but still... You can't do anything without variables, i really think you can, i've both made TD's and RPG's without variables, but that isn't really my problem xD.

All i really need to know is like... Example: What do you use Integers for? And why are their Variables that has a value of "Unit-Type"? There's already a unit type in the Action tool, i've never could get use of variable shit xD. Only to drop items, and that worked, that was pretty easy though... But only because it was posted, and not explain in text :bored:
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I can tell you that i've been searching som places around... Tried anything, but still... You can't do anything without variables, i really think you can, i've both made TD's and RPG's without variables, but that isn't really my problem xD.

All i really need to know is like... Example: What do you use Integers for? And why are their Variables that has a value of "Unit-Type"? There's already a unit type in the Action tool, i've never could get use of variable shit xD. Only to drop items, and that worked, that was pretty easy though... But only because it was posted, and not explain in text :bored:
If you made TD's/RPG's without variables, I would instantly reject them if you uploaded those here.

Integer and unit type variables are very often used.
Let's take a TD: how about an integer variable that saves the lives of a player?
And a unit type variable that saves the unit type of each level?
You can make every trigger a hell lot more efficient with those.

Variables are also used for removing leaks, if you don't use variables, your map will lag.
 
Level 1
Joined
Dec 28, 2009
Messages
1
I can tell you that i've been searching som places around... Tried anything, but still... You can't do anything without variables, i really think you can, i've both made TD's and RPG's without variables, but that isn't really my problem xD.

dude r u serious?? listen to them ffs u cant make a map without learning variables -.- y dont u take the time and read what hes posted??:slp:
 
dude r u serious?? listen to them ffs u cant make a map without learning variables -.- y dont u take the time and read what hes posted??:slp:


no, you CAN make maps without variables though it would be really spammed with leaks and such and as your triggers go harder and complicated the more leaks it will create if you don't use variables... And I think if you create one without variables it would be crap...
 
Status
Not open for further replies.
Top