Button click to display data from Array 0-4

Just started using Construct 2? Post your questions here

Post » Tue Jul 12, 2016 2:36 am

Every click will be a random word.
I tried random, array.at(0) +1, myArray.CurValue +1, I can't seem to find the answer.
I Also can't figure out how to call functions from my javascript. I dont see a html file to and scripts.
I quess idiot.

Also I'm making a big list of words.
What is the best way to store that?
Just type them out in the events individually?
B
30
S
13
G
1
Posts: 41
Reputation: 2,933

Post » Tue Jul 12, 2016 6:20 am

Array.at(floor(random(array.width-1) will give you the value at a random position in the array.

I recommend learning how to parse a text file to work with a large list of words. You can import the list as a project file, read it with AJAX, and parse out each word with tokenat and the newline expression as your token separator.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Wed Jul 13, 2016 12:14 am

Heck yes it works. I tried to put the Math version in and it wouldn't go. Thank-you.

I figured out my initial problem with call js........I didn't use quotes.

What you said about the AJAX I will have to work on putting that together.
B
30
S
13
G
1
Posts: 41
Reputation: 2,933

Post » Wed Jul 13, 2016 1:05 am

Ok I got basic AJAX working too. And It did read the first word in my text.txt file.
More stuff to think about.
Thanks again.
B
30
S
13
G
1
Posts: 41
Reputation: 2,933

Post » Wed Jul 13, 2016 1:31 am

Cool, so in your text file, have each word on a newline.

By using a loop, you can push tokenat(textfile,loopindex,newline) to an array, which will then populate your array for you. (Start with your array at width 0)

You can use tokencount(textfile,newline) to see how many lines there are in your text file, which also gives you how many times to run your loop.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Thu Jul 14, 2016 4:01 am

Do you think this is the way to do things. I want to present a word and then another button to spell it out 1 textbox for each letter. or I can use the token thing. What do you think?

Image
B
30
S
13
G
1
Posts: 41
Reputation: 2,933


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest