• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

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