Author Topic: Nesting of If rules  (Read 3426 times)

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Nesting of If rules
« 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?

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
Re: Nesting of If rules
« Reply #1 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 "}". 
Looking to the skies.....

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Nesting of If rules
« Reply #2 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.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Nesting of If rules
« Reply #3 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.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Nesting of If rules
« Reply #4 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)
Edward Dassmesser

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Nesting of If rules
« Reply #5 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.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Nesting of If rules
« Reply #6 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)

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Nesting of If rules
« Reply #7 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...