GetLocalInt and SetLocalInt issues (coupled with weird onHeartBeat issues)


#21

Thanks for the numbers. Perhaps by knowing the hard limits one could do some byte-patching to raise them. I’ll look into the recursion limits, but now I was interested in at around which i, while(TRUE) i++ will raise.

They are related. This was my point all along. A beginner may avoid such kind of mistakes by adhering to few core principles they are taught. Not everyone is a natural born programmer (and a lot of programmers can’t even code). Dividing your program in clear, identifiable at glance segments is one of those rules. For example:

  1. Note to self to use tabs for indentation
  2. Function declaration segment
  3. Variable declaration segment
  4. First logical part of the function
  5. W H I T E S P A C E
  6. Second logical part of the function
  7. W H I T E S P A C E
  8. Outstanding return.

@Val’s code is full of comments too, which is very good for debugging.

By keeping the declarations in one spot, a beginner makes a habit of avoiding putting any int, float, etc keywords beyond the initial part of the code. You may see scrolling up and down as a chore, but it keeps things under control in clear view. Maybe not how they are used, but what they are and how many of them are at your disposal. Don’t need one? Delete it from one spot and all leftovers won’t compile. Need one more? Just add it to the list. Once you feel comfortable with this, you can start going your own way.


#22

I like nice clean, easy to read code, too. I just think in this case it’s more likely there would have been 3 declarations of iGrow if there was one up near the top :slight_smile: And @val I’m not trying to pick on you. You’re doing fine and this is all part of the learning process.

As to the numbers I’d expect your while loop to pretty quickly just hit TMI (which is adjustable with EE or nwnx/1.69). The stack itself may just grow as memory allows. I don’t think the recursion limits are related to running out of stack space.

There’s also a compile-time limit to the number of globally visible symbols in the in-box compiler (and maybe in the out of box ones but it’s large enough not to be an issue. Not sure off-hand). I don’t remember if this was raised for EE yet or not. It’s 8192 in 1.69 but that includes all the consts and function decls pulled in with nwscript.nss which leaves about 1870 for your scripts (and any bioware includes you pull in).