• 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.

What the hell are these things ?

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
Hi
I am an JASS amateur. you can say I just understand the syntax

In many spells and systems, I find requirements be :
- Units Indexer ...
- Libraries ...

And some other things lel.

I've read their descriptions, I still don't know their usefulness

Anyone who gives a brief definition for them is kewjl lel, I mean I will appreciate his help :D
 
Functions in jass have only access to functions that are placed above after compilation.

JASS:
function A takes nothing returns nothing
    call B()    //won't work
endfunction

function B takes nothing returns nothing
    call A()    // works
endfunction

So if you make a system that should work for all functions you must ensure that it gets above them all. How? --> library (library is a vJass feature, not jass)


JASS:
library Test

    function A takes nothing returns nothing
    endfunction

endlibrary
Now all functions have access to function A.

So a library is just a collection of code that is useable by all non-library code, because library compiled code is placed above.

But in case library A needs access to functions from library B, you have to use the requires keyword to ensure correct compilation:
JASS:
library A requires B

    function a takes nothing returns nothing
        call b()
    endfunction

endlibrary
JASS:
library B

    function b takes nothing returns nothing
    endfunction

endlibrary

UnitIndexer is just an example for a useful library. It gives an unit specific index for each existing unit, so you can directly work with it.
And that's the sense of libraries. They should include useful code that just gets imported and then can be used easily. We don't want to create each system from scratch for each new project so we import libraries to make life more simple.

You can read more:
http://www.hiveworkshop.com/forums/tutorial-submission-283/simple-jass-tutorial-beginners-251698/
http://www.wc3c.net/vexorian/jasshelpermanual.html#lib
 
Status
Not open for further replies.
Top