TicTacToe: Effeciency Tips

Get help using Construct 2

Post » Thu Jun 09, 2016 1:45 am

The manual explains the conditional operator pretty well here:
https://www.scirra.com/manual/78/expressions

But yeah, it's like a simple if then else.

If X=2
Then set y to 4
Else set y to 5

Can be written instead as

Set y to X=2?4:5
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Thu Jun 09, 2016 1:55 am

R0J0hound wrote:The manual explains the conditional operator pretty well here:
https://www.scirra.com/manual/78/expressions

But yeah, it's like a simple if then else.

If X=2
Then set y to 4
Else set y to 5

Can be written instead as

Set y to X=2?4:5



Wow, I've landed on that page so many times when searching for various answers but I have never read the operators section. Assumed I knew plus, minus, greater than, less than etc. We all know what assuming makes.... usually I try to read everything
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Thu Jun 09, 2016 9:34 pm

tokenat() is useful if you don't want to create a JSON or manually populate an array, with a text variable, it basically acts like the At command of a one-dimensional array.
I use it a lot, but I don't know if performance gets affected by it.
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,471

Post » Thu Jun 09, 2016 10:35 pm

Whiteclaws wrote:tokenat() is useful if you don't want to create a JSON or manually populate an array, with a text variable, it basically acts like the At command of a one-dimensional array.
I use it a lot, but I don't know if performance gets affected by it.


Yes, what you did with tokenat() reminded me of a simple array. Honestly, at first it seemed to be more complex in writing the syntax than using an array. But that's probably because I haven't seen it or tried it so I won't knock it until I try it. I could see it possibly coming in handy with text choices as well "yes/no/maybe", "save&quit/save&exit/exit".

Do you usually accompany it with another variable to track the index? If you use it and discard it in the event its unnecessary but it seems like in a lot of cases you would want to save the results somewhere, whether in global or instance variable.
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Fri Jun 10, 2016 11:25 pm

badmoodtaylor wrote:@blackhornet & @gumshoe2029 I don't have those plugins installed but I'm sure I'd learn something about those plugins from the capx. I've heard good things about those plugins but not going to install them at this moment.


We use it in our current game to produce our isometric platform:
https://www.stormforgedproductions.com/ ... 287745.png
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Sat Jun 11, 2016 4:32 am

The index is like that of an array 0/1/2/3 etc assuming your separator is /, it could also be just blank "", which would give you the letter at a number, you can even make a nested array using different separators, its very useful, also, if you want to convert the text to number, you can either do int() or float()
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,471

Post » Sat Jun 11, 2016 3:28 pm

Whiteclaws wrote:The index is like that of an array 0/1/2/3 etc assuming your separator is /, it could also be just blank "", which would give you the letter at a number, you can even make a nested array using different separators, its very useful, also, if you want to convert the text to number, you can either do int() or float()


Ah, nested array. So you could do something like

"Give me the item!"

(I will never give it to you,Here you go/I don't have the item,I will come back with the item/What item?,Screw you I don't care)
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Sat Jun 11, 2016 6:12 pm

More like multiple dialogs such as "Give me the item/Hello, who are you?/What was that explosion?" For NPC Dialogs and "Yes#No#What Item?/Harry the wizard#It's a secret#MrRodgers/An explosion#What?#Tnt"
Where to get the NPC dialogs and all responses you use index X and separator /; but if you wanted a response, you'd have to use index Y and separator # over the responses you just got.

Edit: The cool thing is that you are not blocked by the array being rectangular for example you could have the first dialog have 2 responses and the second 52 and it would be ok, whereas in a 2d array you'd have one of the columns with 50 free spaces or if you had a 1D you'd have to save the index or go thru the array to find the token to be able to access second dialog (which tokenat already does for you)
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,471

Previous

Return to How do I....?

Who is online

Users browsing this forum: DolyGamesCosmos and 21 guests