Player Can Adjust Keymap?

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
Andredron
Miko-Class Veteran
Posts: 719
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Player Can Adjust Keymap?

#1 Post by Andredron »

When a player clicks on a button, a screen will appear, allowing them to choose any key on their keyboard to reassign for a specific in-game action.

For instance, normally, you'd use the "S" key for taking a screenshot. But, if you click a specific button, a menu pops up allowing you to choose a different key – say, "Z," to switch up your screenshot button.

Is there a way to do this?
https://www.reddit.com/r/RenPy/comments ... st_keymap/

Wandered to reddit and saw this question, and myself became interested in how to do this, please advise please

User avatar
Andredron
Miko-Class Veteran
Posts: 719
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Player Can Adjust Keymap?

#2 Post by Andredron »

An acquaintance suggested an option on how to realize something like this.....

##########

Code: Select all

default persistent.keymap = {}

label start:
    "Standard voiceover input (now [config.keymap[self_voicing]])"
    $ persistent.keymap['self_voicing'] = renpy.input(u "Replace with new ", length = 1)
    $ config.keymap['self_voicing']= [persistent.keymap['self_voicing']]
    $ renpy.clear_keymap_cache()
    "Now [config.keymap[self_voicing]]''
    return
The modified layout is written to persistent.keymap. This is to make sure it doesn't roll back the next time you run the game:

Code: Select all

label splashscreen:
    python:
        for k, v in config.keymap.items():
            if k in persistent.keymap.keys():
                config.keymap[k] = persistent.keymap[k]
    $ renpy.clear_keymap_cache()
    return
I think that if you create a separate menu for these settings, you need to loop for loop through the options in config.keymap.


##########

But I remember in the old version on the joystick were other commands and do not remember already.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Player Can Adjust Keymap?

#3 Post by PyTom »

There really isn't a good way to do this yet.

I'm considering adding it, but it's a lot of work, and I don't have a great feeling as to how many people would use it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Andredron
Miko-Class Veteran
Posts: 719
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Player Can Adjust Keymap?

#4 Post by Andredron »

PyTom wrote: Fri Dec 22, 2023 10:07 pm There really isn't a good way to do this yet.

I'm considering adding it, but it's a lot of work, and I don't have a great feeling as to how many people would use it.
👍👍👍👍👍

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot]