ValueError with code I removed?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
voluorem
Newbie
Posts: 6
Joined: Fri Jun 24, 2022 3:32 pm
Projects: Sweet Release
Discord: voluorem#7105
Contact:

ValueError with code I removed?

#1 Post by voluorem » Sat Jul 30, 2022 6:32 pm

I'm getting a ValueError when I try and show my save screen, but the traceback shows a line of code I deleted. Here's the code I'm using:

Code: Select all

default playtime = 0

init python:

    def save_playtime(d):
        renpy.store.playtime += renpy.get_game_runtime()
        renpy.clear_game_runtime()
        d["playtime"] = renpy.store.playtime

    config.save_json_callbacks = [save_playtime]
    
screen file_slots(title):
    imagebutton:
        idle "gui/backgrounds/return_bg.png"
        hover "gui/backgrounds/return_bg.png"
        action Hide("save")

    add "gui/backgrounds/notesbg.png" at app_open xalign 0.5
    default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))
    frame at app_open:
        background None
        viewport:
            xpos 0
            ypos 50
            xfill False
            yfill False
            ymaximum 550
            mousewheel True

            grid gui.file_slot_cols gui.file_slot_rows at app_open:
                style_prefix "slot"

                xalign 0.5
                yalign 0.5

                spacing gui.slot_spacing

                for i in range(gui.file_slot_cols * gui.file_slot_rows):

                    $ slot = i + 1

                    button:
                        action [SetVariable("save_name", "%s"%calendar.string3()), FileAction(slot)]

                        has vbox

                        text FileSaveName(slot):
                            font "gui/fonts/Lato-Bold.ttf"
                            color "#9D755A"
                        $ playtime = FileJson(slot, "playtime", empty=0, missing=0) ## deleting this line got rid of the ValueError if that helps at all
                        $ minutes, seconds = divmod(int(playtime), 60)
                        $ hours, minutes = divmod(minutes, 60)
                        text "[hours]:[minutes]"
                        key "save_delete" action FileDelete(slot)
And this is the traceback:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 560, in script call
    call roomload
  File "game/technical.rpy", line 220, in script
    $ renpy.call_screen(place + "_" + current_room + "int")
  File "game/technical.rpy", line 220, in <module>
    $ renpy.call_screen(place + "_" + current_room + "int")
  File "game/screens.rpy", line 615, in execute
    screen save():
  File "game/screens.rpy", line 615, in execute
    screen save():
  File "game/screens.rpy", line 619, in execute
    use file_slots(_("Save"))
  File "game/screens.rpy", line 629, in execute
    screen file_slots(title):
  File "game/screens.rpy", line 629, in execute
    screen file_slots(title):
  File "game/screens.rpy", line 637, in execute
    frame at app_open:
  File "game/screens.rpy", line 639, in execute
    viewport:
  File "game/screens.rpy", line 647, in execute
    grid gui.file_slot_cols gui.file_slot_rows at app_open:
  File "game/screens.rpy", line 655, in execute
    for i in range(gui.file_slot_cols * gui.file_slot_rows):
  File "game/screens.rpy", line 659, in execute
    button:
  File "game/screens.rpy", line 662, in execute
    has vbox
  File "game/screens.rpy", line 668, in execute
    $ minutes, seconds = divmod(int(playtime), 60)
  File "game/screens.rpy", line 668, in <module>
    $ minutes, seconds = divmod(int(playtime), 60)
