Beginning JASS Tutorial Series

Level 11
Joined
Oct 13, 2005
Messages
233
Is anything happening? Do enemy units take damage? In the code you posted, the unit will not appear to move because all the moving and damage is done instantly. There needs to be a delay between each attack in order to see the movement of the caster. If enemies are not taking any damage, then you might have the wrong spell id or there could be other issues.
 
Level 10
Joined
Jan 24, 2009
Messages
606
well... They are taking Damage.... The hero is not moving that is it:) so I must use some kind of wait or??

One more thing.... My code is just like urs! (the spell in the torturial code) So i can't really see why the Unit is not moving!
 
What is the difference between Local and Global variables?
-Local variables are variables only usable by the function they’re declared in. These are used for cleaning Memory Leaks (which will be explained later), neatening code, and making script Multi-instanceable.
-Globals are variables which can be accessed by any function, but can also be changed by any function. This can be bad for multi-instanceability (which will now be referred to as MUI), depending. MUI will be discussed later on.

i dont know wat *multi-instanceability* is ... does it mean exectue several actions at once? ... and what's the difference between actions and function? i mean they both perform ... an action. I'm kindda stuck on lesson 2 been reading it for couple hours and my brain hurts so i decided to ask :D

and im gonna list a few more questions i got
1)
How do I create a local variable?
-There are two ways to creating/setting a variable.
function variable_test takes nothing returns nothing
local unit u = CreateUnit()
endfunction
This method creates and sets it in one line, at the beginning of the function.
which of these is the variable? is it the *unit*? or is it the *u*? and what does it mean when u set *local unit u = createunit()*? does it mean there will be a unit created and this created unit's name is *u*? sorry i just never had a single programing class all my life

2)
function variable_test takes nothing returns nothing
local unit u
set u = CreateUnit(…..) //Creates a unit and sets the variable to it
endfunction
And this method creates a blank variable, to be set later on in the function.
uhm... whats this *…..*? is it the name of a unit (after u press ctr+d? cuz i didn't see any number or non-letter-symbols when i pressed ctr+d. like pally is Hpal)?

i have a lot more questions but plz answer these 1st so i can continue
ty
 
Level 10
Joined
Jan 24, 2009
Messages
606
i dont know wat *multi-instanceability* is ... does it mean exectue several actions at once? ... and what's the difference between actions and function? i mean they both perform ... an action. I'm kindda stuck on lesson 2 been reading it for couple hours and my brain hurts so i decided to ask :D

and im gonna list a few more questions i got
1)
which of these is the variable? is it the *unit*? or is it the *u*? and what does it mean when u set *local unit u = createunit()*? does it mean there will be a unit created and this created unit's name is *u*? sorry i just never had a single programing class all my life

