Is there a limit to variable declaration in AGS?

Started by Darius Poyer, Fri 03/02/2012 22:19:03

Previous topic - Next topic

Darius Poyer

I remember reading somewhere on the AGS wiki about some limit to how many variables could be declared in one function, I think it said 4k? I'm wondering if this is still relevant to the current version of AGS. I'm doing things like this;

Code: ags

    t[7].r1s =s[1].b2; t[7].r1e =s[1].b3;
    t[7].r2s =s[1].b3; t[7].r2e =s[1].e ;
    t[7].r3s =s[1].s ; t[7].r3e =s[1].b1;
    t[7].r4s =s[1].b1; t[7].r4e =s[1].b2;
    t[7].entr1s = 547; t[7].exit1s = 578;
    t[7].entr2s =   0; t[7].exit2s =   0;
    t[7].entr3s =   0; t[7].exit3s =   0;

    t[8].r1s =s[1].b3; t[8].r1e =s[1].e ;
    t[8].r2s =s[1].s ; t[8].r2e =s[1].b1;
    t[8].r3s =s[1].b1; t[8].r3e =s[1].b2;
    t[8].r4s =s[1].b2; t[8].r4e =s[1].b3;
    t[8].entr1s = 547; t[8].exit1s = 578;
    t[8].entr2s =   0; t[8].exit2s =   0;
    t[8].entr3s =   0; t[8].exit3s =   0;

    t[9].r1s =s[2].s ; t[9].r1e =s[2].b1;
    t[9].r2s =s[2].b1; t[9].r2e =s[2].b2;
    t[9].r3s =s[2].b2; t[9].r3e =s[2].b3;
    t[9].r4s =s[2].b3; t[9].r4e =s[2].e ;
    t[9].entr1s = 121; t[9].exit1s = 151;
    t[9].entr2s =   0; t[9].exit2s =   0;
    t[9].entr3s =   0; t[9].exit3s =   0;

    t[10].r1s =s[2].b1; t[10].r1e =s[2].b2;
    t[10].r2s =s[2].b2; t[10].r2e =s[2].b3;
    t[10].r3s =s[2].b3; t[10].r3e =s[2].e ;
    t[10].r4s =s[2].s ; t[10].r4e =s[2].b1;
    t[10].entr1s = 121; t[10].exit1s = 151;
    t[10].entr2s =   0; t[10].exit2s =   0;
    t[10].entr3s =   0; t[10].exit3s =   0;


it works for now, but I will need that multiplied by about 20. I'm just wondering if I am liable to run into issues.

DoorKnobHandle

I would be *very* surprised if that's the case with any modern AGS version. In fact, I would have hit that limit in countless projects so I'm fairly (read: 99%) sure that's not the case.

Make sure to use while-loops as much as possible! :=

Akatosh

#2
You also may want to consider using multidimensional arrays to make work a little easier.

Darius Poyer

It's for a kind of tileset declaration. It's fairly complex and I like having the readability I get now, There are also a lot of unique cases that prevent me from using while loops to automate all of it anyway, so I'm probably going to keep it this way even though ill probably end up with 1000+ lines of code.

I hope your right dkh.

Khris

The emphasis here is on "in one function", as in, variables local to the function.
I can't imagine a scenario, much less in relation to a tile engine, where one would need all those variables only inside a function, as opposed to in a global context.

In other words:

Code: ags
int a;   // <- no limit

function do_stuff() {
  int b;  // <- 4k limit applies here
  ...
}

SMF spam blocked by CleanTalk