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!
Libraries are compiled before scopes. Usually spells require external functions like knockback, damage detection or unit indexer. So you would call some functions from other resources from the spell's code. Now if the systems are libraries and your spell is a library, it is not guaranteed that your spell is compiled first, and the function calls will fail as the called functions aren't compiled yet. If your spell is a scope, then the libraries are coded before that.
but on the other hand, the other comment was good.
Scopes and libraries allows you to use keyword private for globals or scopes within libraries or functions, making it easier to code because you dont need to remember which name you used where.
With prefix private, you can have global unit variable of name trigunit in all spells and it will not collide
Libraries are mostly used as systems or pieces of code that must be callable from anywhere from the code. You cant say where exactly will Scope with your spell be placed, but you can exactly say that library will be right below globals(and struct constructors/deconstructors/onDestroys[muhaha]) so you know you can call functions from libraries from anywhere
another good thing about libraries, as maker pointed out, is the advantage of keyword uses/requires
This makes, so that if you have Library A and Library B requires Library A, the library A will always be above Library B.
(There is also keyword optional, which means you dont really need the library)
Last but not least good feature of libraries/scopes is initializer
if you use keyword initializer, you can make custom functions that will run when map is loading without using the horrible InitTrig keyword
for instance:
JASS:
scope AA initializer init
private function init takes nothing returns nothing
endfunction
endscope
you can also have scope in scope
JASS:
scope A
scope B
endscope
endscope
JASS:
library AAD initializer init requires AAA, AAB, optional AAC
private function init takes nothing returns nothing
endfunction
endlibrary
library AAC initializer init requires AAB, AAA
private function init takes nothing returns nothing
endfunction
endlibrary
library AAB
endlibrary
library AAA
endlibrary
//or also:
library AAQ
private scope sco
endscope
endlibrary
/*
be aware, that Vexorians JH has a glitch in which it will not compile private scopes
like this, you have to use dummy unes like:
*/
library AAQ
scope AAQA
endscope
private scope sco
endscope
endlibrary
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.