• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Doomsday Timer

  • 19
    Posts
    6
    Years
    • Seen Aug 14, 2021
    Hello all!

    I'm working on a short Pokemon fangame and I'm interested in adding a possibly optional feature: The game must be completed within 10 hours. After 10 in-game hours have elapsed, no matter where the player is at the time, they get a non-standard Game Over and must restart.

    I have a couple of ideas for how to implement this, but nothing seems like the perfect solution. Most time-based events trigger based on real time, and I don't want the player to have to play for ten consecutive hours. The in-game timer only goes up to 99 minutes, so that's out. The best bet seems to be to base the trigger on the in-game time played, but I'm not sure where this information is stored, how to track it, or how to make the countdown visible to the player.

    What would y'all recommend?
     
  • 658
    Posts
    7
    Years
    I haven't used timers personally. But what I'd do is run a timer for 60 mins, after 60 I'll increment a variable by 1 and restart the timer. Then I'll continue this until the variable value is 10. When it reaches 10 then its game over.

    I hope I could help.
     
  • 19
    Posts
    6
    Years
    • Seen Aug 14, 2021
    At the moment I'm trying to cobble something together out of the Bug Catching Contest code, but it's slow, error-filled going. Ten one-hour timers may be the best solution.

    Edit: No, that's not going to work. I tried it, and the in-game timer pauses during battles. That's not really in the spirit of what I'm going for.
     
    Last edited:
  • 1,682
    Posts
    8
    Years
    • Seen yesterday
    If you look at the trainer card, there's this bit here.
    Code:
        totalsec = Graphics.frame_count / Graphics.frame_rate
        hour = totalsec / 60 / 60
        min = totalsec / 60 % 60
    Graphics.frame_count is the number of frames the game has been running for, and it's saved and restored in the save file.

    You don't actually need to convert it to hours and minutes, you can just compare it with the number of seconds elapsed.

    That's 100% ingame time, though I don't know if it keeps counting if the game loses focus. Oh and you can't have any scripts that mess with Graphics.frame_rate
     
    Back
    Top