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

Jass loc.getX()

Status
Not open for further replies.
Level 4
Joined
Aug 18, 2013
Messages
71
Title explains what I'm trying to do. I'm very used to objects in C++ and Java, and jass doesn't have the functionality i'm trying to achieve. Can anyone explain to me how to do what i'm trying to achieve, and point me to a tutorial for struggling programmers trying to relearn syntax.

if you're unfamiliar with coding languages outside of jass, c++ and java an a nifty functionality with objects where you can access "public" variables from the object. For example

init an object
Code:
public object o
public o
{
int x;
int y;
}

getX()
{
return x;
}

getY()
{
return y;
}

... etc

now in a main function
Code:
object o = new object();
o.x = 2;
exampleInt = 0.getX();
exampleReal would be equal to 2

This is just an quick example, many things are missing for this to be completely functional.

 
Level 22
Joined
Sep 24, 2005
Messages
4,821
I'm sure Purge can point you to a better guide, but this is what I used back then:
wc3c vjass has a documentation bundled with jasshelper.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
If you're used to Java, you could try out Wurst language linked in my signature. It has a very similar syntax, much better than vJass' plus allows a more organized and modular code.

If you want to use vJass, just declare an object and its members, they're public by default.
JASS:
struct O
    integer x
    integer y

    method getX takes nothing returns integer
        return x
    endmethod

    method getY takes nothing returns integer
        return y
    endmethod
endstruct
JASS:
local O o = O.create()
set o.x = 2
set exampleInt = o.x
 
Status
Not open for further replies.
Top