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

[Trigger] Null var

Status
Not open for further replies.
Level 9
Joined
Nov 19, 2011
Messages
516
Hi there,

Here are two questions that I am tring to find answer:

1. How to set variable to null? Is destroy doing so for all variable types or not?
2. How to check if variable value is null?

I have a set of points on the map, and I am about to store them into table. But if I will not count well and set table length to more than points count? How to check if I am not about to refer to null value? Or maybe I am able to set endless table like in JAVA?
 
1) if its a unit the set it to no unit. Some of the other variables u can do this to. Other variables u need to use custom script. A variable is a pointer to a piece of memory. When u destroy that variable u actually destroy the memory that it points to. To null u need to destroy first then null.

2) use an ITE and In the conditions block check if unit equal to no unit. And same with the others.
 
Level 9
Joined
Nov 19, 2011
Messages
516
In JAVA it looks like this:

int table[]

that is endless table where table.length stores it largerst index.

So.. all of variables in WC3 are pointers? That sloves a lot. So until I set some value it not uses space in memory...

What about objects then? Can I make a record variable:

record el
{
point position;
int value;
}

??
 
Sort of. You can emulate that class structure with structs in vJASS:
JASS:
struct X
    real x
    real y
endstruct

Then you can make an instance and set the variables:
JASS:
local X example = X.create()
set example.x = 5
set example.y = 10

Of course, there are a lot more things to it than that. You should look into some of the vJASS tutorials around our tutorials section.
 
Status
Not open for further replies.
Top