ValueError: invalid literal for int() with base 10: '[hours_display] : [minutes_display]'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 560, in script call
    call roomload
  File "game/technical.rpy", line 220, in script
    $ renpy.call_screen(place + "_" + current_room + "int")
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\ast.py", line 1131, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\python.py", line 1049, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/technical.rpy", line 220, in <module>
    $ renpy.call_screen(place + "_" + current_room + "int")
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\exports.py", line 3161, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\core.py", line 3377, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs) # type: ignore
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\core.py", line 3804, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\core.py", line 582, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\core.py", line 582, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\core.py", line 582, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\screen.py", line 451, in visit_all
    callback(self)
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\core.py", line 3804, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\screen.py", line 462, in per_interact
    self.update()
  File "C:\Users\thepr\Downloads\renpy-7.4.11-sdk\renpy\display\screen.py", line 653, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 615, in execute
    screen save():
  File "game/screens.rpy", line 615, in execute
    screen save():
  File "game/screens.rpy", line 619, in execute
    use file_slots(_("Save"))
  File "game/screens.rpy", line 629, in execute
    screen file_slots(title):
  File "game/screens.rpy", line 629, in execute
    screen file_slots(title):
  File "game/screens.rpy", line 637, in execute
    frame at app_open:
  File "game/screens.rpy", line 639, in execute
    viewport:
  File "game/screens.rpy", line 647, in execute
    grid gui.file_slot_cols gui.file_slot_rows at app_open:
  File "game/screens.rpy", line 655, in execute
    for i in range(gui.file_slot_cols * gui.file_slot_rows):
  File "game/screens.rpy", line 659, in execute
    button:
  File "game/screens.rpy", line 662, in execute
    has vbox
  File "game/screens.rpy", line 668, in execute
    $ minutes, seconds = divmod(int(playtime), 60)
  File "game/screens.rpy", line 668, in <module>
    $ minutes, seconds = divmod(int(playtime), 60)
ValueError: invalid literal for int() with base 10: '[hours_display] : [minutes_display]'

Windows-10-10.0.22000 AMD64
Ren'Py 8.0.1.22070801
Sweet Release 1.0
Sat Jul 30 15:21:55 2022
I can't find [hours_display] : [minutes_display] anywhere (because I deleted it from my code). Is this some kind of cache issue? I cleared the cache and saves folders and deleted the persistent data, which still didn't fix it.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: ValueError with code I removed?

#2 Post by Imperf3kt » Sat Jul 30, 2022 9:01 pm

The final 5 lines of what you posted (minus the very last line) are where this error is coming from.

Code: Select all

                        $ playtime = FileJson(slot, "playtime", empty=0, missing=0) ## deleting this line got rid of the ValueError if that helps at all
                        $ minutes, seconds = divmod(int(playtime), 60)
                        $ hours, minutes = divmod(minutes, 60)
                        text "[hours]:[minutes]"
The first line creates the data and adds it to the save data so it can be used.
The next two lines appear to set or get the time played for the save file and the last line displays that information to the player on the screen.

you have to delete all of these lines if you wish to remove this playtime counter from your save/load screens
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

voluorem
Newbie
Posts: 6
Joined: Fri Jun 24, 2022 3:32 pm
Projects: Sweet Release
Discord: voluorem#7105
Contact:

Re: ValueError with code I removed?

#3 Post by voluorem » Sun Jul 31, 2022 12:07 am

But it says the error is from [hours_display] : [minutes_display], not [hours]:[minutes]. I tried doing something else using hours_display and minutes_display (which didn't work, so I took it out), but it's still giving me errors like it's still there for some reason.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: ValueError with code I removed?

#4 Post by Alex » Sun Jul 31, 2022 8:04 am

voluorem wrote:
Sun Jul 31, 2022 12:07 am
But it says the error is from [hours_display] : [minutes_display], not [hours]:[minutes]. I tried doing something else using hours_display and minutes_display (which didn't work, so I took it out), but it's still giving me errors like it's still there for some reason.
Did you restore game frome save? Don't use old saves when you changing your script - start a new game or use reload function.
Also such an error could occur when you deleted some rpy file, but not the corresponding rpyc file. Ren'Py uses rpyc files (it creates/updates them on project start), so try to delete all rpyc files (not rpy) and run your project.

voluorem
Newbie
Posts: 6
Joined: Fri Jun 24, 2022 3:32 pm
Projects: Sweet Release
Discord: voluorem#7105
Contact:

Re: ValueError with code I removed?

#5 Post by voluorem » Sun Jul 31, 2022 4:50 pm

I tried deleting all of the rpyc files and all of the saves and that still didn't fix it. I also tried clearing the cache and that also didn't do anything.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: ValueError with code I removed?

#6 Post by Ocelot » Sun Jul 31, 2022 5:04 pm

Show your save screen. How you store data in file in particular. Error you got means that there is '[hours_display] : [minutes_display]' line stored within save file. Which is not a number. That is why integer conversion routine throws an error. Either you have old stray save file here, or you are saving data wrong.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], minyan