Too many nested if/else statements? (SOLVED)

Started by masseymoviegames, Wed 02/06/2010 20:46:46

Previous topic - Next topic

masseymoviegames

I need some help, but I don't know if there's any way to fix this problem.

I just placed my 75th script request into the dialog_request section, and it's telling me that I've used too many if/else statements when I try to save it.

This is a fairly major issue because I haven't even half-finished the overall game I'm making yet and could really use some advice if there is a way to increase the amount of statements I could use.

Thanks!

Vince Twelve

You can split it into two (or more) functions.
Code: ags

function dialog_request2(int parameter){
  if(parameter==76){
    ...
  }
  else ...
}

function dialog_request(int parameter){
  if(parameter==1){
    ...
  }

  ...

  else if(parameter==75){
    ...
  }
  else{
    dialog_request2(parameter);
  }
}

will get you on your way.

However versions 3.1 (I think) and above allow scripts right in the dialogs which will save you a lot of headaches.

masseymoviegames

 :D
Thanks a lot!
And by the way, the game's actually being built as a whole game, then released in parts.
I'll hopefully have Part 1 out within the next few weeks.
I'm aiming for next Sunday. For the rest of the parts to be released over the summer.

Thanks again!
:)


Pumaman

Quote from: Vince Twelve on Wed 02/06/2010 21:06:00
However versions 3.1 (I think) and above allow scripts right in the dialogs which will save you a lot of headaches.

Yes, this is important. Don't use dialog_request, it is ugly and obsolete. Just put the scripts in your dialog scripts which makes them much easier to follow.

SMF spam blocked by CleanTalk