Problem with tracking time when tabbing out of the game

● ARCHIVED · READ-ONLY
Started by autophagy 6 posts View original ↗
  1. Hello!

    In my previous question thread I was trying to figure out a way to make another song play after the current one has reached its end. I am now using two variables:

    1. One that contains the current song's length in seconds.
    2. One that counts the seconds since the song has started.
    I also edited the standard load script to reset the counting variable to 0 when the game gets loaded since the song restarts upon opening the file. (That's about the extent of my Ruby knowledge...)

    I also edited the battle and map related scripts to prevent all BGM and ME from playing when the radio is on.

    Now I ran into another problem...If I tab out of the window at any point during a song is playing, it seems like the second variable stops counting while the song plays on merrily, therefore messing up the count and creating an awkward pause after the song has stopped.

    Is there any way to fix this behavior? For example a script that would pause all audio while the game window isn't the active window?

    Edit: I forgot to mention, the variable that counts the seconds is in a parallel process common event that increases the variable by 1 every second. (However there seems to be something wrong with it, since when I playtest and check the variables, it only seems to increase the number every 3 seconds or so...)
  2. I'm sorry, but pretty sure the only wqay to get what you really want is through scripting...
  3. @Waterguy: Hmm, so this requires some really extensive changes to the game engine? I was hoping that it would be possible to somehow "steal" the method the game uses to detect when the focus isn't on the window and repurpose it to not only stop all movement and event progression (as it already does!) but also the playback of music. If someone could give me a hint where to find this part of the game's programming (if it's in an accessible part of the scripting, that is), I guess I would be able to figure it out on my own, but I could really use a hint. :')
  4. I never said it needed extensive changes. But you will need some scripting.
    People just try to avoid scripting much to avoid both bad habits of trying to solve everything through them and to avoid compability problems with using too many that deal with the same pieces.
  5. That's okay with me. :) I do have some rudimentary scripting knowledge (since I know PHP and some Javascript, but I'm still pretty lost with RGSS), so I can modify existing parts of a script without breaking the whole thing, but I would need help with finding the proper spot in the basis scripts so I can figure something out and know what part of the script I'd have to mimic. My assumption is that even if I scrapped the whole event based feature I have so far, the wait command equivalent would still not count properly. (Unless there is a way to use the actual computer clock through a script and calculate the time that has passed since the last event loop? o: )

    So, is this the right forum for this kind of question? Should I try making a thread in the RGSS Request forum instead? Sorry, I'm a bit confused.

    Edit: OKAY SO. I had a better idea and was able to google my way to getting a timestamp from the operating system...and wrote my first ruby script. :D The problem is solved. Thank you for trying to help nevertheless. :)
  6. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.