• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Whats the difference between JASS and vJASS ?

Status
Not open for further replies.
vJASS is a user-made extension to normal JASS to make JASS coders' lives easier. It requires jasshelper in order to write the code/save it in the editor (which is included in JassNewGenPack, check our tools section), but it compiles into normal JASS so that you can run it with the normal wc3.

vJASS essentially adds features. One main feature is global declaration--it makes it very easy for us to create globals without using the variables editor. It also allows for ordering scripts (so you can make one script require another), and encapsulation (so you can have functions with the same name without conflict). There are a whole slew of other features:
http://www.wc3c.net/vexorian/jasshelpermanual.html

Usually, if you are using GUI, you won't need to touch vJASS at all unless you want to use someone else's script in your map. If you are learning JASS, it is usually best to get JassNewGenPack and learn vJASS, as it will make your life a lot easier.
 
Another key feature of vJass is that it is object oriented. What this means is that if you want to script some behavior for a car, you create a "car" object and define some variables and behaviors which it will be using. For instance, you could give it variables such as "speed" and "actor" (the unit representing your car, i usually just name it "u"), and behaviors (methods) such as "accelerate" (which increases speed by 5 every second), "enter driver" and "exit driver" (which maybe activates/deactivates the car). Whenever you create a new car, you will be able to manipulate it using these methods and change these variables for it.

Another feature is that you can keep some parts of your code secret from the other parts (wait, what?). The reason you would want to do this is that sometimes when having large amounts of code, or if you are using other peoples resources, there might be variable or function names which have the same names, and hence are conflicting. You can fix this by making sure certain parts of your code only has access to the things they need, and nothing more. Kind of a "need to know basis", lol.

In regular JASS, you have a more linear approach. Functions and variables don't belong to any specific object, and most code has to be run from some kind of trigger. All global variables have to be declared in the variable editor, which is a bit cumbersome.
 
Level 6
Joined
Jan 4, 2014
Messages
227
@Fingolfin , can you add includes like in C++ ( external libraries for JASS or vJASS ), if yes whats the best place for those libraries ??
 
@Fingolfin , can you add includes like in C++ ( external libraries for JASS or vJASS ), if yes whats the best place for those libraries ??

Yes. We have plenty of libraries in our JASS Section, and implementing it is as easy as copy and pasting it into a trigger. To "include" it in your code, simply add "requires":
JASS:
library MyCode requires SomeExternalLibrary, SomeOtherLibrary
    // your code
endlibrary

Wrapping your code in a "library" block will move that code to the top of the map script, but below any libraries that are listed as requirements. In the example above, it would be placed below both "SomeExternalLibrary" and "SomeOtherLibrary".

This is a very useful feature for JASS, because normally you would have to put things in the map header in order to use it in other triggers. Library blocks allow you to put code in individual triggers and use it anywhere (as long as you list it as a requirement).
 
You can also add an initialization function to the library which will set up the neccesary stuff automatically. Example:

JASS:
library myLibrary initializer Init

globals
    private integer array playerScore
endglobals

private function Init takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i > 11
        set playerScore[i] = 0
        set i = i+1
    endloop
endfunction

endlibrary
 
Status
Not open for further replies.
Top