Arrays

Jesus4Lyf

Good Idea™
Reaction score
397
I've been trial and erroring, slowly building up enough information to start writing systems in SC2.

This is the syntax for array declaration and usage, demonstrated by writing an allocator/deallocator. I don't think this will be necessary if structs are all they're cracked up to be, but we'll see. :)
JASS:
int[128] MyStack__Stack;
int MyStack__Stacked=0;
int MyStack__Next=0;

int MyStack__Alloc(){
	if (MyStack__Stacked==0){
		MyStack__Next=MyStack__Next+1;
		return MyStack__Next;
	}
	MyStack__Stacked=MyStack__Stacked-1;
	return MyStack__Stack[MyStack__Stacked];
}
void MyStack__Dealloc(int ev){
	MyStack__Stack[MyStack__Stacked]=ev;
	MyStack__Stacked=MyStack__Stacked+1;
}

Code is tested and compiles.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Can arrays be passed as parameters?
Haven't tried, yet.
>Can you declare arrays with a variable size?
Not that I know of. But of course, we don't have a full function list...
>If not, can you use const's instead of integer literals when declaring an array?
Yes. :)

It seems the [LJASS]Wait(fixed, int);[/LJASS] native cannot go down to 0.03125 sec. The minimum seems to be around... I dunno, 0.05? :(
Edit: Actually, Wait(0,0) seems to be very fast. The problem is, I'm not sure how fast. It just seems to have some kind of overhead...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top