Timer won't stop

MissKerrigan

Active Member
Reaction score
23
Hey I create a trigger: 'destroy timer' but the timer still keeps counting
Does anybody knows what's going on here?

MissKerrigan

(omg, spend 2 hours yesterday to change 2 little things in the editor!!)
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
please when you have any kind of trigger problems with something you have already attempted, do this:
[noparse]
Trigger:
  • right click it, copy as text, and past it in these wc3 tags
[/noparse]
 

MissKerrigan

Active Member
Reaction score
23
In the start of the game I create repeating a timer every 60 seconds countdown

Wave 50 is the last wave, so I create the trigger:

event: wave 50 starts

condition: none

action: destroy timer window 'last created timer' (can't select other timers here)

In the game the timer still keeps counting down from 60 seconds
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
(Last created timer window) doesn't work between triggers. In that trigger, there is no last created timer since you haven't created a timer in that trigger.

Therefore it destroys no timer window. So how do we fix this?

Well, first of all you need a global variable of the Timer Window type. Then go into the trigger where you first create your timer window and create the action "Set variable" below it. Set your timer window variable to the Last created timer window. This will work since in this trigger, you have created a timer window so in this case (Last created timer window) actually refers to something.

Then you go into the trigger where you want to destroy the timer. Change (Last created timer window) to your global variable.

You said you can't select other timers there. That's because you're only looking at functions. There's preset, variable and custom script as well.

In this case, since we saved our timer in a variable, we want to go to the variable tab and pick your global variable.

I hope this helps.

Edit: Changed timer to timer window. My bad. thanks for pointing it out Dave.
 

Dave312

Censored for your safe viewing
Reaction score
269
Just to clarify, the action you are trying to use destroys a timer window not a timer. As such, you are only able to select a parameter of the type Timer Window not Timer. Most likely you will still want to destroy the timer window so do what Siretu said but change the variable to the type Timer Window.

Even after you destroy the timer window, the timer will continue to run (you just won't be able to see it on screen). Use the Pause/Unpause Timer action to stop the timer from running.
 

MissKerrigan

Active Member
Reaction score
23
I don't understand anything about global variables
For me it's even more difficult than soccer! haha

but I already got it!
I made a trigger which is just only the timer
And in the 'wave 50' trigger I simple turned off the timer trigger

MissKerrigan
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Do you know what a variable is?

In each trigger there are several parts. Events, Conditions, Local variables and Actions. I assume you know how events, conditions and actions work.

A variable is a place where you can store data. If I have a string variable, I can store a string in it. Let's say I store the string "foo" in my variable x. Then every time I want to get the string "foo", I could just refer to the variable x.

You can store other things as well such as timers and integers and a lot of other things.

You can create a variable in two places, locally in your trigger and globally. What's the difference? Well, local variables can only be used inside that specific trigger. No other triggers can see them.

A local variable is created in local variables in your trigger. A global variable is created in the list to the left where all your triggers are.

You can create a variable by right clicking in the right place(either in your trigger to make a local one or in the list to the left to make a global one) and selecting New > New Variable. You can also click ctrl+b.

When you create the variable, you get to choose a name. The name can be changed later on by right-clicking and pressing rename. The only thing you have to worry about in the variable for right now is the part that says "Type". That is where you change the type.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
global variables are basically a form of storing data to be used in triggers, they can save almost anything from unit groups to numbers to strings to players and they can have indexes or save multiple pieces of data for a specific set of integer values ie: (variable[1-10]) every number from 1 to 10 can hold its own unique data of one type for that variable
 

Sevion

The DIY Ninja
Reaction score
413
A variable is something that stores either data or an address pointing to data.

A variable that stores the address pointing to data is known in the Object Oriented Programming (OOP) world as a Pointer.

Pointers don't exist in Galaxy/StarCraft II GUI, so we'll just stick to explaining variables that store data.

Basically variables are like a cardboard box. You make your variable, shove some data in, and later you can use the data inside of it.

I can make a unit variable (a cardboard box that only holds objects of type unit) and shove a Zergling into there. Now I have a cardboard box with a Zergling in it (a specific Zergling in this case).

Later on, I can open that box and pull out that Zergling and say "Oh, in this box, there is Zergling #51895."

With that, I can use Zergling #51895 for whatever I want. I.E. Killing it. Calling a kill event on that variable will kill Zergling #51895.

I can also pull Zergling #51895 out and put say..... Marine #8715 into it.

Now the cardboard box (the variable) holds Marine #8715 and I can do whatever I want to Marine #8715 by referencing the variable.

You can also put "NULL" into it. That is, in effect, pulling Marine #8715 out and putting nothing, "NULL", into it.

That, in essence, is what a variable is.

To understand scope, you only need to really know three different things:

Static, Global, and Local.

Locals are only usable in their respective functions.

Globals are usable everywhere.

Statics are only usable in the Galaxy file they're declared in (don't need to worry about this unless you're using advanced Galaxy programming like in my tutorial here).
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293

MissKerrigan

Active Member
Reaction score
23
well I tried few things but I still don't understand grrr

Well I'm a dutch girly so for me it's hard to understand this

I know a variable is something to store things but I don't understand the following thinig:


If I create a variable 'unit type' Jim Raynor I can use this later in trigger, I know

But why does starcraft not make values of units so I just can select Jim Raynor in the trigger actions

Example:

Event: 'unit enters region' (only possible to set this on 'any unit')

Condition: none

Action: 'kill unit in region' (they must make a value of all units here so you just can select the unit you want instead of this stupid variables)


Well, it doesn't matter actually, I already made a few maps without variables

MissKerrigan
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you could use variables if you wanted to do the same thing with other unit types; IE:

spawning units in the middle of the map

every 5 seconds you create a unit type of variable_X at the center of the map

every time you do this you change the unit typ of variable_X

60 seconds in you now have 12 unique units
 

Sevion

The DIY Ninja
Reaction score
413
I'm not sure what you mean by "must use a variable".

You can select preplaced units in actions and conditions. You can also use units through event responses (I.E> Triggering Unit).

And in your example you can use specific unit-types. You don't have to use a variable.

In my experience, variables make just about everything a lot easier, but you don't have to use them.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
The reason you can't use your unit-type variable in those actions is because they take a unit variable.

A unit is not the same thing as a unit-type. They're two different variable types.

One metaphor for this would be cars. A specific car model is a unit-type while MY car is a unit. Does this make more sense?

So if you wanted to use "Unit enters region", you would use any unit and then a condition that looks like: "(Unit type of (Triggering Unit)) == Jim Raynor"

If you want to kill a unit in a region, how would the trigger know what unit to kill? Do you want to kill a random one? There's a function that picks a random unit in a region.
 
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