I'm starting to tackle vJass and I'm now creating a library. To give you an idea of what I'm trying to achieve, here is my incomplete code. I cant find any tutorials on libraries, so was hoping someone could explain a couple of things for me.
A few questions:
1.) What is the scope of of the "global" variables? Are they actual global or only use-able in this library? If global, could I make them static private instead?
2.) When are the global variables created? On map init, or each time the library is used in real time?
3.) I want to initialize the variables to store data in them upon the map loading. It seems I can't do that within the global nest. What's the best way to init the variables?
If there are any tutorials you know of, I'd also be happy if you could share a link
Edit: I remembered someone saying vJass supports 2D arrays. Can someone show me the correct syntax for that so I don't use funky emulating 1D arrays anymore like shown above?
JASS:
library MusicLibrary
//************************************
// Variable Setup
//************************************
globals
// Globals
integer musicKey // Music Key. See "Music Mappings" for reference
constant integer MUSICINDEXSIZE = 10 // Each key can only store indexSize number of values.
constant string array MUSICPATHS
constant integer array MUSICLENGTHS
hashtable udg_TimerHash
set musicKey = 1
set MUSICPATHS[musicKey] = "Music\\06 Pallet Town Theme.mp3"
set MUSICLENGTHS[musicKey * MUSICINDEXSIZE + 1] = 0050
set MUSICLENGTHS[musicKey * MUSICINDEXSIZE + 2] = 43886
set musicKey = 4
set MUSICPATHS[musicKey] = "Music\\08 Professor Oak's Laboratory.mp3"
set MUSICLENGTHS[musicKey * MUSICINDEXSIZE + 1] = 1076
set MUSICLENGTHS[musicKey * MUSICINDEXSIZE + 2] = 17138
endglobals
//************************************
// Function List
//************************************
endlibrary
A few questions:
1.) What is the scope of of the "global" variables? Are they actual global or only use-able in this library? If global, could I make them static private instead?
2.) When are the global variables created? On map init, or each time the library is used in real time?
3.) I want to initialize the variables to store data in them upon the map loading. It seems I can't do that within the global nest. What's the best way to init the variables?
If there are any tutorials you know of, I'd also be happy if you could share a link
Edit: I remembered someone saying vJass supports 2D arrays. Can someone show me the correct syntax for that so I don't use funky emulating 1D arrays anymore like shown above?
Last edited: