Loop through a list of numbers?

This forum is currently in read-only mode.
  • Hi! I've asked about this before in a diferent thread, but i can't remember where, and it didn't get answered, so i'm posting it again here in the right forum.

    I'm creating an AI system that needs to check if a number of values exist in an objects private variable. At first i tried to code it in an event, but it ended up like this:

    <img src="http://img166.imageshack.us/img166/5261/infiniteeventjt0.jpg">

    That is obviously not a solution. So i need a way to loop through these numbers and write them down somewhere else. The problem is that i can't find a place to write them down! The array can't be edited eccept with events, so i would still need like 20 of these events. An array that was visible where you could just klick a box and fill in the numbers would be a nice thing to ad in the future, but is there a soluton right now?

    Does someone have any suggestions? I really really need a solution to this. Thank you for your time!

    Jonatan

  • I cant think of any and probably no solution other than creating event for every possibility, btw thats the curse of programing a lot of events...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use a For loop and a Text object with numbers like:

    1,7,19,257,380

    then:

    + Always

    : Set global variable 'found' to 0

    + For "i" from 1 to numtokens(Numbers.Text)

    + Private variable = int(gettoken(Numbers.Text, LoopIndex))

    : Set 'found' to 1

    From this point on, you can check the global variable 'found' to see if it matched.

  • Thank you very much Ashley! I'll try that out and return with information of how it turned out!

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