Do this OR this

For questions about using Classic.

Post » Sun Oct 19, 2014 8:04 pm

Since CC Wiki is gone and I'm dumb as hell I don't know how to use "OR" system condition. I wanna Audiere play sound "walk1" OR "walk2" OR "walk3" (33,3% chance) when character walk (actually he don't walk now, I use "every X milliseconds", but is not important), because having only one sound for walk may be quite... boring. I don't wanna use variables for such simple thing, but I really don't know how to use "OR" condition. Can you help me?
B
5
S
1
Posts: 37
Reputation: 576

Post » Sun Oct 19, 2014 8:30 pm

Something like this? Not using OR

audio:play sound(choose("sound1", "sound2", "sound3"))
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Oct 19, 2014 10:56 pm

Image
I don't think that Construct Classic understand "choose"...
B
5
S
1
Posts: 37
Reputation: 576

Post » Sun Oct 19, 2014 11:27 pm

oh damn.. sorry dude

note to self, look at forum title

In CC can you do:

choose random number 1 to 3
if number=1 -> play "walk1"
if number=2 -> play "walk2"
if number=3 -> play "walk3"
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Oct 19, 2014 11:43 pm

You could use this expression for an equivalent of choose.
{"sound1", "sound2", "sound3"}at (random(3)+1)
B
94
S
33
G
118
Posts: 5,392
Reputation: 75,845

Post » Mon Oct 20, 2014 12:39 pm

codah, yes, but I really don't wanna create variables for such trivial things.

Thanks R0J0, your solution of course work, too bad that I totally don't understand why this work...
B
5
S
1
Posts: 37
Reputation: 576

Post » Mon Oct 20, 2014 12:43 pm

eku wrote:codah, yes, but I really don't wanna create variables for such trivial things.

Thanks R0J0, your solution of course work, too bad that I totally don't understand why this work...


I think this creates an one dimensionnal array of the 3 strings, then it choose one of the 3 values (not sure why the +1, does CC needs a 1 based index?)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

Post » Mon Oct 20, 2014 6:00 pm

Aphrodite wrote:
eku wrote:codah, yes, but I really don't wanna create variables for such trivial things.

Thanks R0J0, your solution of course work, too bad that I totally don't understand why this work...


I think this creates an one dimensionnal array of the 3 strings, then it choose one of the 3 values (not sure why the +1, does CC needs a 1 based index?)

Yes. :D
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Mon Oct 20, 2014 9:05 pm

eku wrote:codah, yes, but I really don't wanna create variables for such trivial things.


sorry CC is out of my depth.. is there a premium on variables or something? :?
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Oct 20, 2014 9:40 pm

There are only global and instance variables in CC. C2 spoils us with local variables.
B
94
S
33
G
118
Posts: 5,392
Reputation: 75,845


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests