Fengist's Forum Posts

  • I'd need to see an example of what you're trying to do.

  • Arrays (and a lot of other things) are typically 0 based. If you were doing 1 to 10 and it was a 10 wide array, the 10 didn't exist so it couldn't go there. I'm so used to 0 based stuff, I just put things like 0 to array.width-1 as a habit.

  • Here's an example of one of mine.

    Notice the boolean check is directly under the for loop, not the while.

    This one runs a bunch of for loops. If I need to keep repeating those loops, I set the found variable to true inside that for loop. That way, it keeps looping and looping until it doesn't find things I need to change and then, with found = false, exits the while.

    Again, Ashley says I'm doing it wrong, but hey, it works and I understand it!

  • I believe your else is in the wrong spot. Put it under the value at check. If you look at the lines, it's connected to the tap gesture and the value at check does nothing if it's true or false.

  • I think this can be done a bit easier, with a single string variable.

    Yea, but mine is elegant.

    *cough*

  • SDB is the correct sequence

    twistedvoid.com/c3examples/KeySequencing

    Download here:

    twistedvoid.com/c3examples/KeySequencing.c3p

    There's a timer. Each correct key adds 1 to the timer. Every tick the timer is reduced by the delta time. If it reaches 0, the sequence booleans are reset.

    Here's the catch. You can do SDS. In which case, it looks at the second S as if you're restarting the sequence and resets the timer back to 1 second. Anything else is regarded as an invalid sequence.

    Now, for just this one sequence, this will work fine. BUT, if you have a bunch of sequences, you'll need to play with array's.

    And for those who just want to see the code:

    | Global boolean SequenceCorrect1‎ = false
    | Global number Countdown‎ = 0
    | Global boolean SequenceCorrect2‎ = false
    
    + Keyboard: On any key pressed
    ----+ System: Is SequenceCorrect2
    --------+ Keyboard: B is down
    ---------> Text: Set text to "Correct Sequence"
    
    --------+ System: Else
    ---------> System: Set SequenceCorrect1 to False
    ---------> System: Set SequenceCorrect2 to False
    ---------> Text: Set text to "Incorrect Sequence"
    ---------> System: Set Countdown to 0
    
    ----+ System: Is SequenceCorrect1
    ----+ System: [X] Is SequenceCorrect2
    --------+ Keyboard: D is down
    ---------> System: Add 1 to Countdown
    ---------> System: Set SequenceCorrect2 to True
    ---------> Text: Set text to "Sequence 2 Completed"
    
    --------+ System: Else
    ---------> System: Set SequenceCorrect1 to False
    ---------> Text: Set text to "Incorrect Sequence"
    ---------> System: Set Countdown to 0
    
    ----+ System: [X] Is SequenceCorrect1
    ----+ System: [X] Is SequenceCorrect2
    --------+ Keyboard: S is down
    ---------> System: Set SequenceCorrect1 to True
    ---------> System: Set Countdown to 1
    ---------> Text: Set text to "Sequence 1 Completed"
    
    --------+ System: Else
    ---------> System: Set SequenceCorrect1 to False
    ---------> Text: Set text to "Incorrect Sequence"
    ---------> System: Set Countdown to 0
    
    + System: Is SequenceCorrect1
    -> System: Subtract dt from Countdown
    ----+ System: Countdown ≤ 0
    -----> System: Set SequenceCorrect1 to False
    -----> System: Set SequenceCorrect2 to False
    -----> Text: Set text to "Incorrect Sequence"
    
    
  • Wait, you want a random row and a random column from an array and not have it = 0?

    Use a while statement.

    While found = false
     x=floor(random(1,10))
     y=floor(random(1,10))
     array.at(x,y)) <> 0
     else
     found = true
     stop loop
    

    then, x & y hold the answer you seek

    I know Ashley will correct my method here but I'm old school so this makes sense to me.

    I believe this is the proper method

    While 
     x=floor(random(1,10))
     y=floor(random(1,10))
     array.at(x,y)) <> 0
     else
     stop loop
    
  • Nevermind. I had it looking in the wrong folder for the music. Schedule next play defaults to the sound folder, not the music folder. Something I didn't anticipate. And, apparently music has to be playing for it to schedule a next play.

    Before I submit a bug report, it appears that schedule next play isn't working for music. The code sample below works perfect until I add the schedule next play. The basic logic is, if the music has ended, check an array of songs available and pick one at random, except for the song last played, delay it to give some silence and then play it.

    + Audio: On "Background" ended
    + System: [X] Is Muted
    ----+ System: While
    --------+ System: MusicRandom = MusicLastPlayed
    ---------> System: Set MusicRandom to round(random(0,MusicSongCount-1))
    --------+ System: Else
    ---------> Audio: Schedule next play for Audio.CurrentTime+(random(MusicMinDelay,MusicMaxDelay))
    ---------> Audio: Play MusicList.At(0,MusicRandom) not looping from Music at 0 dB (tag "Background")
    ---------> System: Set MusicLastPlayed to MusicRandom
    ---------> System: Stop loop
    

    I wanted to make sure I'm doing this correctly before complaining.

    There was a mention of this in a previous post back in Feb. but I'm guessing no bug report was filed.

  • From what I heard, you're off to an excellent start. I'll be interested to see how it all turns out.

  • Most welcome.

    By the way, I don't speak Polish, but I loved the quality and sound of the voices and music you have there.

  • Yes, it looks like a silly approach, but I was looking for a way to call this function once and I didn't find anything.

    Yep, I realized what you were trying to do and why you were trying to do it. And it was a valiant attempt. Here's the thoughts just off the top of my head. Have an array of all of your voice files with say 2 fields, the file name and a boolean (as a string). Pass the file name to the 'speakText' function as a parameter. When the speakText is run, have it check the array and see where that file name is in the array and then, set the boolean to true. When the On "textAudio" ended is run, you can again, look at the array and see which one is set to true and that tells you the last audio file played. That way, you can get away with using 1 tag and still know which voice file was played last.

    This is probably not the prettiest solution, but it works :-)

    Elegance is for physicists.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To quote the tips for this forum:

    "SHARE YOUR PROJECT

    It's difficult to help if you merely describe your project, or even if you post a screenshot of your events. It's much better to share your actual project, which is normally a .c3p file."

  • I think this is what you want:

    twistedvoid.com/c3examples/testSpeaking2.c3p

    I added a new parameter to the speakText function called thisTag and updated where you called the function to pass a tag textAudio or textAudio2.

    If it's not what you want, it's a start to solving your problem.

    You'll have to move or change this function though.

    + Audio: On "textAudio" ended

    -> Audio: Fade "music1" volume to 0 dB over 0.1 seconds, then keep playing

    -> Audio: Fade "music2" volume to 0 dB over 0.1 seconds, then keep playing

  • It's doing what you're telling it to do. You've set up an infinite loop that tells it to play a sound file with the textAudio tag when a sound file with the textAudio tag ends.

    + Audio: On "textAudio" ended
    -> Functions: Call speakText (fileName: "trzy")
    
    * On function 'speakText'
    -> Audio: Play fileName not looping from Sounds at 0 dB (tag "textAudio")
    

    You call that function the first time here:

    + System: Trigger once
    -> Functions: Call speakText (fileName: "tututu")
    
    + System: Else
    -> Functions: Call speakText (fileName: "raz")
    

    Once you call the function, it plays the file with the tag textAudio.

    The next tick it checks to see if textAudio has ended, if it has, it plays trzy with the tag textAudio.

    The next tick it checks to see if textAudio has ended, if it has, it plays trzy with the tag textAudio.

    The next tick it checks to see if textAudio has ended, if it has, it plays trzy with the tag textAudio.

    The next tick it checks to see if textAudio has ended, if it has, it plays trzy with the tag textAudio.

    etc....

  • For that, CSS.