Fengist's Recent Forum Activity

  • I've written software in other languages that needed internet connections and what I've discovered is that many functions like .isOnline are querying some driver or some device and often don't really know if the device is connected or not.

    One of the easiest ways in Construct and one pretty much guaranteed to pass or fail, is to do an Ajax call to a website you know is going to be up and one that accepts Ajax calls from anyone. Or, create your own php file on a webserver and do an Ajax call to it.

    Google has a bunch of resources that accept open Ajax calls. One is for jquery, both current and past versions:

    ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js

    + System: On start of layout
    -> AJAX: Request "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" (tag "check")
    
    + AJAX: On "check" completed
    -> Text: Set text to "Passed"
    
    + AJAX: On any error
    -> Text: Set text to "Failed"
    

    That simple test will pass.

    So, in theory, if you set the url to the current jquery version, it should, I say should, still work years later. Version 1.2.6 came out in 2007 but if you put this url in that check:

    "https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"

    It still passes.

    The thing you have to keep in mind is that Google has a HUGE history of changing their mind about things so having it check your own url is, most of the time, a safer bet. You'll still have to worry about your host servers crashing, internet outages and such but at least the domain is yours and you can take it wherever you wish.

  • 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
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

Fengist's avatar

Fengist

Member since 6 Nov, 2015

Twitter
Fengist has 5 followers

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x3
    Coach One of your tutorials has over 1,000 readers
  • x2
    Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies