For Next Loops

AuricAuric Member Posts: 35
edited November -1 in Working with GS (Mac)
Okay guys I know there is an example somewhere but I can't for the life of me remember where it is on the site. I need the GS equivalent to:

For Y = 1 To 10
For X = 1 To 10
'Do Something
Next
Next

Thanks!

Comments

  • Fafnir312Fafnir312 Member Posts: 161
    Rule stating: if Y < 10 then Y = Y+1 and do something

    And you'll want to do the same thing with the X and put that rule inside the Y rule.
  • AuricAuric Member Posts: 35
    It doesn't loop properly when trying that. Anyone else?
  • Fafnir312Fafnir312 Member Posts: 161
  • deltatracedeltatrace Member Posts: 10
    Hey all,

    Just experimenting with some game logic and I can't get the above code working (as detailed in the screenshot 'spawnLoop.png' in the last message. Has anyone got a basic ForNext type loop documented or an example ? GS seems great for prototyping games but seems a little hard work where perhaps it shouldn't be. Thx for any help.
  • deltatracedeltatrace Member Posts: 10
    Anyone tried this? The example listed by Fafnir works through the browser plugin but complained that I needed the latest GS update (which I have) but spawned actors perfectly well while performing the code loop. Download it and run it through the GS editor however and it does not loop through, thus doesn't spawn. Does this code simply not work on the latest GS version or as a complete GS 'noob' am I missing something ?
  • wayneh001wayneh001 Member Posts: 300
    Just had a quick look at the example supplied by Fafnir312.

    The Loop (Spawning) didn't run on my machines either. To make it run there's a few ways, but the quickest is just to put all the [Behaviour Code] in the 'Spawner' Actor into a [Timer].

    IE. Timer: Every 0 Seconds

    Then it works for me.
  • deltatracedeltatrace Member Posts: 10
    Thanks for the confirmation Wayne. My problem is I set up a loop within a timer to test it, I then wanted the loop outside of any timer function as even with 0 seconds as the delay value it still seemed to delay a little too much. Ideally I'd like a good old fashioned ForNext loop. If you or anyone knows how to get the example working or if this IS a bug and it's going to be fixed anytime soon I'd like it. Thx.
  • wayneh001wayneh001 Member Posts: 300
    I understand what you are saying Deltrace. However, I wouldn't consider the issue you describe as a [Bug]. Could you describe the exact purpose you need a For/Next Loop? There's usually always a way to implement this type of logic within GamaSalad using Rules, conditions and Timers.
  • deltatracedeltatrace Member Posts: 10
    I was doing some basic string reading attempts, stepping through a list of them. I did it on the timer just to slow it all down and enable me to read any output to the screen. It's not vital as such, just some code I'd like for future tweaking. My calling it a 'bug' is because it DID work on the browser (and perhaps earlier GS version) and doesn't now (on the current GS).

    I'm a cautious person and always looking ahead for the next pitfall !
Sign In or Register to comment.