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

vJass stuff i dont understand

Status
Not open for further replies.
Level 7
Joined
Nov 6, 2009
Messages
279
Can somebody explain or post a link about operators and keywords? And are modules something more than struct expansions?
 
Last edited:
Level 7
Joined
Nov 6, 2009
Messages
279
Thats quite simple.

Keywords allow you to acces stuff "below" your code.
If two structs use each other, like
JASS:
struct a
    b data
endstruct

struct b
    a dat
endstruct
This throws errors without keywords.
Operators are "=", so you can call functions via normal "sets". There is more, but I have to go :p

Always helping me thx Justify
 
Okay, just an addition:
keywords are also used for the .execute and .evaluate methods, just anything that is below the calling code.

Method operators allow you, to access functions with a "set".
For example: (= means set, there is > for comparisons, and so on. An operator without anything means "read" (like reading a variable))
JASS:
method operator ohMyGod= takes real omg
    set this.myreal = omg
    call SetUnitFacing(this.myUnit, omg)
endmethod
Would be called via:
JASS:
set this.ohMyGod = 325.
 
Level 7
Joined
Nov 6, 2009
Messages
279
Okay, just an addition:
keywords are also used for the .execute and .evaluate methods, just anything that is below the calling code.

Method operators allow you, to access functions with a "set".
For example: (= means set, there is > for comparisons, and so on. An operator without anything means "read" (like reading a variable))
JASS:
method operator ohMyGod= takes real omg
    set this.myreal = omg
    call SetUnitFacing(this.myUnit, omg)
endmethod
Would be called via:
JASS:
set this.ohMyGod = 325.

What makes operators useful?
 
Level 9
Joined
Nov 28, 2008
Messages
704
What makes operators useful?

You can define seperate methods for getting and retrieving data.

For example, in my projectile system it is much more efficient to keep all of the variables such as speed in per interval times, but you give the speeds in a per second time.

Thus, using operators, I can do:

p.Velocity = 100

and have it automatically conerted to 100 * INTERVAL (which is usually 0.04). This also allows the user to get the speed whenever he desires and have it return the right thing, without requiring usage of a function and making things more complicated on his end.

It's more of an aesthetics thing than anything, but it really is much more beautiful and sense making.
 
Level 7
Joined
Nov 6, 2009
Messages
279
You can define seperate methods for getting and retrieving data.

For example, in my projectile system it is much more efficient to keep all of the variables such as speed in per interval times, but you give the speeds in a per second time.

Thus, using operators, I can do:

p.Velocity = 100

and have it automatically conerted to 100 * INTERVAL (which is usually 0.04). This also allows the user to get the speed whenever he desires and have it return the right thing, without requiring usage of a function and making things more complicated on his end.

It's more of an aesthetics thing than anything, but it really is much more beautiful and sense making.

Actually i think they're something like function variables arent they?

And are modules something more than struct expansions?

And seriously man cJass?
 
cJass seems to be the most hated language but it provides some extensions that vJass doesn't have, but I don't need them (they love their "define" :D).
Method operators are nothing but normal functions, that take a SINGLE argument and are called via "set this.opMethod = xyz".

Modules seem to be the same then delegates for me, dunno what's the difference :O
Read this: http://www.wc3c.net/vexorian/jasshelpermanual.html :p
 
Level 7
Joined
Nov 6, 2009
Messages
279
cJass seems to be the most hated language but it provides some extensions that vJass doesn't have, but I don't need them (they love their "define" :D).
Method operators are nothing but normal functions, that take a SINGLE argument and are called via "set this.opMethod = xyz".

Modules seem to be the same then delegates for me, dunno what's the difference :O
Read this: http://www.wc3c.net/vexorian/jasshelpermanual.html :p

Ive read that. The difference is that u delegate a struct which works standalone but u implement a module which cant work on its own.

Like TFT expansion.

EDIT: Hell this is getting long:ap:
 
Level 9
Joined
Nov 28, 2008
Messages
704
And seriously man cJass?

JASS:
scope Win initializer Init:
    private player P
    
    private void Init():
        group g = groups.Get()
        P = Player(0)
        
        GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Filter(lambda bool()
        {
            return GetOwningPlayer(GetFilterUnit()) == P
        }))
        
        ForGroup(g, lambda void()
        {
            KillUnit(GetEnumUnit())
        })
        groups.Give(g)

I'm sorry. I was too busy staring entranced at the beauty of cJass. What were you saying?
 
Level 11
Joined
Apr 29, 2007
Messages
826
You could also do that with zinc:
JASS:
//! zinc
scope Win
{

    Player P

    function onInit()
    {
        group g = CreateGroup(); //Seriously was that group.get thing cJass intern?
        P = Player(0);
        GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, function() -> boolean
        {
            return GetOwningPlayer(GetFilterUnit()) == P;
        });

        ForGroup(g, function()
        {
            KillUnit(GetEnumUnit());
        });

        DestroyGroup(g);
        g = null;
    }
}
//! endzinc

cJass is only awesome because of it's defines. (In my opinion of course)

JASS:
#define
{
    <CreateUnit>(unit) = CreateUnit(unit, Player(0), 0, 0, 0)
    <CreateUnit>(unit, player) = CreateUnit(unit, player, 0 ,0 ,0)
    <CreateUnit>(unit, player, x, y) = CreateUnit(unit, player, x, y, 0)
    <CreateUnit>(unit, player, x, y, f) = CreateUnit(unit, player, x, y, f)
}

Who could say that this is NOT awesome? (Might have mistakes in it, haven't coded for a while D:)
 
Status
Not open for further replies.
Top