Keybindings Not Always Working

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
majike
Newbie
Posts: 16
Joined: Thu Feb 04, 2016 4:28 am
Contact:

Keybindings Not Always Working

#1 Post by majike » Thu Oct 11, 2018 9:25 pm

I've been having a problem I just can't figure out, with me being none-the-wiser on how to solve this after searching through the forums and official documentation.

I'm working upon an entirely text-based game within Renpy (due to Renpy being awesome, featuring the programming I am most comfortable with, and an intense dislike of 'you must download an interpreter to play my games' thing that many text games feature). While I have been able to generally create a main menu that works and in-game menu that does what it should do (IE, main menu keymap for B starts the game, O opens the options menu; in-game, space advances until a menu occurs, Q brings to a do-you-want-to-quit screen).

However, when I first arrive at the options screen from the main menu, the keymapped button for R (to go back to the main menu) doesn't work. After selecting one of the colour-changing options (say, pressing 7, which sends it through label option_process), I end up back in the options menu (as intended) and the key-maps then work once more. At that point, however, I can't use the O button to get back to the options menu.

I've included a snippet of screens, with all the stuff on options and main menu (minus some spammy purely text stuff in the main menu that does nothing except display text), in case it might help.
##############################################################################
# Options Screen (Attempt)
#

screen options:

image "#000000"

key "K_r" action ShowMenu("main_menu")
key "K_q" action NullAction()
key "K_b" action NullAction()
key "K_s" action NullAction()
key "K_o" action NullAction()


#### Colour Palette

key "K_6" action [SetVariable("colorset", "gb"), SetVariable("optionchange", "1"), Jump("option_process")]

key "K_7" action [SetVariable("colorset", "wb"), SetVariable("optionchange", "1"), Jump("option_process")]

key "K_2" action [SetVariable("colorset", "cr"), SetVariable("optionchange", "1"), Jump("option_process")]

key "K_5" action [SetVariable("colorset", "fc"), SetVariable("optionchange", "1"), Jump("option_process")]

key "K_4" action [SetVariable("colorset", "bw"), SetVariable("optionchange", "1"), Jump("option_process")]

key "K_3" action [SetVariable("colorset", "gold"), SetVariable("optionchange", "1"), Jump("option_process")]

key "K_1" action [SetVariable("colorset", "muck"), SetVariable("optionchange", "1"), Jump("option_process")]

# Add an in-game quick menu.
hbox:
style_group "quick"

xalign 0.25
yalign 0.3
xminimum int(config.screen_width * 0.3)
xmaximum int(config.screen_width * 0.3)

text "Colour Palette\n\n[[1] ASCII Colour\n[[2] Black Text on Cream\n[[3] Black Text on Gold\n[[4] Black Text on White\n[[5] Full Colour\n[[6] Green Text on Black\n[[7] White Text on Black\n"

hbox:
style_group "quick"

xalign 0.75
yalign 0.3
xminimum int(config.screen_width * 0.4)
xmaximum int(config.screen_width * 0.4)

text "Progress\n\nCAUTION: These actions\nare irreversible\n\n[[N] Start a New Game\n\n[[W] Wipe All Progress,\nIncluding Achievements"

hbox:
style_group "quick"

xalign 0.5
yalign 0.9
xminimum int(config.screen_width * 0.4)
xmaximum int(config.screen_width * 0.4)

text "[[R] Return to the Main Menu"


label option_process:

if colorset == "gb":
$persistent.optionchange = "1"
$persistent.colorset = "gb"
$style.default.color = "#00ff00"
$style.rebuild()
elif colorset == "cr":
$persistent.optionchange = "1"
$persistent.colorset = "cr"
$style.default.color = "#000000"
$style.rebuild()
elif colorset == "fc":
$persistent.optionchange = "1"
$persistent.colorset = "fc"
$style.default.color = "#d0d1d3"
$style.rebuild()
elif colorset == "bw":
$persistent.optionchange = "1"
$persistent.colorset = "bw"
$style.default.color = "#000000"
$style.rebuild()
elif colorset == "wb":
$persistent.optionchange = "1"
$persistent.colorset = "wb"
$style.default.color = "#ffffff"
$style.rebuild()
elif colorset == "gold":
$persistent.optionchange = "1"
$persistent.colorset = "gold"
$style.default.color = "#000000"
$style.rebuild()
elif colorset == "muck":
$persistent.optionchange = "1"
$persistent.colorset = "muck"
$style.default.color = "#cccccc"
$style.rebuild()

