Nestharus
o-o
- Reaction score
- 84
Note to reader
If there is a link in a chapter, like Comments or Variables or Functions, then you should click that link and read everything on that page. Those links are there for a reason. Each link contains an extremely good description to the concept =). Without reading what's on those links, you might get lost. The links are a part of this guide =P.
In Progress
Chapter 1- The Basics
Chapter 2- Exploring the Trigger Editor
Chapter 3+ Requires vJASS and cJASS
Required code-
Chapter 3- Comments and Semicolons
Chapter 4- Variables and Code Blocks
Chapter 5- Variable Operations
Chapter 6- Functions
Chapter 7- Local Variables
Chapter 8- Scope
To put it more simply, a scope is like a category. Scopes don't return anything or take anything, they are just blocks of code that are placed into a category like putting files into a folder.
[ljass]scope Boo {}[/ljass]
Scopes may also be written with the customary endtype keyword (JASS)
Scopes may also have what is called an [ljass]initializer[/ljass] . Initializers run a function when the map starts up. The function is not allowed to have any parameters and cannot return a value. An initializer requires the function.
That would call Hi at the start of the map.
Nested scopes, or scopes that are inside of other scopes, may not have initializers.
Scopes may also go into global blocks
The above would be the same thing as this-
Convention
Chapter 9- Natives
Chapter 10- Includes
Chapter 11- printf
Chapter 12- null
Chapter 13- Arrays
Chapter 14- Handles
Chapter 15- code variables
If there is a link in a chapter, like Comments or Variables or Functions, then you should click that link and read everything on that page. Those links are there for a reason. Each link contains an extremely good description to the concept =). Without reading what's on those links, you might get lost. The links are a part of this guide =P.
In Progress
Chapter 1- The Basics
The World Editor
Installing the necessary ToolsThe World Editor is a program used to create maps for Warcraft 3. The program has seven primary tools for map making:
1. The Object Editor (units, items, destructables, doodads, abilities, buffs/effects, upgrades)
2. The Sound Editor
3. The Campaign Editor
4. AI Editor
5. Object Manager
6. Import Manager
7. Terrain Editor
8. Trigger Editor
It also includes advanced tools for modifying gameplay constants and the interface under the advanced drop down menu.
The purpose of this guide is to only explain the Trigger Editor and the languages used for it: JASS, vJASS, and cJASS.
First, let's install the necessary components for you to take full advantage of World Editor.
vJASS
vJASS installation should take place first.
Download and open up the attached zip file.
You should see a single folder in there. Click the folder once to select it and then rename it to jassnewgenpack. Click extract and put it into your Warcraft 3 directory.
Default Paths:
32 Bit- C:\Program Files\Warcraft III
64 Bit- C:\Program Files (x86)\Warcraft III
Jass Helper (Required)
Download and open Jass Helper. The file is in .7z format.
First click the jasshelper folder in the file.
---------------------------------------------------------------------
Jass Helper should be extracted to the Jass Helper Folder of your Warcraft 3 directory
Default Paths:
32 Bit- C:\Program Files\Warcraft III\jassnewgenpack\jasshelper
64 Bit- C:\Program Files (x86)\Warcraft III\jassnewgenpack\jasshelper
Now move the executable folder in jasshelper. First open up explorer by right clicking the start menu in the bottom left corner of your computer screen and then clicking explore.
Navigate to your Warcraft 3 Jasshelper directory.
Default Paths:
32 Bit- C:\Program Files\Warcraft III\jassnewgenpack\jasshelper\executable
64 Bit- C:\Program Files (x86)\Warcraft III\jassnewgenpack\jasshelper\executable
Double click the executable folder to go inside. Hold CTRL + A to select all of its contents. CTRL + X.
Hit backspace. Hit CTRL + V. If it prompts you about move and replace, hit move and replace ^_^.
Congratulations, you have just installed vJASS and updated it to the latest version ^_^.
cJASS
cJASS Manual
Download the Installer
Run it.
Hit next, and then hit next again. You will see a path. Paste in your Warcraft 3 JassNewGen directory
Default Paths:
32 Bit- C:\Program Files\Warcraft III\jassnewgenpack
64 Bit- C:\Program Files (x86)\Warcraft III\jassnewgenpack
Then hit install.
cJASS includes an auto updater so you should never have to download it again. The JassNewGen Pack (vJASS) and JassHelper will have to be downloaded again on new versions. JassNewGen pack isn't always updated to the latest JassHelper, so that is why both should be downloaded. Always be sure to check for new versions of those.
Getting to NewGen World Editor
To enable vJASS and cJASS, you will have to use the NewGen World Editor. It can be found in your Wacraft 3 directory.
Navigate to your Warcraft 3 Jass NewGen directory and find an exe named NewGen WE (or similar). Right click it and click Create Short Cut.
Hit CTRL + X and then hit WINDOWS KEY + D.
You should now be at your desktop. Hit CTRL + V and you should see the shortcut you made appear on the desktop.
You should now have all the tools you need to proceed.
Everything after this assumes that you have NewGen World Editor open and that you are working on a new map from topic to topic. There is also required code that will be shown after Chapter 2. Sometimes it will ask you to save your map so that you can open it later on.
To make a new map-
Then just hit ok
To run the map-
First CTRL + S or hit the save icon
Then CTRL + F9 or hit the Test Map Icon
Description
The Trigger Editor is used to write script for maps. Most aspects of Map Creation take place in the Trigger Editor.
How To Get To It
There are two ways to open up the trigger editor. The first way is by hitting F4.
The second way is by clicking the Trigger Editor icon (which looks like an a).
Trigger Editor Overview
When initially entering the trigger editor, you will see this-
The area on the left is where the code areas, or more commonly referred to as triggers, go.
Melee Initialization would be a trigger. When clicking on a trigger, the code area on the right displays what's inside of the trigger.
This trigger is in what is called GUI Format. GUI stands for Graphical User Interface.
Also, if you look above the trigger, you will see a comment area.
The comment area is limited in its capacity, but is great for quick notes. Do not use these areas for documentation.
The folder called Initialization is a category, which can be used to organize the code. Categories can be expanded and contracted by double clicking them.
Teaching Map.w3m would be the custom map script, which is really pointless to use and has a few bugs. It was originally there for plain JASS. Click Teaching Map.w3m (or whatever your map name is) to see what the custom code area looks like.
Right clicking on Teaching Map.w3c will allow you to create new categories.
Right clicking on a category will allow you to create new categories and triggers.
Right clicking on a trigger will allow you to create new categories, triggers, or trigger comments.
To delete triggers, trigger comments, and categories, simply select them and hit the delete key.
GUI Variables can be accessed by hitting CTRL + G. You can also access them by clicking the GUI Variables Icon.
Trigger Comments
Trigger comments are normally used for writing documentation. I suggest you never use these and instead use what are called comments. Comments will be taught at a later point, but trigger comments are really only for Vanilla Warcraft 3 (the default Blizzard Wc3). The reason is that they will automatically make the map that it's inside of a TFT Map (The Frozen Throne Expansion Pack), which lowers its accessibility. There are still many ROC (Reign of Chaos, or regular Warcraft 3) users out there.
Try making a new trigger comment
Trigger comments are pretty much like notepad (start -> run -> notepad), except that you can't use the tab key in them.
GUI In A Nutshell
GUI is like going through a series of menus. It's time consuming, it's slower than plain JASS, and reading it can be a serious chore.
There are three parts of a Trigger.
Events- what makes the trigger run. An event might be something like a unit casts a spell.
Conditions- what must be true for the event to fire. Let's say the spell has to be Life Drain.
Actions- what is done when the trigger is fired if all the conditions are true. Let's say that a spell was cast and it was indeed Life Drain.
To add new events, conditions, or actions, right click the trigger, events, conditions, actions, or any item.
Right clicking trigger
Right clicking an item
To copy text like this-
right click and hit copy as text.
Trigger Copy As Text- Copies entire trigger like above
Event Copy As Text- Copies all events
Condition Copy As Text- Copies all conditions
Action Copy As Text- Copies all actions
Item Copy As Text- Copies Item
*item copy as text output*
To create and view GUI variables, open the Variable List. Any variable made there will be accessible by GUI.
Converting a Trigger to JASS
To convert a trigger to JASS, click the trigger, click on edit, and then click Convert to Custom Text
The Melee Map trigger should now look like this
From this point onwards, images will only be used to show in-game results. Everything from here on will be JASS, vJASS, and cJASS.
The Trigger Editor is used to write script for maps. Most aspects of Map Creation take place in the Trigger Editor.
How To Get To It
There are two ways to open up the trigger editor. The first way is by hitting F4.
The second way is by clicking the Trigger Editor icon (which looks like an a).
Trigger Editor Overview
When initially entering the trigger editor, you will see this-
The area on the left is where the code areas, or more commonly referred to as triggers, go.
Melee Initialization would be a trigger. When clicking on a trigger, the code area on the right displays what's inside of the trigger.
This trigger is in what is called GUI Format. GUI stands for Graphical User Interface.
Also, if you look above the trigger, you will see a comment area.
The comment area is limited in its capacity, but is great for quick notes. Do not use these areas for documentation.
The folder called Initialization is a category, which can be used to organize the code. Categories can be expanded and contracted by double clicking them.
Teaching Map.w3m would be the custom map script, which is really pointless to use and has a few bugs. It was originally there for plain JASS. Click Teaching Map.w3m (or whatever your map name is) to see what the custom code area looks like.
Right clicking on Teaching Map.w3c will allow you to create new categories.
Right clicking on a category will allow you to create new categories and triggers.
Right clicking on a trigger will allow you to create new categories, triggers, or trigger comments.
To delete triggers, trigger comments, and categories, simply select them and hit the delete key.
GUI Variables can be accessed by hitting CTRL + G. You can also access them by clicking the GUI Variables Icon.
Trigger Comments
Trigger comments are normally used for writing documentation. I suggest you never use these and instead use what are called comments. Comments will be taught at a later point, but trigger comments are really only for Vanilla Warcraft 3 (the default Blizzard Wc3). The reason is that they will automatically make the map that it's inside of a TFT Map (The Frozen Throne Expansion Pack), which lowers its accessibility. There are still many ROC (Reign of Chaos, or regular Warcraft 3) users out there.
Try making a new trigger comment
Trigger comments are pretty much like notepad (start -> run -> notepad), except that you can't use the tab key in them.
GUI In A Nutshell
GUI is like going through a series of menus. It's time consuming, it's slower than plain JASS, and reading it can be a serious chore.
There are three parts of a Trigger.
Events- what makes the trigger run. An event might be something like a unit casts a spell.
Conditions- what must be true for the event to fire. Let's say the spell has to be Life Drain.
Actions- what is done when the trigger is fired if all the conditions are true. Let's say that a spell was cast and it was indeed Life Drain.
To add new events, conditions, or actions, right click the trigger, events, conditions, actions, or any item.
Right clicking trigger
Right clicking an item
To copy text like this-
Trigger:
- Melee Initialization
- Events
- Map initialization
- Conditions
- Actions
- Melee Game - Use melee time of day (for all players)
- Melee Game - Limit Heroes to 1 per Hero-type (for all players)
- Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
- Melee Game - Set starting resources (for all players)
- Melee Game - Remove creeps and critters from used start locations (for all players)
- Melee Game - Create starting units (for all players)
- Melee Game - Run melee AI scripts (for computer players)
- Melee Game - Enforce victory/defeat conditions (for all players)
- Events
right click and hit copy as text.
Trigger Copy As Text- Copies entire trigger like above
Event Copy As Text- Copies all events
Condition Copy As Text- Copies all conditions
Action Copy As Text- Copies all actions
Item Copy As Text- Copies Item
*item copy as text output*
Trigger:
- Melee Game - Remove creeps and critters from used start locations (for all players)
To create and view GUI variables, open the Variable List. Any variable made there will be accessible by GUI.
Converting a Trigger to JASS
To convert a trigger to JASS, click the trigger, click on edit, and then click Convert to Custom Text
The Melee Map trigger should now look like this
From this point onwards, images will only be used to show in-game results. Everything from here on will be JASS, vJASS, and cJASS.
Required code-
JASS:
//paste this into a jass trigger
include "cj_types.j"
include "cj_typesEx.j"
include "cj_types_priv.j"
include "cj_typesEx_priv.j"
include "cj_order.j"
include "cj_antibj_base.j"
include "cj_print.j"
Chapter 3- Comments and Semicolons
Comments
Comments
Semicolons
Comments
In essence, comments are like little notes.
Single Line Comment- [ljass]//[/ljass]
Delimited Comment (multiple lines)- [ljass]/*code*/[/ljass]
Exercises
Paste the code into the map and then comment it out to get rid of the syntax error.
Problem 1
Comment me to get rid of the syntax error
Problem 2
I am
your
syntax error
yes, you will
not stop
me at all
Semicolons
Semicolons represent a new line in programming. You can either split up lines with an enter like this-
or with a semicolon
;
You may only have one semicolon after or in between code though (unless it is a comment). Semicolons really allow you to write a bundle of code all on the same line. They are really only useful for what are called variable declarations as you will see in the next chapter. Any other use of them only results in convoluted code.
As you begin programming, the use of semicolons will become more apparent. In just about all cases you do not need one.
Chapter 4- Variables and Code Blocks
What is a Variable?
The Pieces of a Variable
Variable Type
The World of JASS Variables
Variable Names
Primitive Types
Declaring A Variable
Code Blocks
The Pieces of a Variable
Each variable has two parts: a type and a name
The type describes what the variable contains. The name is the name of the variable, or how it is identified.
Let's say that you get a new dog. The name of your new dog is Shilo
Now let's say you also get a new desktop. Your desktop is a Gamer Xtreme XT
You can't describe your new dog as a desktop. A dog just isn't a desktop. You can't turn it on and play games or program or whatever else that that you do with a desktop.
You can't describe your new desktop as a dog. A desktop just isn't a dog. If you try to play fetch with it, things will probably go badly.
These are what are known as types. Shilo is a dog and Gamer Xtreme XT is a desktop. Shilo is the name of the dog and Gamer Xtreme XT is the name of the desktop.
Variable Type
dog -> Shilo
desktop -> Gamer Xtreme XT
This would be pretty accurate
pet -> dog -> Shilo
computer -> desktop -> Gamer Xtreme XT
This would also be accurate. A dog can be described as a pet and the dog's name can be Shilo. A desktop can be described as a computer and the desktop could be the Gamer Xtreme XT
Let's say you also got a laptop-
computer -> laptop -> Xplorer X8-8800
That's a pretty sweet laptop huh? The laptop can be described as a computer and that laptop could be an Xplorer X8-8800. Luck you.
So what if we had this?
computer -> Gamer Xtreme XT
computer -> Xplorer X8-8800
Well, can Gamer Xtreme XT be described as a computer? What about an Xplorer X8-8800?
A desktop is a type of computer and so is a laptop, so both could be described as a computer. The problem is that a computer could be described as either a desktop or a laptop.
If you were just given that information, how would you be able to tell if a Gamer Xtreme XT was a laptop or a desktop? You couldn't.
What this means is that while something described as laptop or a desktop can be described as a computer, the computer cannot be described as either a destop or a laptop because there's no way to tell what the computer is. It could be either or.
The World of JASS Variables
In JASS, there are two main types of variables. There are variables that store things directly: numbers and words, and there are variables that point to complicated things: a dog tag pointing to a dog.
The two main types of variables are called primitives and handles.
Primitives are so named because they hold very simple values like the word "dog" or the number 6. Handles are named because they handle and point to very complicated values, like an actual dog or a whole hospital.
Variable Names
Let's say you now have another dog and you decided to name it Shilo as well.
dog1 -> Shilo
dog2 -> Shilo
You call out Shilo but both of them come. Why? They both have the same name. Things can't have the same name, otherwise there's
no way to get something unique out of it.
If you were to have a friend named Shilo that you had named your dog after-
friend -> Shilo
dog -> Shilo
And you called out, "hey Shilo, get over here." They'd still both come. Even if the type is different, the names have to be unique.
Primitive Types
JASS:
Counterparts (these mean the same thing as the above, they are just written differently)
JASS:int //integer float //real string //still string bool //boolean
So you can do-
integer or int
real or float
string
boolean or bool
They will do the exact same thing.
Declaring A Variable
The word declare is just a fancy way of saying, "I'm writing this variable out for the first time." It's sort of like when I said you have a new dog.
To declare a variable, you just write it out:
[ljass]variable[/ljass]
But wait! Remember variables have two parts: a type and a name. This variable only has one of those two parts. To fix it, why not give it a name from one of the primitive types?
[ljass]int variable[/ljass]
Much better.
Because I'm just so creative with names
JASS:float number string hi bool has
Variables of the same type can also be declared on the same line in a comma separated list-
[ljass]int x, y, z[/ljass]
This would be the same code as-
JASS:int x int y int z
If you want different types, a semicolon is used to split it up into different lines
[ljass]int x, y, z; float h, n; string i[/ljass]
JASS:int x int y int z float h float n string i
When declaring a variable in the map plainly, it is what is known as a global variable. A global variable is a variable that exists for the entire game. When you think global, think of a term like global warming. Global Warming exists for the entire planet.
A global variable can be accessed from anywhere.
[ljass]int x //a global declaration[/ljass]
Code Blocks
The Globals Block (deprecated)A block of code is just a set of code that's put into a container. All blocks of code have a start and a finish. Traditionally, the start and finish for a block of code is blockName { } (curly brackets). This is true for all code blocks. All blocks of code in programming have to have a start and a finish.
All blocks of code can have unlimited lines-
JASS:blockName { }
You can have as many blocks of code as you like-
JASS:blockName {} blockName {} blockName { } blockName { }
The most common way of writing a code block is-
JASS:blockName { }
Generalized notes on a block of code are generally written on the second curly bracket with a single line comment.
JASS:blockName { } //notes on the block
With plain JASS, the block of code is the blockName endBlockName. This is true for all plain JASS code.
JASS:blockName endBlockName
With the plain JASS code block, notes are generally written above the block-
JASS://notes blockName endBlockName
Naming ConventionA globals block is just a block of code used to declare globals. This is no longer required, but you should know what it is so that you can recognize it when reading someone else's code.
The globals block name is globals-
JASS:globals { }
JASS:globals endglobals
A globals block in action:
JASS:globals int i endglobals
Only variables can go into global blocks, so this isn't valid-
JASS:globals { globals { } }
Variables are named lowercase first with camelcasing-
helloHello
The Order of Operations
Recognize these: + - * /
Those are all operators.
Recognize this: ()
This is used for grouping
3 + 4 * 5
Following the order of operations:
4 * 5 = 20
20 + 3 = 23
If you did this-
(3 + 4) * 5
Following the order of operations:
3 + 4 = 7
7 * 5 = 35
An operator is just something that is used to manipulate something else.
In each case, the value being changed was manipulated by the operator.
The = operator sets the thing on the left to the thing on the right. The = operator isn't like it is in mathematics. Remember, all operators manipulate or retrieve a value. = does both (gets value from right) (sets value on left to the rerieved value on right)
So the above examples would now be-
But this still isn't ready. You can't set a literal value (40 opposed to x).
And that would work. In plain JASS, the deprecated set keyword is used (makes it easier to see)
Remember, the left side is always being set to the right side so the set keyword works well.
Operations of Types
Initialization
Shortcut Operations
Recognize these: + - * /
Those are all operators.
Recognize this: ()
This is used for grouping
3 + 4 * 5
Following the order of operations:
4 * 5 = 20
20 + 3 = 23
If you did this-
(3 + 4) * 5
Following the order of operations:
3 + 4 = 7
7 * 5 = 35
An operator is just something that is used to manipulate something else.
Code:
Adding 4 to 5 will change 5 to 9
Subtracting 1 from 9 will change 9 to 8
Multiplying 8 by 5 will change 8 to 40
Dividing 40 by 8 will change 40 to 5
In each case, the value being changed was manipulated by the operator.
The = operator sets the thing on the left to the thing on the right. The = operator isn't like it is in mathematics. Remember, all operators manipulate or retrieve a value. = does both (gets value from right) (sets value on left to the rerieved value on right)
So the above examples would now be-
JASS:
5 = 4 + 5 //The value on the right is 9, 9 is set to the value on the left, so 5 is now 9
9 = 9 - 1 //The value on the right is 8, 8 is set to the value on the left, so 9 is now 8
8 = 8 * 5 //The value on the right is 40, 40 is set to the value on the left, so 8 is now 40
40 = 40 / 8 //The value on the right is 5, 5 is set to the value on the left, so 40 is now 5
But this still isn't ready. You can't set a literal value (40 opposed to x).
JASS:
x = 5 //x is now 5
x = x + 4 //(9) //5+4
x = x - 1 //(8) //9-1
x = x * 5 //(40) //8*5
x = x / 8 //(5) //40/8
And that would work. In plain JASS, the deprecated set keyword is used (makes it easier to see)
JASS:
set x = 5
set x = x + 4 //(9)
set x = x - 1 //(8)
set x = x * 5 //(40)
set x = x / 8 //(5)
Remember, the left side is always being set to the right side so the set keyword works well.
Operations of Types
Integers-
Integers can only be whole numbers-
JASS:int x = 15 //remember, you can use either the int or integer keyword
Integers work with these operators with other integers (+, -, *, /)
An integer may not be set to a real (=)
Reals-
Reals can be whole numbers or fractional numbers-
JASS:float x = 15 //remember, you can use either the float or real keyword real y = 16.111
Reals work with these operators with other integers and reals (+, -, *, /, =)
Booleans-
Booleans can only be boolean values-
JASS:boolean b = true bool c = false //remember, you can use either the boolean or bool keyword
Booleans only work with one generic operator (=)
Strings-
Strings can only be string values. String values start and end with double quotes (" ") or (` `) (top left of your keyboard under escape)
The " " is a standard string. The ` ` takes the literal text in the string and wraps " " around it. It pretty much always does the same thing as a string. The times when it does not do the same thing are when you wrap up definitions, which will be covered later.
Strings may be added to other strings and may be set to other strings (+, =)
Initialization
Initialization is the first time a variable gets a value.
[ljass]x = 0[/ljass]
Variables may be initialized in their declaration
[ljass]int x = 16[/ljass]
A variable that isn't initialized cannot be used.
JASS:int x int y = x
While that may be syntactically correct (no syntax error), it will result in an immediate termination of the code. The map won't crash, but nothing past the usage of the variable will occur.
JASS:int x x = x + 1
That would not work either. The reason is x still does not have a value.
JASS:int x = 0 int x = x + 1
That would work.
Shortcut Operations
++ and --
+=, -=, /=, *=++ stands for +1 and -- stands for -1
After
BeforeWhenever ++ or -- are used after the variable, their operations are done after where they are used.
JASS:int x = 0 x++
x++ would translate into
[ljass]x = x + 1[/ljass]
So x would now equal one.
JASS:int x = 0 x--
x-- would translate into
[ljass]x = x - 1[/ljass]
So x would now equal -1.
JASS:int x = 16 int b = x--
Because -- is after the x, the operation is done after it is used.
b would be 16, x would be 15.
JASS:int x = 16 int b = x x = x - 1 //after the operation
JASS:int x = 16 int b = x++
Because ++ is after the x, the operation is done after it is used.
b would be 16, x would be 17
JASS:int x = 16 int b = x x = x + 1 //after the operation
Whenever ++ or -- are used before the variable, their operations are done before where they are used.
JASS:int x = 0 ++x
++x would translate into
[ljass]x = x + 1[/ljass]
So x would now equal one.
JASS:int x = 0 --x
--x would translate into
[ljass]x = x - 1[/ljass]
So x would now equal -1.
JASS:int x = 16 int b = --x
Because -- is before the x, the operation is done before it is used.
b would be 15, x would be 15.
JASS:int x = 16 int b x = x - 1 //before the operation b = x
JASS:int x = 16 int b = ++x
Because ++ is before the x, it is done before it is used.
b would be 17, x would be 17
JASS:int x = 16 int b x = x + 1 //before the operation b = x
[ljass]x += 3[/ljass]
[ljass]x = x + 3[/ljass]
[ljass]x -= 3[/ljass]
[ljass]x = x - 3[/ljass]
[ljass]x /= 3[/ljass]
[ljass]x = x / 3[/ljass]
[ljass]x *= 3[/ljass]
[ljass]x = x * 3[/ljass]
What is a Function?
Basic Overview of a Function
Creating Functions in JASS
Basic Overview of a Function
A function can be thought of like a procedure with a number of steps, like the steps you have to take for turning on a computer.
The procedure would be the task of turning on the computer
The steps would be-
Step 1- Hit computer power button
Step 2- Hit monitor power button
or
Turn On The Computer {
Step 1. Hit computer power button
Step 2. Hit monitor power button
}
A procedure can have any amount of steps, even 0.
You can input things into a procedure, like maybe a laptop instead.
laptop -> Turn On The Computer {
Step 1. Hit the laptop power button
Step 2. Hit the laptop monitor button (if it has a monitor button)
}
And the procedure can ouput a state. Turning on the computer would output the state computer is on
computer -> Turn On The Computer {
Step 1. Hit the laptop power button
Step 2. Hit the laptop monitor button (if it has a monitor button)
} -> Computer Is On
What about an add procudure, like in a calculator?
Only has one step and takes two values-
value1, value2 -> Add {
Step 1. value1+value2
} -> Sum
And returning a specific value?
value1, value2 -> Add {
Step 1. value1+value2 ->
} -> Sum
Creating Functions in JASS
Naming ConventionWhen looking at a function, they look almost like variables, except that they have 4 parts.
Part 1: The return type (the type of the output)
Part 2: The name (the name of the function)
So far it's looking just like a variable-
[ljass]int MyFunction //this would return an integer[/ljass]
Part 3: Arguments () (the input)
[ljass]int MyFunction()[/ljass]
Part 4: Code Block {} (the steps)
[ljass]int MyFunction() {}[/ljass]
That would be a totally empty function that returned an integer. Code in the block is just plain code-
JASS:int x = 15 int y = 16 int MyFunction() { x += y //x is now 31, 15+16 }
A function that returns something (the ->) always has to return that something. MyFunction would have to return an integer. If a function that returns a type does not return something, it causes a syntax error (if you try to save it, the trigger editor will complain).
To return a value, the return keyword is used.
JASS:int MyFunction() { return 0 }
And now MyFunction returns 0 : o.
The last line of a function that returns something always has to be a return. When a return is used, it returns to whatever called it with a special package: the value!
Functions cannot go into functions, that makes no sense... could you put the procudure of Baking Cookies into the procedure of Turning on a Computer? No. Steps go in and procedures call other procedures and that is it.
JASS:int MyFunction() { int MyOtherFunction() //what the hell?? Syntax Error!! { return 0 } return 0 }
Functions can also be treated like variables in a sense (except that they have the () for parameters), so if you wanted to set a variable to this-
[ljass]x = MyFunction() //when setting variables to variables, do you use the type? No. Do you use the internal stuff? No[/ljass]
So, let's go over this real fast again-
[ljass]int myVar //will always return an integer when it is used. Doesn't take any arguments because it is a variable[/ljass]
[ljass]int MyFunc() //will always return an integer when it is used. Can take arguments because it is a function, so requires ()[/ljass]
Functions are defined after globals, so a global variable cannot be initialized to a function.
JASS:int MyFunction() {return 0} int x = MyFunction() //syntax error!!
Also, because MyFunction in this case returns an integer, it can only be set to integers and reals. Could you set a string variable to an integer variable? No.
Can functions be set to something? No. You can set a set of steps to something.
Finally, you don't even have to set a function to a variable to use it, you can just do this-
[ljass]MyFunction() //runs the function[/ljass]
Yea, it still returns a value, but the value isn't used or set to anything, which is totally legit.
Each parameter, like a variable, needs a name and a type. Just like procedures, they are separated by commas. The parameters themselves look like little variable declarations. Parameters cannot be initialized.
[ljass]int MyFunction(int x) {return 0} //this takes an integer now[/ljass]
[ljass]int MyFunction(int x = 0) {return 0} //Parameters cannot be initialized!! They are plugged in! Error[/ljass]
And multiple parameters
[ljass]int MyFunction(int x, int y) {return 0} //comma separated list[/ljass]
And different types
[ljass]int MyFunction(int x, bool c, string helloHello, real hi) {return 0} //total freedom to declare whatever you want[/ljass]
You always have to have the type for each argument-
[ljass]int MyFunction(int x, y, z) {return 0} //Error![/ljass]
The parameters of the function can be used inside of the function just like regular variables. They can be set, returned, and whatever.
JASS:int MyFunc(int x) { x = x + 5 return x + 5 //x is now x + 10, if you plugged in 5, 15 would be returned }
To input values into a function, plug them into the arguments list (). When a parameter variable is operated on in a function and changed, the actual variable outside of the function is not changed.
JASS:int MyFunc(int x) { x = x + 5 return x + 5 //x is now x + 10. 9 was plugged in, so 19 would be returned } int MyFunc2() { int x = 9 MyFunc(x) //x is still 9 return 0 }
It would be changed in this case though, but only because it is set to the result
JASS:int MyFunc(int x) { x = x + 5 return x + 5 } int MyFunc2() { int y = 9 y = MyFunc(y) //they don't have to be the same names MyFunc(6) //anything can be plugged in, even regular values return 0 }
Multiple Types and multiple parameters?
JASS:int z = 0 int MyFunc(int x, int y, int z, string h) { return x + y + z } int MyFunc2() { z = MyFunc(z, 5, 16, "") //set z to z + 5 + 16, or 21 z = MyFunc(16, 9, 20, "") //set z to 16+9+20, or 45 return 0 }
Notice that all parameters have to be passed in even if they are empty. String h wasn't used because typecasting hasn't been covered yet ^_^.
You can do multiple returns but you can only return one type and one value. If you were to do mutiple returns, you could, but only the very first return would go.
JASS:int MyFunc() { return 0 return 16 }
This would return 0 and not 16. The use will become apparent later on, but for now this feature is pretty useless.
If you want to make a function that returns nothing, that is totally possible with the void keyword-
JASS:void MyFunc() {}
Functions that return nothing can't be set to a variable because there isn't a variable that stores nothing =P.
[ljass]integer x = MyFunc() //Syntax Error[/ljass]
Only functions that return something can be set to variables.
You can still use the return keyword in a function that doesn't return anything. How does that work? You return nothing of course
JASS:void MyFunc() { return }
Also, the last line of a function that returns a value must always be a return.
JASS:int MyFunc(int x, int y, int z) { z = x + y + z return x + y + z }
JASS:int MyFunc(int x, int y, int z) { x = y z = x return z //syntax error, no return on the last line z = 16 }
JASS:int MyFunc(int x, int y, int z) { x = y z = x return z //this is what is returned z = 16 return z }//this is ok because it has a return on the last line
There is another way to write functions: the JASS way-
The returns is the type, the takes are the parameters, and instead of {}, a function and endfunction are used because the blockName is function. Hello is the name. Nothing keyword is the same as the void keyword.
Quite a mouthful, but shown so that you know what you are reading when reading most JASS code. As you can see, multiple parameters are still separated by commas, but there is no () to group them. Parameters can be used the same way.
Single values are pretty much the same way too.
The { } can't be used with the JASS function declaration-
You may not have strange hybrids like these-
or
JASS:nothing function Hello takes () end
Functions may also be called with the deprecated call keyword-
[ljass]call MyFunc()[/ljass]
The exact same thing as-
[ljass]MyFunc()[/ljass]
A lot of JASS uses the call keyword.
Functions start with an uppercase letter and are camelcase-
HelloHello
A local variable is a variable that is declared inside of a function. They can be declared just like regular variables-
They can also be declared anywhere inside of the function
You could even have this-
The reason you don't want to set a variable to a variable that isn't defined yet is because it translates from
to
Meaning slower code and more lines over all. Nifty if you really must have it, but you shouldn't do it.
You can also do some wacky things with variable declarations.
What happens is all the declarations are automatically placed at the top of the function in the order that they are declared. That code is really-
Which makes more sense. The fact is, you shouldn't write something like the first example-
[ljass]return h; int h //remember ; is a new line[/ljass]
The reason is because it makes the code really confusing to read. When you saw that first example, the first thought that went into your mind was probably: wtf?
If you wrote code like that and someone else was to read it, the first thing that would pop into their mind would also be: wtf?
They would have to stop and think for a second and go: wtf?
After a minute or two of analyzing your code and thinking, they'd then go, oh, ok. This is a total waste of time on their part ><. You should only write code that can be scanned quickly and is easy to read. If someone else has to pause for a minute and go: wtf, then you did something wrong =P.
Doing something like this-
Is not acceptable ><. Always declare all your variables at the top... that is good practice. Declaring this here and that there is not good practice and makes it that much longer for someone to understand your code. Good code is easy to read. Bad code is hard to read. Maintainability is the #1 key in coding.
Local variables may also be declared with the local keyword-
JASS:
void MyFunc()
{
int y = 42
}
They can also be declared anywhere inside of the function
JASS:
void MyFunc()
{
int z
return
int h
h = h + 1
int y
}
You could even have this-
JASS:
void MyFunc()
{
int z = h //don't do this unless you have a really good reason ><
int h
int x, y, o; string i
}
The reason you don't want to set a variable to a variable that isn't defined yet is because it translates from
JASS:
int z = h
int h
to
JASS:
int z
int h
z = h
Meaning slower code and more lines over all. Nifty if you really must have it, but you shouldn't do it.
You can also do some wacky things with variable declarations.
JASS:
int MyFunc()
{
return h
int h
}
What happens is all the declarations are automatically placed at the top of the function in the order that they are declared. That code is really-
JASS:
int MyFunc()
{
int h
return h
}
Which makes more sense. The fact is, you shouldn't write something like the first example-
[ljass]return h; int h //remember ; is a new line[/ljass]
The reason is because it makes the code really confusing to read. When you saw that first example, the first thought that went into your mind was probably: wtf?
If you wrote code like that and someone else was to read it, the first thing that would pop into their mind would also be: wtf?
They would have to stop and think for a second and go: wtf?
After a minute or two of analyzing your code and thinking, they'd then go, oh, ok. This is a total waste of time on their part ><. You should only write code that can be scanned quickly and is easy to read. If someone else has to pause for a minute and go: wtf, then you did something wrong =P.
Doing something like this-
JASS:
int MyFunc()
{
return h
int h
}
Is not acceptable ><. Always declare all your variables at the top... that is good practice. Declaring this here and that there is not good practice and makes it that much longer for someone to understand your code. Good code is easy to read. Bad code is hard to read. Maintainability is the #1 key in coding.
Local variables may also be declared with the local keyword-
JASS:
void MyFunc()
{
local int h
}
Scope is an important concept in programming languages – one cannot read or write large programs without properly understanding the concept of scope. The scope of a variable in a program is the lines of code in the program where the variable can be accessed.
To put it more simply, a scope is like a category. Scopes don't return anything or take anything, they are just blocks of code that are placed into a category like putting files into a folder.
[ljass]scope Boo {}[/ljass]
JASS:
scope Boo
{
void hi() {}
}
JASS:
scope Boo
{
int x
void oh() {}
scope Rawr
{
}
}
Scopes may also be written with the customary endtype keyword (JASS)
JASS:
scope Boo
endscope
Scopes may also have what is called an [ljass]initializer[/ljass] . Initializers run a function when the map starts up. The function is not allowed to have any parameters and cannot return a value. An initializer requires the function.
JASS:
scope Hello initializer Hi
{
void Hi()
{
}
}
That would call Hi at the start of the map.
Nested scopes, or scopes that are inside of other scopes, may not have initializers.
JASS:
scope Hello
{
scope UhOh initializer Hi //this scope is in another scope, so it can't have an initializer!!
void Hi()
{
}
endscope
}
Scopes may also go into global blocks
JASS:
globals
scope Hi
integer x
endscope
endglobals
The above would be the same thing as this-
JASS:
scope Hi
{
int x
}
Convention
Scopes start with an uppercase letter and are camelcase.
HelloHello
JASS Natives are like JASS functions except that they are written in C++, which is the programming language that JASS is built on. Natives are all premade and are included with Warcraft 3 and they may be used at any point in the map. They are defined before anything else.
Natives don't use the function keyword when being declared because they aren't functions, they're natives. The native keyword is used.
[ljass]native ClearMapMusic takes nothing returns nothing //natives are plain JASS, so C syntax, which is what you are used to, isn't used in their declaration[/ljass]
You may notice that this looks exactly like a regular function declaration except for two primary differences. The native keyword and no endnative. Natives are fully written in wc3, so they are always one liners. They have 0 JASS inside of them. Functions on the other hand are purely JASS.
Natives come from two wc3 jass files, one called common.j and the other called common.ai. The first is used for making maps and the latter is used for making ai. Things in common.j may not be accessed from ai things and stuff from common.ai may not be accessed from maps.
While you may not declare your own natives, you may declare ones that already exist and use them. In map making, all natives and what not in common.j are already and automatically declared for you, so the natives you'd want to declare are from common.ai.
Not all natives in common.ai work. Here's a list of all the working ones.
You may declare these in your map and then use them. Again, the C syntax way of declaration will not work with natives.
common.j natives and functions can be found in the Function List located in the trigger editor.
This is a function from the list. As you can tell, it looks exactly like a normal function, and it calls the ClearMapMusic native. You should rarely use these functions as it will almost always be faster to inline it, or write out the function's contents in your own function-
[ljass]ClearMapMusic() //fast[/ljass]
[ljass]ClearMapMusicBJ() //slow and moronic[/ljass]
The function list also holds all of the common.j variables. There are checkboxes for filtering out functions and there are radio buttons for viewing variables or functions/natives.
The biggest window with the actual code in it shows the function/native. The small text box on the top right can be used for search for functions/natives/variables.
Natives don't use the function keyword when being declared because they aren't functions, they're natives. The native keyword is used.
[ljass]native ClearMapMusic takes nothing returns nothing //natives are plain JASS, so C syntax, which is what you are used to, isn't used in their declaration[/ljass]
You may notice that this looks exactly like a regular function declaration except for two primary differences. The native keyword and no endnative. Natives are fully written in wc3, so they are always one liners. They have 0 JASS inside of them. Functions on the other hand are purely JASS.
Natives come from two wc3 jass files, one called common.j and the other called common.ai. The first is used for making maps and the latter is used for making ai. Things in common.j may not be accessed from ai things and stuff from common.ai may not be accessed from maps.
While you may not declare your own natives, you may declare ones that already exist and use them. In map making, all natives and what not in common.j are already and automatically declared for you, so the natives you'd want to declare are from common.ai.
Not all natives in common.ai work. Here's a list of all the working ones.
JASS:
native GetPlayerUnitTypeCount takes player p, integer unitid returns integer
native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer
native GetUnitBuildTime takes integer unitid returns integer
native CreepsOnMap takes nothing returns boolean
native UnitAlive takes unit id returns boolean
You may declare these in your map and then use them. Again, the C syntax way of declaration will not work with natives.
common.j natives and functions can be found in the Function List located in the trigger editor.
JASS:
function ClearMapMusicBJ takes nothing returns nothing
call ClearMapMusic()
endfunction
This is a function from the list. As you can tell, it looks exactly like a normal function, and it calls the ClearMapMusic native. You should rarely use these functions as it will almost always be faster to inline it, or write out the function's contents in your own function-
[ljass]ClearMapMusic() //fast[/ljass]
[ljass]ClearMapMusicBJ() //slow and moronic[/ljass]
The function list also holds all of the common.j variables. There are checkboxes for filtering out functions and there are radio buttons for viewing variables or functions/natives.
The biggest window with the actual code in it shows the function/native. The small text box on the top right can be used for search for functions/natives/variables.
Includes allows you to include external JASS files. There is one directory where the tool searches for included files: [JNGP path]\AdicHelper\lib. Another option is to provide an absolute path: "d:\..."
In other words, it looks inside of your JassNewGenPack directory inside of the AdicHelper folder inside of the lib folder or it looks in a path you designate.
To include a file, the include keyword is used followed by the follow the file (string format).
[ljass]include ""[/ljass]
There are 7 jass files that come with cJASS so far that you should always include in your maps.
These will be covered later in the guide. For now, just know that they are all there.
A JASS File is just a text file with .j extension. They can be created in notepad or you can use WE to write out some text, cnp it into a text file, and then change the extension after saving it.
There are also very good JASS Editors out there. The most widely known one is JassCraft
Try out jasscraft and write out some plain jass to see what a jass file is like. To get an idea for how includes works, try including the file using the direct path method. To get the path of the file, right click it and click on properties and then cnp the path. Try using a variable you declared in the file or a function.
In other words, it looks inside of your JassNewGenPack directory inside of the AdicHelper folder inside of the lib folder or it looks in a path you designate.
To include a file, the include keyword is used followed by the follow the file (string format).
[ljass]include ""[/ljass]
There are 7 jass files that come with cJASS so far that you should always include in your maps.
JASS:
include "cj_types.j"
include "cj_typesEx.j"
include "cj_print.j"
include "cj_types_priv.j"
include "cj_typesEx_priv.j"
include "cj_order.j"
include "cj_antibj_base.j"
These will be covered later in the guide. For now, just know that they are all there.
A JASS File is just a text file with .j extension. They can be created in notepad or you can use WE to write out some text, cnp it into a text file, and then change the extension after saving it.
There are also very good JASS Editors out there. The most widely known one is JassCraft
Try out jasscraft and write out some plain jass to see what a jass file is like. To get an idea for how includes works, try including the file using the direct path method. To get the path of the file, right click it and click on properties and then cnp the path. Try using a variable you declared in the file or a function.
This displays text to all players in the game.
[ljass]printf("string")[/ljass]
Now try out some of the stuff you've been learning.
ex:
This will display Hello World!
[ljass]printf("string")[/ljass]
JASS:
scope Hello initializer Hi
{
void Hi()
{
printf("hello")
}
}
Now try out some of the stuff you've been learning.
ex:
JASS:
This will display Hello World!
The null keyword undefines a pointer. To undefine something is to make it equal to nothing. The variable remains initialized, but it has no value. Because it can only be used on pointers, only handles and strings qualify.
Strings are a primitive type? Not quite... they are pointers as well. In Warcraft 3, there is a huge string table in the background. As a new string is made, it is added to the table and all uses of that string point to the value in the table. Once a string value is added, it can never be removed from the table. In this way, new strings can be quite slow, but uses of already made strings are quite fast. Also, because strings are never removed, they take up memory, meaning each new string increases the amount of memory Warcraft 3 (your map) uses. Strings are extremely small, so you shouldn't worry about this.
null is primarily used to clean up memory. When nothing points to a piece of memory, that memory is removed, meaning Warcraft 3's (your map's) memory usage goes down. When a piece of memory is no longer used, it is called a memory leak. So, in essence, handles can be cleaned up in memory, but not strings. This means that setting a string to null serves no purpose if you aren't planning to use the string again. Setting a handle to null is a requirement if you aren't planning to use that handle again.
Strings are a primitive type? Not quite... they are pointers as well. In Warcraft 3, there is a huge string table in the background. As a new string is made, it is added to the table and all uses of that string point to the value in the table. Once a string value is added, it can never be removed from the table. In this way, new strings can be quite slow, but uses of already made strings are quite fast. Also, because strings are never removed, they take up memory, meaning each new string increases the amount of memory Warcraft 3 (your map) uses. Strings are extremely small, so you shouldn't worry about this.
JASS:
string myString = "hi"
myString = null
null is primarily used to clean up memory. When nothing points to a piece of memory, that memory is removed, meaning Warcraft 3's (your map's) memory usage goes down. When a piece of memory is no longer used, it is called a memory leak. So, in essence, handles can be cleaned up in memory, but not strings. This means that setting a string to null serves no purpose if you aren't planning to use the string again. Setting a handle to null is a requirement if you aren't planning to use that handle again.
Arrays are variables with multiple slots. To make a variable into an array, the array keyword is used inside of the declaration
[ljass]int x[][/ljass]
In plain JASS
[ljass]int array x[/ljass]
Notice array is the second keyword. Array is sort of like a subtype.
Arrays cannot be initialized to a value.
[ljass]integer x[] = 0 //syntax error![/ljass]
But all slots on all arrays are automatically initialized to a default value-
Arrays require an index whenever they are used. The index is accessed using brackets [ ]. Arrays may contain indexes from 0 to 8191. Keep in mind that the 8191 and 0 indexex are buggy as they will not work when loading a saved game. It is safest to use 1 thru 8190. If you don't plan on saved games, then use 0 and 8191 to your heart's content. Keep in mind that the 8192 number comes from an array size of 8kb.
Exercises
[ljass]int x[][/ljass]
In plain JASS
[ljass]int array x[/ljass]
Notice array is the second keyword. Array is sort of like a subtype.
Arrays cannot be initialized to a value.
[ljass]integer x[] = 0 //syntax error![/ljass]
But all slots on all arrays are automatically initialized to a default value-
JASS:
integers: 0
reals: 0.0
booleans: false
all pointers: null //(a string null is "", so you can do string s; printf(s+"hi"))
JASS:
int x[] //every element in the array is initialized to 0 because it is an array
Arrays require an index whenever they are used. The index is accessed using brackets [ ]. Arrays may contain indexes from 0 to 8191. Keep in mind that the 8191 and 0 indexex are buggy as they will not work when loading a saved game. It is safest to use 1 thru 8190. If you don't plan on saved games, then use 0 and 8191 to your heart's content. Keep in mind that the 8192 number comes from an array size of 8kb.
JASS:
void Ha()
{
int x[]
x = 0 //bad, will result in a syntax error
}
JASS:
void Ha()
{
int x[]
x[0] = 0 //good
x[5000] = 50 //good
}
Exercises
Create a global integer array with a variable called x. Make a function that
sets index 0 to 50, index 50 to 25, index 25 to 75, and index 75 to 100. After
the variables are set, get to index 100 without using it and set it to 95. Be
sure to display the output to test.
Handles are pointers to complicated data structures in the background, like units and items.
Pointer------Data
1 -------> Unit
2 -------> Unit
3 -------> Item
The most basic handle is the primitive handle type. The second most basic is the agent handle (not a primitive).
When a handle is defined, the type keyword is used followed by the handle's name. Keep in mind that all Warcraft 3 handles are already defined for you. You cannot define your own handles unless you actually write C++ code to handle them.
[ljass]type agent[/ljass]
There are many different types of handle variables. They extend off of each other like branches on a tree. The handle type can be thought of as the base of the base of a tree while everything else can be thought of as branches. The agent handle is like a really really big branch =P.
When a handle extends another handle, the extends keyword is used followed by the handle to be extended-
[ljass]type agent extends handle[/ljass]
In this case, agent extends handle.
An extending handle may always be stored into the handle being extended (agent goes into handle), but an extended handle may not go into the handle extending it (handle does not go into agent). This rule applies to every handle down the line-
Unit goes into widget, agent, or handle.
Widget goes into agent of handle
Agent goes into handle
Handle cannot go into agent, widget, or unit
Agent cannot go into widget or unit
Widget cannot go into unit
[ljass]type widget extends agent[/ljass]
------------------------------------------------
[ljass]local widget w[/ljass]
[ljass]local agent a = w //widget goes into agent, good[/ljass]
[ljass]local agent a[/ljass]
[ljass]local widget w = a //agent goes into widget, not good[/ljass]
[ljass]type unit extends widget[/ljass]
------------------------------------------------
[ljass]local unit u[/ljass]
[ljass]local widget w = u //unit goes into widget, good[/ljass]
[ljass]local widget w[/ljass]
[ljass]local unit u = w //widget goes into unit, not good[/ljass]
Most handles within warcraft 3 that are used in map making extend off of the agent handle.
List of Handles
Pointer------Data
1 -------> Unit
2 -------> Unit
3 -------> Item
The most basic handle is the primitive handle type. The second most basic is the agent handle (not a primitive).
When a handle is defined, the type keyword is used followed by the handle's name. Keep in mind that all Warcraft 3 handles are already defined for you. You cannot define your own handles unless you actually write C++ code to handle them.
[ljass]type agent[/ljass]
There are many different types of handle variables. They extend off of each other like branches on a tree. The handle type can be thought of as the base of the base of a tree while everything else can be thought of as branches. The agent handle is like a really really big branch =P.
When a handle extends another handle, the extends keyword is used followed by the handle to be extended-
[ljass]type agent extends handle[/ljass]
In this case, agent extends handle.
An extending handle may always be stored into the handle being extended (agent goes into handle), but an extended handle may not go into the handle extending it (handle does not go into agent). This rule applies to every handle down the line-
Unit goes into widget, agent, or handle.
Widget goes into agent of handle
Agent goes into handle
Handle cannot go into agent, widget, or unit
Agent cannot go into widget or unit
Widget cannot go into unit
[ljass]type widget extends agent[/ljass]
------------------------------------------------
[ljass]local widget w[/ljass]
[ljass]local agent a = w //widget goes into agent, good[/ljass]
[ljass]local agent a[/ljass]
[ljass]local widget w = a //agent goes into widget, not good[/ljass]
[ljass]type unit extends widget[/ljass]
------------------------------------------------
[ljass]local unit u[/ljass]
[ljass]local widget w = u //unit goes into widget, good[/ljass]
[ljass]local widget w[/ljass]
[ljass]local unit u = w //widget goes into unit, not good[/ljass]
Most handles within warcraft 3 that are used in map making extend off of the agent handle.
List of Handles
JASS:
type agent extends handle // all reference counted objects
type event extends agent // a reference to an event registration
type player extends agent // a single player reference
type widget extends agent // an interactive game object with life
type unit extends widget // a single unit reference
type destructable extends widget
type item extends widget
type ability extends agent
type buff extends ability
type force extends agent
type group extends agent
type trigger extends agent
type triggercondition extends agent
type triggeraction extends handle
type timer extends agent
type location extends agent
type region extends agent
type rect extends agent
type boolexpr extends agent
type sound extends agent
type conditionfunc extends boolexpr
type filterfunc extends boolexpr
type unitpool extends handle
type itempool extends handle
type race extends handle
type alliancetype extends handle
type racepreference extends handle
type gamestate extends handle
type igamestate extends gamestate
type fgamestate extends gamestate
type playerstate extends handle
type playerscore extends handle
type playergameresult extends handle
type unitstate extends handle
type aidifficulty extends handle
type eventid extends handle
type gameevent extends eventid
type playerevent extends eventid
type playerunitevent extends eventid
type unitevent extends eventid
type limitop extends eventid
type widgetevent extends eventid
type dialogevent extends eventid
type unittype extends handle
type gamespeed extends handle
type gamedifficulty extends handle
type gametype extends handle
type mapflag extends handle
type mapvisibility extends handle
type mapsetting extends handle
type mapdensity extends handle
type mapcontrol extends handle
type playerslotstate extends handle
type volumegroup extends handle
type camerafield extends handle
type camerasetup extends handle
type playercolor extends handle
type placement extends handle
type startlocprio extends handle
type raritycontrol extends handle
type blendmode extends handle
type texmapflags extends handle
type effect extends agent
type effecttype extends handle
type weathereffect extends handle
type terraindeformation extends handle
type fogstate extends handle
type fogmodifier extends agent
type dialog extends agent
type button extends agent
type quest extends agent
type questitem extends agent
type defeatcondition extends agent
type timerdialog extends agent
type leaderboard extends agent
type multiboard extends agent
type multiboarditem extends agent
type trackable extends agent
type gamecache extends agent
type version extends handle
type itemtype extends handle
type texttag extends handle
type attacktype extends handle
type damagetype extends handle
type weapontype extends handle
type soundtype extends handle
type lightning extends handle
type pathingtype extends handle
type image extends handle
type ubersplat extends handle
type hashtable extends agent
A code variable is a variable that can store a function. Code variables may only be global, and as they are global, they can not be initialized to functions as variables are made before functions. The reason code variables cannot be local is because they refer to the actual machine code in the background. Machine code cannot be dynamically generated. Code variables cannot be arrays.
The type of the code variable is code.
[ljass]code codeVar[/ljass]
To pass functions in as values, treat them like a variable. The type would be function and the name would be the name the function has.
[ljass]function Hello[/ljass]
[ljass]code c = function Hello[/ljass]
You cannot call code variables.
The type of the code variable is code.
[ljass]code codeVar[/ljass]
To pass functions in as values, treat them like a variable. The type would be function and the name would be the name the function has.
[ljass]function Hello[/ljass]
[ljass]code c = function Hello[/ljass]
JASS:
You cannot call code variables.