Pulling random text values out of a bank (But not Array?)

  • I'm making a random phrase generation system. It's going to be something like "Thing + ADJ_VAR + NOUN+VAR."

    The Noun variable is going to have a ton of nouns in it. Arm, leg, butt, etc. Would the easiest thing to do is make a on Start Layout > Add all the nouns into a 1 dimensional Array and then pull out a random one when asked for it? I just feel like there's an easier way to accomplish this.

  • What's complicated about that solution with the array? It's just a simple one line expression to fetch a value like that.

    Personally I would just add a text file to the project, that contains all the nouns and then, after I've successfully requested the file with ajax, add them to the array with a for loop.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah see doing that with a text file would make this so much simpler but I don't know how to do that. What is ajax?

    Right now I'm doing it as

    On Start of Layout>

    Adj_var>Set Value at 0 to "red"

    Adj_var>Set Value at 1 to "big"

    Adj_var>Set Value at 2 to "arm"

    and so on.

  • https://copy.com/G1eGXoqiTaSVu0jh

    Ajax in this case is the ajax object in Construct. Read the Construct 2 manual for more information on it, if you want to know more.

    SIDENOTE: If you are working with large arrays/lists, it is probably faster (performance/memory-wise) to set the array's final size right in front of the loop and then just fill it step by step, instead of repeatedly resizing it. So instead of push you set the array width to the tokencount that was used in the for expression. And in the for loop instead of pushing, you use set array at (loopindex-1) to tokenat(...)

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