call screen options


##############################################################################
# Main Menu
#
# Screen that's used to display the main menu, when Ren'Py first starts
# http://www.renpy.org/doc/html/screen_sp ... #main-menu

init python:
if persistent.optionchange == None:
persistent.optionchange = "0"
optionchange = "0"
colorset = "wb"

init:

$ ingame = "0"

if persistent.optionchange == "0":
$ persistent.colorset = "wb"
else:
if persistent.colorset == "gb":
$style.default.color = "#00ff00"
$style.menu_choice.color = "#00ff00"
$style.input.color = "#00ff00"
$style.rebuild()
elif persistent.colorset == "cr":
$style.default.color = "#000000"
$style.menu_choice.color = "#000000"
$style.input.color = "#000000"
$style.rebuild()
elif persistent.colorset == "fc":
$style.default.color = "#d0d1d3"
$style.menu_choice.color = "#000000"
$style.input.color = "#000000"
$style.rebuild()
elif persistent.colorset == "bw":
$style.default.color = "#000000"
$style.menu_choice.color = "#000000"
$style.input.color = "#000000"
$style.rebuild()
elif persistent.colorset == "wb":
$style.default.color = "#ffffff"
$style.menu_choice.color = "#ffffff"
$style.input.color = "#ffffff"
$style.rebuild()
elif persistent.colorset == "gold":
$style.default.color = "#000000"
$style.menu_choice.color = "#000000"
$style.input.color = "#000000"
$style.rebuild()
elif persistent.colorset == "muck":
$style.default.color = "#cccccc"
$style.menu_choice.color = "#0080ff"
$style.input.color = "#0080ff"
$style.rebuild()
else:
$style.default.color = "#000000"
$style.menu_choice.color = "#"
$style.input.color = "#"

screen main_menu():

if persistent.colorset == "gb":
image "main_menu_green.png"
elif persistent.colorset == "cr":
image "main_menu_cream.png"
elif persistent.colorset == "fc":
image "main_menu_fc.png"
elif persistent.colorset == "bw":
image "main_menu_white.png"
elif persistent.colorset == "gold":
image "main_menu_gold.png"
elif persistent.colorset == "wb":
image "main_menu.png"
elif persistent.colorset == "muck":
image "main_menu_muck.png"

tag menu

key "K_r" action NullAction()
key "K_o" action ShowMenu("options")
key "K_e" action ShowMenu("extras_menu")
key "K_s" action NullAction()
key "K_q" action Quit()
key "mouseup_1" action NullAction()

if persistent.gamestarted == 1:
key "K_l" action FileLoad(3, confirm=False)
key "K_r" action Start()
else:
key "K_l" action FileLoad(3, confirm=False)
key "K_b" action Start()

# Text stuff edited out for length
If anyone can help shed some light on where I'm going wrong, I would be eternally grateful!

philat
Eileen-Class Veteran
Posts: 1435
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Keybindings Not Always Working

#2 Post by philat » Thu Oct 11, 2018 10:02 pm

You have R set to NullAction() in the screen main_menu, which I believe is conflicting with the action in options. Try tagging options with menu.

majike
Newbie
Posts: 16
Joined: Thu Feb 04, 2016 4:28 am
Contact:

Re: Keybindings Not Always Working

#3 Post by majike » Thu Oct 11, 2018 10:20 pm

philat wrote:
Thu Oct 11, 2018 10:02 pm
You have R set to NullAction() in the screen main_menu, which I believe is conflicting with the action in options. Try tagging options with menu.
Goodness! Tagging options with menu (and I think removing the R setting in main-menu) solved the issue! Thank you very much! :D

Post Reply

Who is online

Users browsing this forum: APD13