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.
My save code is a bit of a hodgepodge between imagebutton GUI interface and the standard save code that the project starts with, so I don't know if that's where the problem lies, but key "save_delete" action FileDelete(number) doesn't allow me to hover and hit the delete key to get rid of saves like it should? I'm not sure if i have the keybinding in the wrong section or what. Any help is appreciated!
## ■██▓▒░ SAVE / LOAD SLOT ░▒▓██████████████████████████████■
## This represents a load/save slot. You should customize this to ensure that the placement of the thumbnail and the slot text are as desired. Positions (x1, y1, x2 and y2) are relative to the x, y parameters, that are passed when the screen is called. To set the screenshot thumbnail size see options.rpy.
init -2 python: #we initialize x and y, so the load_save_slot screen below works at startup
x=0
y=0
screen load_save_slot:
$ file_text = "% 2s. %s\n%s" % (
FileSlotName(number, 4),
FileTime(number, empty=_("Empty Slot")),
FileSaveName(number))
$ save_name = FileSaveName(i)
$x1=x+321
$y1=y+10
add FileScreenshot(number) xpos x1 ypos y1
$x2=x+10
$y2=y+11
text file_text xpos x2 ypos y2 size 25
key "save_delete" action FileDelete(number)
## ■██▓▒░ SAVE SCREEN ░▒▓███████████████████████████████████■
screen save:
tag menu
# This ensures that any other menu screen is replaced.
add "GUI/save base.png" # We add the file picker background image. This image is the same for save and load screens.
use file_picker # We include the file_picker screen
## ■██▓▒░ LOAD SCREEN ░▒▓███████████████████████████████████■
screen load:
tag menu # This ensures that any other menu screen is replaced.
add "GUI/save base.png"
use file_picker
## ■██▓▒░ FILE PICKER ░▒▓███████████████████████████████████■
## Since saving and loading are so similar, we combine them into a single screen, file_picker. We then use the file_picker screen from simple load and save screens.
screen file_picker:
use navigation # We include the navigation/game menu screen
# Buttons for selecting the save/load page:
#imagebutton auto "GUI/filepage1_%s.png" xpos 46 ypos 104 focus_mask True action FilePage(1)
#imagebutton auto "GUI/filepage2_%s.png" xpos 46 ypos 228 focus_mask True action FilePage(2)
#imagebutton auto "GUI/filepage3_%s.png" xpos 46 ypos 353 focus_mask True action FilePage(3)
$ y=115 # ypos for the first save slot
frame xpos 420 ypos 30:
hbox:
textbutton _("Previous"):
action FilePagePrevious()
textbutton _("Auto"):
action FilePage("auto")
textbutton _("Quick"):
action FilePage("quick")
for i in range(1, 17): # This repeats the block below 3 times (counts from 0 to 2), for the 3 save slots. We could also copy/paste the block below 3 times, but we are too lazy to do that.
textbutton str(i):
action FilePage(i)
textbutton _("Next"):
action FilePageNext()
#grid 2 5:
#transpose True
#style_group "file_picker"
for i in range(1, 6): # This repeats the block below 3 times (counts from 0 to 2), for the 3 save slots. We could also copy/paste the block below 3 times, but we are too lazy to do that.
imagebutton auto "GUI/saveslot_%s.png" xpos 423 ypos y focus_mask True action FileAction(i)
use load_save_slot(number=i, x=423, y=y)
$ y+=185 # We increase the y variable so every next save slot is moved 124px lower.
$y=115
for i in range(6, 11): # This repeats the block below 3 times (counts from 0 to 2), for the 3 save slots. We could also copy/paste the block below 3 times, but we are too lazy to do that.
imagebutton auto "GUI/saveslot_%s.png" xpos 970 ypos y focus_mask True action FileAction(i)
use load_save_slot(number=i, x=970, y=y) # This calls the load_save_slot screen defined above. We pass variable i as the slot number and x, y coordinates.
$ y+=185 # We increase the y variable so every next save slot is moved 124px lower.
Obviously can't test it myself, but based on the default screens, it seems like the key "save_delete" line should be in the imagebuttons in the file_picker, not in the load/save slot.
for i in range(1, 6): # This repeats the block below 3 times (counts from 0 to 2), for the 3 save slots. We could also copy/paste the block below 3 times, but we are too lazy to do that.
imagebutton:
auto "GUI/saveslot_%s.png"
xpos 423
ypos y
focus_mask True
action FileAction(i)
key "save_delete" action FileDelete(number)
use load_save_slot(number=i, x=423, y=y)
$ y+=185 # We increase the y variable so every next save slot is moved 124px lower.
Upping this thread as I thought of the same approach as philat, then discovered like Kshimimi that imagebuttons do not take a key statement. Is there a way to make the save_delete key work with an imagebutton save GUI?
Setting a "key" to an "imagebutton" still doesn't seem to work, throws an error stating "u'key' is not a keyword argument or valid child for the imagebutton statement." Am I doing something wrong? My code is similar to the second reply of this topic and is for the file picker as well.
I started doing that previously but I failed at learning how to get the "auto" working for buttons like imagebuttons for the "_idle," "_hover", "_selected_idle," etc., working. At least how to get hover working? Sorry, I am indeed a Ren'Py newbie.
3dmasons wrote:I started doing that previously but I failed at learning how to get the "auto" working for buttons like imagebuttons for the "_idle," "_hover", "_selected_idle," etc., working. At least how to get hover working? Sorry, I am indeed a Ren'Py newbie.
Thank you for your reply, PyTom.
auto Used to automatically define the images used by this button. This should be a string that contains %s in it. If it is, and one of the image properties is omitted, %s is replaced with the name of that property, and the value is used as the default for that property.
For example, in your given case, you can do something like:
imagebutton auto "mybutton_%s.png" action ShowMenu('save')
THEN in the image folder, create mybutton_idle.png, mybutton_hover.png, and so on.
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.