Code: Select all
$ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
"%(minutes)d minutes and %(seconds)d seconds to
finish this demo."
Code: Select all
$ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
"%(minutes)d minutes and %(seconds)d seconds to
finish this demo."
Here a way to do it, it's unefficient though:JinzouTamashii wrote:I would like to convert that into hours and minutes, with hours possibly given as a decimal if > a value of 1.
Code: Select all
label start:
$ hours=0
$ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
$ minute=minutes
while minute>=60:
$ minute-=60
$ hours+=1
if hours>0:
"%(hours)d hours and %(minute)d minutes to finish this demo."
elif hours==0:
"%(minutes)d minutes and %(seconds)d seconds to finish this demo."
Code: Select all
$ allminutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
$ hours, minutes = divmod(allminutes, 60)
Probably this:http://docs.python.org/JinzouTamashii wrote:Does Python have a general documentation wiki too for operations like this?
Well if that isn't just amazing.http://docs.python.org/dev/3.0/whatsnew/3.0.html#integers wrote:An expression like 1/2 returns a float.
This is the code I used and it starts on line 41.I'm sorry, but an exception occured while executing your Ren'Py
script.
TypeError: an integer is required
While running game code:
- script at line 41 of O:\Renpy\SumoftheParts/game/endings.rpy
-- Full Traceback ------------------------------------------------------------
File "E:\Renpy\renpy\bootstrap.py", line 260, in bootstrap
File "E:\Renpy\renpy\main.py", line 308, in main
File "E:\Renpy\renpy\main.py", line 92, in run
File "E:\Renpy\renpy\execution.py", line 230, in run
File "E:\Renpy\renpy\ast.py", line 341, in execute
File "E:\Renpy\renpy\exports.py", line 499, in say
TypeError: an integer is required
While running game code:
- script at line 41 of O:\Renpy\SumoftheParts/game/endings.rpy
Ren'Py Version: Ren'Py 6.9.3c
Code: Select all
$ hours= divmod(int(renpy.get_game_runtime()), 3600)
$ minutes= divmod(int(renpy.get_game_runtime()), 60)
"You finished the game in %(hours)d and %(minutes)d minutes."
Code: Select all
$ hours= int(divmod(int(renpy.get_game_runtime()), 3600))
$ minutes= int(divmod(int(renpy.get_game_runtime()), 60))
I'm sorry, but an exception occured while executing your Ren'Py
script.
TypeError: int() argument must be a string or a number, not 'tuple'
While running game code:
- script at line 42 of E:\Renpy\SumoftheParts/game/endings.rpy
- python at line 42 of E:\Renpy\SumoftheParts/game/endings.rpy.
-- Full Traceback ------------------------------------------------------------
File "E:\Renpy\renpy\bootstrap.py", line 260, in bootstrap
File "E:\Renpy\renpy\main.py", line 308, in main
File "E:\Renpy\renpy\main.py", line 92, in run
File "E:\Renpy\renpy\execution.py", line 230, in run
File "E:\Renpy\renpy\ast.py", line 558, in execute
File "E:\Renpy\renpy\python.py", line 921, in py_exec_bytecode
File "E:\Renpy\SumoftheParts/game/endings.rpy", line 42, in <module>
TypeError: int() argument must be a string or a number, not 'tuple'
While running game code:
- script at line 42 of E:\Renpy\SumoftheParts/game/endings.rpy
- python at line 42 of E:\Renpy\SumoftheParts/game/endings.rpy.
Ren'Py Version: Ren'Py 6.9.3c
Code: Select all
if (hours < 1):
hours = renpy.get_game_runtime() / 3600
Code: Select all
if (hours < 1):
hours = renpy.get_game_runtime() / 3600
Yeah, that's true (albeit incredibly unlikely). Try:delta wrote:better hope get_game_runtime() does not return an integer, or you're going to have a lot of fun with that one.Code: Select all
if (hours < 1): hours = renpy.get_game_runtime() / 3600
Code: Select all
if (hours < 1):
hours = float(renpy.get_game_runtime()) / 3600
Users browsing this forum: Ahrefs [Bot]