Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: dutch_619 on 2008-11-30, 08:43:32 PM

Title: Nesting of If rules
Post by: dutch_619 on 2008-11-30, 08:43:32 PM
For some reason I can't get separate If commands. Each new If ends up nested within the parent (first) If rule. I assumed initially it was due to the lack of an EndIf, but that doesn't seem to be the case. I did a search of the forum for an answer and this seems to be a problem with the early releases of SGDK2. However the version on my PC is the latest release.

Any ideas?
Title: Re: Nesting of If rules
Post by: SmartBoy16 on 2008-11-30, 08:49:07 PM
if this was manual c# you start the if, while, for, ect. functions with a "{" and end with a "}". 
Title: Re: Nesting of If rules
Post by: dutch_619 on 2008-11-30, 08:56:23 PM
I was hoping to avoid going that route and use the built in rules editor. It is mighty handy, and rather nifty as well.
Title: Re: Nesting of If rules
Post by: bluemonkmn on 2008-12-01, 07:38:38 AM
the last rule within an If block needs to have "End If" checked.  If you are nested multiple levels, you may need to add additional "EndIf" rules to close all the nesting levels and get back to the top.  If you can't figure it out, describe in detail what you are trying (what you are clicking in what order) and I can probably tell you what to correct.
Title: Re: Nesting of If rules
Post by: durnurd on 2008-12-01, 03:31:53 PM
Although this does point out that perhaps there should be a simpler way to do end-ifs.

The first thing that comes to mind is to have buttons on the top of the tree view which control the level of indentation of the selected nodes (within the allowable limit based on where the ifs/whiles are)
Title: Re: Nesting of If rules
Post by: dutch_619 on 2008-12-01, 08:41:16 PM
Now that would be a nice feature.

Hmm, as it sits, I can close out the If nested set, but it dumps the else-ifs into their own grouping. I had hoped to flow like so

 If-> else-if -> else-if -> else

 If-> else-if->else

etc.etc.etc.
Title: Re: Nesting of If rules
Post by: bluemonkmn on 2008-12-01, 09:41:43 PM
If you want to do that, then I think you need:

If (Level 1)
   ...
   else if (level 2)
      ...
      else if (level 3)
         ...
         else ... (with implicit end if for level 3)
   explicit End If (level 2)
explicit End If (level 1)
If (Level 1)
   ...
   else if (level 2)
      ...
      else ... (with implicit end if for level 2)
explicit end (level 1)
Title: Re: Nesting of If rules
Post by: dutch_619 on 2008-12-01, 09:54:48 PM
That seems to work! Thank you much! I imported a few sprite templates and used them for reference.

Now to get the video to play smoothly...