Saveslot Delete issue (solved)

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
User avatar
Smaymay
Regular
Posts: 70
Joined: Fri Jul 01, 2016 11:35 am
Completed: Vicboys demo
Tumblr: esmmeh
Deviantart: Smaymay
Location: The Netherlands
Contact:

Saveslot Delete issue (solved)

#1 Post by Smaymay »

Hi! I finally managed to code a Save/Load screen with help from the Imagebutton GUI Framework from Uncle Mugen and Leon. But there seems to be a problem when I want to delete a Save File.

Image Image

When I hover over a saveslot and press the delete button on my keyboard, it's always the last Save File that will be deleted. It's not possible to delete another Save File on the current filepage either. I pasted the relevant code from the file_picker screen below. I hope someone knows what went wrong. Thanks in advance! :)

Code: Select all

#SAVE SLOTS
    $ x=229                     # xpos for the first save slot framework
    for j in range(0, 3):       # 3 Columns
        $ y = 238               # ypos of the top slot in the first column
        for k in range(0,2):    # 2 rows with slots in each column. 
            $ i = j*2+k         # total number of saveslots
            imagebutton:
                auto "images/GUI/loadscreen/saveslot_%s.png" 
                xpos x ypos y focus_mask True 
                action FileAction(i)                    
                hovered [ Play ("Soundeffect_2", "audio/soundeffects/menu_hover.wav") ]
            use load_save_slot(number=i, x=x, y=y)      # call the load_save_slot screen 
            $ y+=319                                    # move every next saveslot 319px lower.
        $ x += 486                                      # move every next column of saveslots 486px to the right.

# Allows the player to delete a saved game file
    key "save_delete" action FileDelete(i) 

init -2 python:
    config.thumbnail_width = 366                        #width of saved game screenshot to appear in the save slot framework
    config.thumbnail_height = 206                       #height of saved game screenshot to appear in the save slot framework
    
Last edited by Smaymay on Tue Aug 02, 2016 11:11 am, edited 1 time in total.

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Saveslot Delete issue

#2 Post by DragoonHP »

You need to indent key "save_delete" more.

Code: Select all

#SAVE SLOTS
    $ x=229                     # xpos for the first save slot framework
    for j in range(0, 3):       # 3 Columns
        $ y = 238               # ypos of the top slot in the first column

        for k in range(0,2):    # 2 rows with slots in each column.
            $ i = j*2+k         # total number of saveslots

            imagebutton:
                auto "images/GUI/loadscreen/saveslot_%s.png"
                xpos x ypos y focus_mask True
                action FileAction(i)                   
                hovered [ Play ("Soundeffect_2", "audio/soundeffects/menu_hover.wav") ]

            use load_save_slot(number=i, x=x, y=y)      # call the load_save_slot screen

            # Allows the player to delete a saved game file
             key "save_delete" action FileDelete(i) 

            $ y+=319                                    # move every next saveslot 319px lower.
        $ x += 486                                      # move every next column of saveslots 486px to the right.


User avatar
Smaymay
Regular
Posts: 70
Joined: Fri Jul 01, 2016 11:35 am
Completed: Vicboys demo
Tumblr: esmmeh
Deviantart: Smaymay
Location: The Netherlands
Contact:

Re: Saveslot Delete issue

#3 Post by Smaymay »

@DragoonHP

Thank you for replying!

I tried to indent key "save_delete" more just like in your example but I got the following error:

Code: Select all

File "game/screens.rpy", line 392: Line is indented, but the preceding use statement statement does not expect a block. Please check this line's indentation.
    key "save_delete" action FileDelete(i) 
    ^

Ren'Py Version: Ren'Py 6.99.10.1227
I'm still not quite used to proper indentation so I'm sorry if the solution is obvious.

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Saveslot Delete issue

#4 Post by DragoonHP »

My mistake. I put in a extra space before key. key and use should be in the same indent.

User avatar
Smaymay
Regular
Posts: 70
Joined: Fri Jul 01, 2016 11:35 am
Completed: Vicboys demo
Tumblr: esmmeh
Deviantart: Smaymay
Location: The Netherlands
Contact:

Re: Saveslot Delete issue

#5 Post by Smaymay »

@DragoonHP

No worries! I removed the extra space before "key" and the error disappeared!
But sadly it did not fix my delete problem. Thank you anyways for your help. I appreciate it.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Saveslot Delete issue

#6 Post by gas »

1: KEY must be tied to the single button, as a child. The way you define it is tied to the screen as a whole (that's why it work on the latest save).
2: BUTTON can have childs, IMAGEBUTTON not at all.

So change your imagebuttons to buttons.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Saveslot Delete issue

#7 Post by Tayruu »

I'm a little confused about what i is supposed to refer to. It's used as the "index of the current button", but labelled as the total save slots.
And as gas said, the way it's indented means it's not being associated with the buttons, it needs to be inside the button block. (But if an imagebutton doesn't accept it, it might not work...)

My save screen uses one block for both columns and rows, but I'm also using a grid rather then specifying absolute values for x/y. It might make things simpler for you to use a grid and styles to line everything up. This is unrelated to the problem at hand though.

User avatar
Smaymay
Regular
Posts: 70
Joined: Fri Jul 01, 2016 11:35 am
Completed: Vicboys demo
Tumblr: esmmeh
Deviantart: Smaymay
Location: The Netherlands
Contact:

Re: Saveslot Delete issue

#8 Post by Smaymay »

Thank you both for your reply.

I'll try to replace my imgagebuttons with regular buttons. I haven't used buttons and styling before
but I will look at the Ren'py documentation some more.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]