Nested Loops? (Specifically Looping Over a Table)
So I just fired up GameSalad after a while of not touching it, and I felt like maybe messing with the (relatively speaking) new loop behavior container. More specifically, I was gonna attempt using nested loops along with an array (or table if you wanna use the fancy Gamesalad terminology) to set up a mockup kind of tiled pattern if that makes any sense. Basically my problem is that when attempting to make a nested loop, I don't get any feedback when testing. There's no infinite looping to my knowledge (I dunno if GameSalad does something to prevent itself from crashing but I'll assume it doesn't) and when I don't use a nested loop, it seems to work fine when I was logging debug statements. Here is a screenshot of what I currently have. (Actor 1 and Actor 1 copy are just different colored squares I was using to make sure it was responding correctly to the different table cell values). I am currently using the most recent version of GameSalad (1.25.80) Let me know if you need any more information. Thanks!
s847.photobucket.com/user/adscomics/media/Screen%20Shot%202017-08-24%20at%209.17.26%20PM_zpsnwt1dqlg.png.html
Having trouble with your game? Sounds like a personal problem.
Comments
@ADSentertainment,
look at the info panel next to the loop behavior in the behavior list. There it tells you that you can't use a loop inside a loop.
To work around this, use one loop, and increment the row and column attributes inside it.
Something like this (assuming a 10x10 array):
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch
I see! That makes sense since you can check for multiple things at once in Gamesalad. Thanks!
Having trouble with your game? Sounds like a personal problem.
@Hopscotch just beat me too it. But here is an example that I just stuck in the spare code thread. It might work for you:
http://forums.gamesalad.com/discussion/comment/599873/#Comment_599873
@ADSentertainment
an alternative shorter and more lightweight method (again assuming a 10x10 grid):
@RThurman
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@RTHurman Thanks! I'll definitely look into that!
Having trouble with your game? Sounds like a personal problem.
@RThurman
looking at your linked project - we are going to have to put the thumb screws on GS to keep that inline binary logic alive in the new HTML5 creator. Currently its strict and predictive syntax checking does not allow for it. Same for a lot of useful LUA functions, like match, gsub, etc, and pattern matching.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch @RThurman Got it working, thank you all so much! I haven't used the more lightweight one yet but I'll look into it more at some point.
Having trouble with your game? Sounds like a personal problem.
@Hopscotch -- good point! It would be a shame to loose such a powerful tool as binary logic in the expression editor.
@Hopscotch regarding your more lightweight method, where it says while self.counter < 100. Is that 100 coming from multiplying the column count and row count of the grid/array since it's a 10x10 grid?
Having trouble with your game? Sounds like a personal problem.
Yes @ADSentertainment, that is correct. I could have been clearer about it.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com