How to disable all GUI's? (SOLVED)

Started by RickJ, Thu 23/11/2006 23:55:55

Previous topic - Next topic

RickJ

The following code runs inside a module and aborts with an "array out of bounds" error.   There are only 7 guis defined so apparently that's all that was allocated.   What I would really like to know is how to get the actual array size at runtime so that I can wallk the entire array?   I haven't found any global variable or constant other than AGS_MAX_GUIS that would appear to serve this purpose.  Have I missed something or is AGS_MAX_GUIS not being defined correctly?

Code: ags

	game_start() {
		int i=0;
		while (i<AGS_MAX_GUIS) {
			if (gui[i]!=null) gui[i].Visible=false;
			i++;
		}
	}


For the benefit of novice scripters who may be wondering why I just wouldn't just change the while statement to "while (i<7)", I did say that this is in a module so I can't know how many GUIs future users of the module will have in their game.  Presumably they would not all be the same anyway.

smiley

AGS_MAX_GUIS is always the maximum number of GUIs, you can possibly have in your game (so currently 50).

Quote from: RickJ on Thu 23/11/2006 23:55:55
Have I missed something [...]?
Yes, "Game.GUICount"  ;)

RickJ

Thanks smiley!!  That's exactly what I wanted and it works like a champ.    ;D

monkey0506

Yes, as smiley states, there is now (AGS 2.72+) the Game.GUICount property to retrieve the number of GUIs actually used within the game (it was previously part of GetGameParameter). Note though that neither of these (Game.GUICount/GetGameParameter) can be used to define the size of an array (with AGS's scripts), so if you want to create an array for anything involved with GUIs, use the AGS_MAX_GUIS constant, and just use Game.GUICount/GetGameParameter when actually checking your function indexes. Indices. Dictionary.com says their both right. Oh well... :P

SMF spam blocked by CleanTalk