2)
uhm... whats this *…..*? is it the name of a unit (after u press ctr+d? cuz i didn't see any number or non-letter-symbols when i pressed ctr+d. like pally is Hpal)?

i have a lot more questions but plz answer these 1st so i can continue
ty

Answer Question 1: The Variable Type is Unit and The Name of the Variable Is U so to use the "set" thing it woud need to be set u = GetTriggerUnit() So I hope that Answered your question:p


Answer Question 2: Paladin's Code is Hpal So u shoud have gotten that one Right:p


I hope this Helped you... If not just send me A PM and i will try answering it Better:p
 
Level 16
Joined
Oct 10, 2009
Messages
1,425
function variable_test takes nothing returns nothing
local unit u
set u = CreateUnit(hpea)
endfunction

what is wrong with that?
it says too few arguments.
what does that mean?
sorry im a noob when it comes to JASS
 
Level 12
Joined
Aug 31, 2008
Messages
1,121
^^
Well it is probably gonna say too few arguments, because there is.
Get Jasscraft (Google it and find it Wc3c) and it'll definitely help you know what arguments functions have to take.
For instance, he used that function as an example, just to keep it simpe. In reality that function also needs a x and y value to be supplied to the function, because it need coorinates to place the unit on.
 
Level 10
Joined
Jan 24, 2009
Messages
606
function variable_test takes nothing returns nothing
local unit u
set u = CreateUnit(hpea)
endfunction

what is wrong with that?
it says too few arguments.
what does that mean?
sorry im a noob when it comes to JASS

it should look like this set u = CreateUnit(Player(0-11), 'hpea', 12., 13., 31)

But if you wanne have it Create a new unit it's CreateNUnit(Integer Count, Integer Unit ID, Player which player,location which location, real face)

Looking like this
JASS:
CreateNUnitsAtLoc(12,'hpea', Player(0), GetUnitLoc(u), 45.)
 
Level 11
Joined
Oct 13, 2005
Messages
233
function variable_test takes nothing returns nothing
local unit u
set u = CreateUnit(hpea)
endfunction

what is wrong with that?
it says too few arguments.
what does that mean?
sorry im a noob when it comes to JASS
Too few arguments means that you're not supplying enough information to the function you're trying to call. Here's the function declaration for CreateUnit:
JASS:
native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit
And here's an example of using it:
JASS:
set myUnit = CreateUnit(Player(0), 'hpea', 0., 0., 0.)
// Will create a peasant for Player Red at the center of the map facing to the right. (0 degrees = right, 90 = up, 180 = left, etc.)
I hope that helps.
 
Level 5
Joined
Sep 29, 2008
Messages
171
Thanks so much. Zypher suggested I start to learn JASS as GUI was pissing me off with refusing to do what I wanted it to do involving a certain proc DoT, and this seems oddly familiar. Is JASS based off another programming language? I learned a tiny bit of C scripting making maps in other games, and I hope this tutorial gently kicks me into the world of good triggers (no more unnecessary microstuns, hopefully)
 
Level 2
Joined
May 14, 2010
Messages
12
Hello wyrmlord. When i tried to do 1st "homework". I copied the JASS function and pasted it in my world editor, but when i tried to start the map it just went directly to warcraft3 start menu. ( battle.net , single player etc.) i also did the trigger : when player red presses arrow key down (custom script) call HelloWorld(). please help me, i really wanna learn JASS and i cant make myself continue before i fixed this :sad:
 

sentrywiz

S

sentrywiz

Hi. Great tutorial for the most part. I got to the omnislash spell and I can say I learned lot. However I have remarks about it:

1. You don't declare all variables that you use. On three or more occasions I was given "undeclared variable" error from JassCraft. Here are the variables that gave me that error:

- gg_trg_slash
- temp_loc
- BlinkEffect

You set them but don't declare them anywhere in the code. Also the final code doesn't show them.

2. The special effect part of the tutorial is not well explained. I am confused what to use and where to use it.

I'd appreciate if you can show how you did it.

3. The spell you showed doesn't fully work. Its buggy at best, the loop runs once or twice, at random. And sometimes it doesn't even deal damage.

The unit moves once at random location and kills 0 - 5 units at random. Not sure where the spell goes wrong but it does.
 
Last edited by a moderator:

Dr Super Good

Spell Reviewer
Level 62
Joined
Jan 18, 2005
Messages
27,004
i just understand the call BJDebugMsg ("HI")
It is running the function "BJDebugMsg" passing it the string "HI" for its parameter. That function looks like...
JASS:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction
So when run it calls the native function "DisplayTimedTextToPlayer" with a string value of "HI" that is repeated for every player.

Not that much different from getting a GUI trigger to run another GUI trigger after placing a value in a global variable. The difference comes from the higher performance and use of the stack when calling a function rather than creating a new thread and heap (global) usage for running another trigger in GUI.
 
Level 3
Joined
Apr 5, 2016
Messages
21
It is running the function "BJDebugMsg" passing it the string "HI" for its parameter. That function looks like...
JASS:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction
So when run it calls the native function "DisplayTimedTextToPlayer" with a string value of "HI" that is repeated for every player.

Not that much different from getting a GUI trigger to run another GUI trigger after placing a value in a global variable. The difference comes from the higher performance and use of the stack when calling a function rather than creating a new thread and heap (global) usage for running another trigger in GUI.

i know still im stuck at function takes nothing return nothing
 

Dr Super Good

Spell Reviewer
Level 62
Joined
Jan 18, 2005
Messages
27,004
i know still im stuck at function takes nothing return nothing
That is the function signature. Types a function take make up the function parameters that are passed to the function when it is called. The single type a function returns is what type the function can be treated as when using it as an argument. To understand what function parameters, return type and such mean then look up practically any programming resource as it is a common feature of a lot of programming languages.
 
Level 3
Joined
Mar 8, 2017
Messages
77
Hello I want put flame effects around my buildings but my buildings are tree from night elves and when my buildings move. I want to use jass, triggers to stop the flame effects. Besides, when the trees come back to take root the flame effect doesn't appears again. I want solve it.
How can I use the jass for solve this?
 
Level 3
Joined
Mar 8, 2017
Messages
77
Where is this?:
Click on the map icon at the top of the list of triggers


I'm in Trigger Editor

Somebody can show me a picture of world editor and indicate where is the map icon? Thanks

By the way I'm using "jass newgen pack official"
 

Attachments

  • upload_2017-9-4_23-58-14.png
    upload_2017-9-4_23-58-14.png
    55.6 KB · Views: 203
Last edited:
Level 4
Joined
Jun 21, 2009
Messages
107
Hello,

I'm going over the tutorial and its been very helpful. I had a question that I couldn't figure out. In the section where you are going over how to do create omnislash, where do you write the actual code inside the WE?
I know its in the trigger editor but is it in the initialization folder or scroll icon thing that all triggers connect to? How do I know where to write the code?

Thanks
 
Level 4
Joined
Jun 21, 2009
Messages
107
Usually one creates a trigger and then use one of the menu options to convert it to custom script.

Right, but I am more asking about the difference of putting your code in a custom script trigger VS the entire map. What I mean by that is, when you open your trigger editor there is a "master" trigger with the "map" icon. This trigger usually has the name of the map. What kind of code goes into that trigger vs regular custom scripts?

In the spell example done in this tutorial, where does he write ALL of that code for omnislash, is it all in a singular custom script trigger?
 

Dr Super Good

Spell Reviewer
Level 62
Joined
Jan 18, 2005
Messages
27,004
The "master trigger" is the script header. That will appear above all other script.

It used to be the only way to force script to the top of the map script. However I think now the triggers are built in the order they appear (not created) so might no longer be necessary.

The main reason not to use it is for organization. You can put nice names next to each piece of script instead of a huge monolithic block of text. Additionally custom script triggers allow one to run code on map initialization, something the header does not without stepping into vJASS features.
 
Level 4
Joined
Jun 21, 2009
Messages
107
The "master trigger" is the script header. That will appear above all other script.

It used to be the only way to force script to the top of the map script. However I think now the triggers are built in the order they appear (not created) so might no longer be necessary.

The main reason not to use it is for organization. You can put nice names next to each piece of script instead of a huge monolithic block of text. Additionally custom script triggers allow one to run code on map initialization, something the header does not without stepping into vJASS features.
Okay, so there is no issue with putting all your JASS code in their own separate triggers? In my limited coding experience, typically function definitions and global variable definitions go at the "top" of your code. For WE/JASS, function definitions and global variables can be defined in their respective triggers, correct?
 
Top