Advertisement
killerbng

Ren'Py Timer

Nov 4th, 2022
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. # https://www.fortunusgames.com/post/timed-choices-code
  2. transform alpha_dissolve:
  3.     alpha 0.0
  4.     linear 0.5 alpha 1.0
  5.     on hide:
  6.         linear 0.5 alpha 0
  7.     # This is to fade the bar in and out, and is only required once in your script
  8.  
  9. init: ### just setting variables in advance so there are no undefined variable problems
  10.     $ timer_range = 0
  11.     $ timer_jump = 0
  12.     $ time = 0
  13.  
  14. screen countdown:
  15.     timer 0.01 repeat True action If(time > 0, true=SetVariable('time', time - 0.01), false=[Hide('countdown'), Jump(timer_jump)])
  16.         ### ^this code decreases variable time by 0.01 until time hits 0, at which point, the game jumps to label timer_jump (timer_jump is another variable that will be defined later)
  17.  
  18.     bar value time range timer_range xalign 0.5 yalign 0.9 xmaximum 300 at alpha_dissolve
  19.         # ^This is the timer bar.
  20.        
  21. label questiontime1:
  22.    
  23.     label menu1:
  24.         $ time = 3                                     ### set variable time to 3
  25.         $ timer_range = 3                              ### set variable timer_range to 3 (this is for purposes of showing a bar)
  26.         $ timer_jump = 'menu1_slow'                    ### set where you want to jump once the timer runs out
  27.         show screen countdown                          ### call and start the timer
  28.  
  29.         menu:
  30.             "Because the courts believed it was just and fair to do so.":
  31.                 play sound click
  32.                 hide screen countdown                  ### stop the timer
  33.                 jump just
  34.  
  35.     label menu1_slow:
  36.         p "Mr. Abramov? Did you fall asleep, by any chance?"
  37.         jump dontknow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement