[Solved] How do I pass loopindex to a Function Call?

  • I'm making a Texas Hold 'Em style Poker game. I'm having difficulty with a function which is called from inside a loop, whose intended role is to make the cards to deal to the players. When I pass loopindex to the function as a parameter, and use that parameter to set an object's variable (one created in the function), it ends up being erroneous (-1).

    Here's the loop and function from the event sheet with arrows pointing to the relevant bits --

    And this is the debugger showing the created cards' unexpected cardNumber variable (the one derived from the loopindex) --

  • While I haven't looked into it in depth, I see a wait in there. Waits in loops are a classic recipe to break everything.

  • One thing i need to tell you that you should start naming the loops and 2nd can you just place a sprite that would just hold variable and place the loopindex onto it and then use that variable for the parameter? And also I thought that loopindex only work within the loops since loops are dynamically always changing never static.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • if you try somethig simple ..you will see that loopindex don't wait..

    you need something like this

    so call & compare loopNumber in loop..

  • if you try somethig simple ..you will see that loopindex don't wait.. so call & compare loopNumber in loop..

    That did the trick. Interestingly, if I added to the counter before the wait, all of the cards had the max value of the loop... whereas placing it after it worked as expected.

    Thanks for your help guys

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)