What's the easiest way to work with tons of text? [Solved]

Get help using Construct 2

Post » Mon Apr 07, 2014 4:59 pm

I'm guessing the 13,6,1 is the array size for x,y,z.
B
33
S
7
G
8
Posts: 312
Reputation: 8,528

Post » Mon Apr 07, 2014 5:51 pm

ok i'm trying to break this down to better understand the syntax.. i need a joke and punchline that would go in different text objects.. so i imagine i'll need to make two json files.. is this the right syntax below?


{
"c2array":true,
"size":[3,1,1],
"data":[[

["Joke1"],
["Joke2"],
["Joke3"]

]]
}

what is the purpose of "c2array"? is it a unique name? I don't cee "c2array" anywhere in the event sheets. If I import two json files i just want to be sure that c2array name is something that either needs to be unique or in common.

also @Manley23 you mention X, Y, Z? i'm only used to that being used in terms of 3d coordinates. what would the x y and z represent in this case with c2?

Thanks!
Caleb
B
59
S
9
G
1
Posts: 942
Reputation: 6,553

Post » Mon Apr 07, 2014 5:59 pm

@part12studios - I don't think you have the right syntax there. For arrays, the X, Y, and Z represent the 1D, 2D, and 3D coordinates for the array. In C2, you want to specify your array size and you always do this in X, Y, Z terms. So, even if you have a simple array of 10 items (i.e., you only need the X-coord), you still specify the size as (10,1,1).
If you had a 2D array of 5x2, then size = (5,2,1).

You would not need two files for your jokes and punchlines, unless you wanted to. I would just put joke, punchline, joke, punchline in a 2D array and access the jokes and punchlines with [x,y] coordinates.

Joke 1 = [0,0]
Joke 1 punchline = [0,1]

Joke 2 = [1,0]
Joke 2 punchline = [1,1]
B
33
S
7
G
8
Posts: 312
Reputation: 8,528

Post » Mon Apr 07, 2014 6:47 pm

Manley23 has the right xy approach above.

And
"c2array":true, is what construct2 uses to json the data into either array or dictionary. It isn't part of json, but a c2 thing :roll:

What I did was build it in construct2 first. Used the array download to download to json. And used that json to be imported.
Attached is capx of events used to create array, then download to json. I toggled the include CreateDatabase event sheet.
I am using the xy, but out of habit I include z = 1

There are 13 because arrays count 0 as 1, which is why I minus one from TotalCards to get correct display of number cards. Array.Width is 13, but we don't want card 0.
So we 13-1=12 cards
And random(1,13) because we don't want to include card0
The above is only for cosmetic purposes. Showing Joke 6of12 for example.

Now that you have how i created the database, play around make your own then import it into files and change the Ajax->Request to reflect your json file.
You do not have the required permissions to view the files attached to this post.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Mon Apr 07, 2014 7:48 pm

awesome thanks! i'll keep at it with this new info! Thanks to you both for your help with new (and kinda confusing to me) subject :)


Thanks!
Caleb
B
59
S
9
G
1
Posts: 942
Reputation: 6,553

Post » Tue Apr 08, 2014 2:17 pm

ok so i have some of this understood, but i'm confused by the example because it just seems like it has a lot going on that i don't need and i'm not clear where what i want ends and what i don't want begins.. because its kinda all woven in together.

I have a json file that is imported in my test project.. i was able to display the the first value by using

Array.CurValue and that's way cool.. it displayed in a Text object (standard text, not sprite font) "Joke1"

but what i don't know how to do next is how to call on any of the values below.. this is what i have setup now:

{
"c2array":true,
"size":[4,1,1],
"data":[[

["Joke1"],
["Joke2"],
["Joke3"],
["Joke4"]

]]
}

it seems like if i could just figure out how to access joke 2 3 and 4.. that would be all i need to know to be able to then use what i do know to call on random text from the list above..

Sorry to be so dense lol, this is just very new to me and having never used sprite fonts before or arrays it's just made the sample project tougher to discern.

Thanks!
Caleb
B
59
S
9
G
1
Posts: 942
Reputation: 6,553

Post » Tue Apr 08, 2014 2:29 pm

a small update.. i tried to use Array.At(1) and got an error.. thinking i could access "Joke2" by calling on (1).
B
59
S
9
G
1
Posts: 942
Reputation: 6,553

Post » Tue Apr 08, 2014 2:38 pm

part12studios wrote:a small update.. i tried to use Array.At(1) and got an error.. thinking i could access "Joke2" by calling on (1).


You use Add Event to Compare Array spots.
You use Add Action to Set Array spots.
You can use Array.At(x,y,z) to access array data in events or actions.

So, for your text object, you could do text->set text->Array.at(1) to set the text to whatever data is in array spot 1.

Does that help at all?
B
33
S
7
G
8
Posts: 312
Reputation: 8,528

Post » Tue Apr 08, 2014 2:59 pm

Think of it as a list.
0.0 Joke 1
>0.1 Joke 1 Punchline
1.0 Joke 2
>1.1 Joke 2 Punchline

The confusing thing is that in code it counts first intance as 1. So 0 is 1 instance. 1 is 2 instances.

["Joke 00"], array.at(0,0)
["Joke 00 Punchline"] array.at(0.1)
],[
["Joke 01"], array.at(1,0)
["Joke 01 Punchline"] array.at(1,1)
],[

We work in 3 dimensions x,y,z

In the above we working in 2 dimensions x,y and z we make it 1

So X is the number of cards and we randomize x
cardnumber = floor(random(1, numberofcards)
we choosing a random number between 1 and #Number of cards. I am not including 0 because I added a card1/totalcards and wanted it too look good. You can add random(0,totalcards) if you want.

And number of cards is how wide is x and we can find that out by using array.width
y is the 2nd dimension, the bullet points of the card.
We only have 1 now, which is punchline.

So it looks like this 2 jokes and 2 punchlines

(x,y,z) (2,2,1)

So to get joke 2 array.at(1,0)
and get joke 2 punchline array.at(1,1)
Make sense?

The trick is to play around with it. Once you master this, you won't ever look back.

Ninja'd by Manley23, I guess I took to long in the editor.
Last edited by DUTOIT on Tue Apr 08, 2014 3:30 pm, edited 1 time in total.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Tue Apr 08, 2014 3:22 pm

lol i had the same thing happen.. i was going to share what i was experiencing with my setup.. which i'll post now.. just so you know.. but i'll read and respond to your deeper response once i read through it.

-----

yea i pretty much follow you but when i do Array,At(1) i get an error..

here is what i have so far https://www.dropbox.com/s/tp0x6fgkskac5 ... 0setup.PNG

this current setup results in this:

click the button.. the text field shows "Joke1"

if i make (0) a (1) i get this error https://www.dropbox.com/s/aiui94i2cu58297/error.PNG
B
59
S
9
G
1
Posts: 942
Reputation: 6,553

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Artcadev, newt and 4 guests