GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Looping tables 2!

digitalzerodigitalzero Posts: 639Member, BASIC

Okay so I know I posted something like this a minute ago but I need some help once again.... so I’m trying to loop a table throughout my characters but I cannot seem to make it work. Everything is fine for looping when it comes down to pressing the forward button but when I go back and want it to go to the last character it will not so I guess my question is how do you loop the table going backwards from not being zero but going back from 1 to 12 assuming I have 12 characters

Comments

  • tatiangtatiang Posts: 11,787Member, Sous Chef, PRO, Senior Sous-Chef
    edited April 18

    There's not much information to go on there but it sounds like you're wondering how to go from row 1 of a table to row 12 without going through row 0 (which doesn't exist)?

    If so, you probably can't use a Loop over Table behavior (or at least not just a single one) but need to use a more manual loop that has conditional rules:

    When [backward button is pressed]
         When game.row is > 1
              Change attribute game.row to game.row - 1
         Otherwise
              Change attribute game.row to 12

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Posts: 11,787Member, Sous Chef, PRO, Senior Sous-Chef
    edited April 18

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • digitalzerodigitalzero Posts: 639Member, BASIC

    Totally lol I guess the real question lies with this @tatiang I’m doing the whole attribute thing to control which row the information is displayed so something like this

    When touch is pressed change attribute game.character select to (game.character select)-1%12 but you know how it goes to zero? Instead of going to zero i want it to do this....

    12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12

    I hope that clears things up

  • tatiangtatiang Posts: 11,787Member, Sous Chef, PRO, Senior Sous-Chef
    edited April 19

    Yep, I totally get it. And both of my solutions should work! :wink:

    How are you having trouble implementing this?

    If you need me to do some consulting work and take a look at your project, I'm happy to but I do charge for that. Just let me know via PM.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • digitalzerodigitalzero Posts: 639Member, BASIC

    @tatiang are you located in the states? I’m going to be done with this project shortly but I have a vast idea of another game I’ll be making after this!

  • tatiangtatiang Posts: 11,787Member, Sous Chef, PRO, Senior Sous-Chef
    edited April 19

    I am, California.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Two.ETwo.E Posts: 570Member, BASIC

    Hello.

    I am not sure what the solution you have. But if your just referencing Rows. Then you can do the reverse.

    You will have an attribute called Row. (We set it to 12, or equal to the row you want to reference).

    To go backwards,

    Change the Row attribute to the following: 12 - ((RowAttribute - 2)%12)+1

    Where 12 is equal to the total number of characters (rows).

    This will avoid the 0 value.

    Best,
    Two.E

  • digitalzerodigitalzero Posts: 639Member, BASIC

    @tatiang that solution did not seem to work for me and @Two.E that one does not work either it just repeats the same character without going down

  • Two.ETwo.E Posts: 570Member, BASIC

    Sorry, I typed that wrong. It should be:

    ((RowAttribute - 2 )%12)+1

    Best,
    Two.E

  • digitalzerodigitalzero Posts: 639Member, BASIC

    Omg I finally got it!!! Thanks you guys! Look forward to a nice question about inventory soon hahahahaha

Sign In or Register to comment.