Loop question

  • Looking on how to refine a bug to send it to "bugs" forum, I found this strange loop behaviour:

    (see example apagada.com/varios/tictactuc/tictacbug2.capx )

    For (N in 0 to 8){

    .. Create object X

    .. Pick instance N {

    .. .. Set property blah, blah, blah.

    .. }

    ]

    No object gets the blah, blah, blah property. If you use, instead:

    For (N in 0 to 8){

    .. Pick instance N {

    .. .. Set property blah, blah, blah.

    .. .. Create object X

    .. }

    ]

    Then all objects get the property, as intended.

    At the other hand,

    For (N in 0 to 8} {Create object X ...}

    For each object X {Text.append "Blah blah blah"}

    does nothing with text.

    I don't really understand how to use loops in an event-ruled programming language. In fact, I use to add a condition like

    "loopindex(N)>=maximum value" inside each loop to ensure some events execute after the loop.

    Can anyone explain me how to place events in the loop?

  • I suppose it fails because of "For each object X" or the pick-condition.

    The sprite actions in a loop pick the created instance without any special pick event.

    forLoop - example

  • The issue you're having is with how newly created objects are picked.

    Here is an outline of the rules:http://www.scirra.com/forum/picking-problem_topic41776_post257714.html#257714

  • Joe7,

    Since the topic is looping. I would like to ask a help regarding my problem on looping.

    I have a php function and I request the php file to fetch data and load in the listbox. the php file is working and it return value on the listbox.

    The problem that I encounter is only one data is return on the listbox what I need is it should load all the data. below are the files that I am working on.

    dropbox.com/sh/097xa30dcgmnlzt/cuv9YRl7Ky

    Please guys I need help on this issue.

  • aragon

    Instead of digging very old unrealated topic you should create your own really (: (it's not because someone mention loop that it's related to your issue)

    Now if you want an answer we need to be able to open your capx, and since it's full of third party plugin, it's a real pain (I don't want to install plugins)

    If you can't really get rid of them, try posting a screenshot of your event sheet.

  • Yann,

    Thank you for your reply, this is the screenshot of my event.

    dropbox.com/s/2engpjf9le6vph2/listbox.png

    I am badly needed a solution for this issue :(

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • aragon

    I've never used the ComboBoxListBox plugin before so I might be wrong

    Nevertheless, you're not using the proper parameters in the tokenat() function

    What you probably want to do is:

    ComboBoxListBox: Add: tokenat (AJAX.LastData, loopindex, "|")

    I don't really know what you want to do in event 3 since your condition is more or less the same as saying "if a = a" or event "Every tick" since it's always true and your second action is overwriting the first one.

    And also, since I've seen your php implementation, I think you have a trailing | at the end of your list, so a blank token. You might need to address that.

  • Locking this topic, if you have more questions, create a new one as said before.

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