• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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?
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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