• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Help me! JAWS are eating me.

Status
Not open for further replies.
library = map header, well almost... I'll leave this to Mal, since I don't remember vjass that well anymore.
 
OK I'll try to explain clearly ^^

I - Libraries and scopes
Libraries and scope are the only way (FOR THE MOMENT BUT STICK TO THIS XD) to use private public keywords.
Libraries put your code on the top of the map and can use requires/uses/needs fields to not compile if those other libraries aren't there.
Example : library FearSystem requires Table
This can be optional too : library FearSystem requires optional Table

Scope are the same but can't use the requires fields and aren't put at the top of the map.


II - Private/public
The keyword private means that you will be able to access the thing which is private only in the library/scope it is declare. (IT IS NOT COMPLETELY TRUE BUT STICK TO THIS XD)

The keyword public means that to access it outside the scope/library you need to put the name of the scope/library then put an "_" and at last put the name of the thing.
Example :
JASS:
library Test
    globals
        public constant integer A = 1
    endglobal
endlibrary

//LATER IN ANOTHER SCOPE

scope Test2
    globals
        constant integer B = Test_A
    endglobals
endscope


III - Struct
It is OOP language -> Object Orientation Programming (IIRC).
Meaning that you can create your own variable type, you want to create another location which is not buggy ?
JASS:
(private/public) struct Location
    real x
    real y
endstruct

function Test takes nothing returns nothing
    local Location loc = Location.create() //That creates an instance of your struct
    set loc.x = 42 //That allows you to change the x value of your struct instance.
    set loc.y = 1764 //That allows you to change the y value of your struct instance.
    //Do your stuff
    call loc.destroy() //Never forget to destroy them
    //No need to null this it is counted as integer.
endfunction
 
location has bugs? IIRC, it's just slower than using real values, which are just numerical values, whilst locations are objects which have overhead when being created.

I'd still use coordinates though, the overhead ain't worth it. Unless of course you're doing maths haha xD
 
Yeah haha xD! Worship da Almighty Malhorne!

EDIT: It's because the stupid World Editor appends udg (user-defined global) to the global identifier. One of Blizzard's weirdness...
 
Status
Not open for further replies.
Back
Top