renpy.input() in Android

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
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

renpy.input() in Android

#1 Post by xavimat »

I have a renpy.input() line in my game to ask the player's name. But it's not working in Android. Do I need to do something or simply is not (yet) a feature in Android?
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: renpy.input() in Android

#2 Post by PyTom »

It doesn't work in Android.
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

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: renpy.input() in Android

#3 Post by Tsapas »

You can still use user input by bypassing renpy.input for android and use this (not my code but could be handy):

Code: Select all

    # replace your renpy.input call with this.
    if not renpy.variant('touch') and povName == '':
        info "Please enter your name."
        $ povFirstName = renpy.input("What is your first name?") or "Name"
        $ povLastName = renpy.input("What is your last name?") or "Surname"
        $ povName = povFirstName +" "+povLastName
    
    if renpy.variant('touch') and povName == '':
        info "What is your first name? (leave blank for 'Name')"
        $ input_header = 'First name:'
        call inputter
        $ povFirstName = input_text or "Name"
        info "What is your last name? (leave blank for 'Surname')"
        $ input_header = 'Last name:'
        $ text_group = 1
        $ input_text = ''
        call inputter
        $ povLastName = input_text or "Surname"
        $ povName = povFirstName +" "+povLastName
The actual soft keyboard code is

Code: Select all

########################################################
#   Android keyboard input stuff, adapted from: http://lemmasoft.renai.us/forums/viewtopic.php?f=8&t=14985
python:
    text_list1=["Q","W","E","R","T","Y","U","I","O","P","0",
                      "A","S","D","F","G","H","J","K","L","0",
                      "Z","X","C","V","B","N","M","0"]
    text_list2=["q","w","e","r","t","y","u","i","o","p","0",
                      "a","s","d","f","g","h","j","k","l","0",
                      "z","x","c","v","b","n","m","0"]
    input_text = ''
    input_header = 'NAME:'
    text_limit = 16
    text_list=text_list1
    text_group=1
    
########################################################
#   More android keyboard input stuff, adapted from: http://lemmasoft.renai.us/forums/viewtopic.php?f=8&t=14985

label inputter:
    if text_group==1:
        $text_list=text_list1
    elif text_group==2:
        $text_list=text_list2
         
    $ ui.frame(xpos=0.5, ypos=0.1, xanchor=0.5, yanchor=0, xminimum=450)
    $ ui.vbox()
    $ ui.text(input_header+" "+input_text)
    $ ui.null(height=30)

    $ ui.hbox()
    $ ui.textbutton("Done", clicked=ui.returns("Done"))
    $ui.textbutton("Backspace", clicked=ui.returns("Backspace"))
    $ui.textbutton("Delete all", clicked=ui.returns("Deleteall"))
    if text_group==1:
        $ ui.textbutton("Caps (On)", clicked=ui.returns("lowercase"))
    elif text_group==2:
        $ ui.textbutton("Caps (Off)", clicked=ui.returns("uppercase"))
    $ ui.close()

    $ ui.null(height=10)

    $ ui.hbox(xalign= 0.5)
    python:
        for text_code in text_list:
            if text_code=="0":
                ui.close()
                ui.hbox(xalign= 0.5)
            elif  len(input_text)<=text_limit-1:
                ui.textbutton(text_code, clicked=ui.returns(text_code))
    $ ui.close()
    $ ui.close()
    $ button_selection=ui.interact()
               
    if button_selection=="Backspace":
        $ input_text=input_text[:-1]
        jump inputter
    elif button_selection=="Deleteall":
        $ input_text=''
        jump inputter
    elif button_selection=="uppercase":
        $text_group=1
        jump inputter
    elif button_selection=="lowercase":
        $text_group=2
        jump inputter
    elif button_selection=="Done":
        return
    $ select_text=button_selection

    python:
        for text_code in text_list:
            if select_text==text_code:
                input_text += text_code
    jump inputter
Again, this may be bloated for your needs, but should work anyway (I don't have an Android device to test it myself, but heard it works).

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: renpy.input() in Android

#4 Post by xavimat »

Thanks!
I'll check the code.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: renpy.input() in Android

#5 Post by qirien »

Hey, this is great! The only change I needed to make was to change the "python:" to "init python:" so it would run before everything else. I tested it on Android and it works great. Thank you!
Finished games:
Image
Image
Image

User avatar
stwkun
Regular
Posts: 82
Joined: Wed Jan 02, 2013 7:57 pm
Organization: Stw Projects
Contact:

Re: renpy.input() in Android

#6 Post by stwkun »

Hello friends, the code works perfectly :-) but it´s too small for my screen (1366x768) . How can I make bigger the keyboard?.

cosmo
Regular
Posts: 120
Joined: Mon Aug 29, 2011 11:01 am
Projects: | ZUKUNFT | Wayang Kulit - A Shadow Play (WIP version 0.1) |
Location: Germany
Contact:

Re: renpy.input() in Android

#7 Post by cosmo »

Oh, great! Will try this out! Thank you!

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: renpy.input() in Android

#8 Post by qirien »

stwkun, it just uses your default font size. I think it is small on purpose so that it will also work with phones that have smaller resolutions.

If you really want to make it larger, you'd probably need to make a new style and tell the text buttons to use it? I'm still learning about styles, so I'm not sure how to do that...
Finished games:
Image
Image
Image

User avatar
stwkun
Regular
Posts: 82
Joined: Wed Jan 02, 2013 7:57 pm
Organization: Stw Projects
Contact:

Re: renpy.input() in Android

#9 Post by stwkun »

qirien, I am trying to find the answer, but I couldn't . I modified many time the codes and I believe the solution could be in this line

Code: Select all

ui.textbutton(text_code, clicked=ui.returns(text_code)) 
I changed to this

Code: Select all

ui.textbutton("{size=30}\'text_code\'{/size} ",clicked=ui.returns(text_code))
but in the keyboard not apears the letters , only appears 'text code' , logic, isn't it?

I don't know how to make work "text_code" and also appears bigger in my screen

If someone find the solution, tell me please
Attachments
Sin título.png

User avatar
dyrarendy
Regular
Posts: 59
Joined: Wed Apr 02, 2014 12:26 pm
Projects: Visual Novel Dating Sims Masa SMA
Location: Indonesia, Cimahi
Contact:

Re: renpy.input() in Android

#10 Post by dyrarendy »

anyway.....

Code: Select all

init python:
    text_list1=["{size=+14}Q{/size}","{size=+14}W{/size}","{size=+14}E{/size}","{size=+14}R{/size}","{size=+14}T{/size}","
                     {size=+14}Y{/size}","{size=+14}U{/size}","{size=+14}I{/size}","{size=+14}O{/size}","{size=+14}P{/size}","0",
                      "{size=+14}A{/size}","{size=+14}S{/size}","{size=+14}D{/size}","{size=+14}F{/size}","{size=+14}G{/size}","
                         {size=+14}H{/size}","{size=+14}J{/size}","{size=+14}K{/size}","{size=+14}L{/size}","0",
                          "{size=+14}Z{/size}","{size=+14}X{/size}","{size=+14}C{/size}","{size=+14}V{/size}","{size=+14}B{/size}","
                             {size=+14}N{/size}","{size=+14}M{/size}","0"]
    text_list2=["{size=+14q{/size}","{size=+14}w{/size}","{size=+14}e{/size}","{size=+14}r{/size}","{size=+14}t{/size}","
                       {size=+14}y{/size}","{size=+14}u{/size}","{size=+14}i{/size}","{size=+14}o{/size}","{size=+14}p{/size}","0",
                           "{size=+14}a{/size}","{size=+14}s{/size}","{size=+14}d{/size}","{size=+14}f{/size}","{size=+14}g{/size}","
                              {size=+14}h{/size}","{size=+14}j{/size}","{size=+14}k{/size}","{size=+14}l{/size}","0",
                                "{size=+14}z{/size}","{size=+14}x{/size}","{size=+14}c{/size}","{size=+14}v{/size}","{size=+14}b{/size}",
                                   "{size=+14}n{/size}","{size=+14}m{/size}","0"]

Code: Select all

  $ ui.textbutton("{size=+10}Selesai{/size}", clicked=ui.returns("Done"))
    $ui.textbutton("{size=+10}Hapus{/size}", clicked=ui.returns("Backspace"))
    $ui.textbutton("{size=+10}Hapus Semua{/size}", clicked=ui.returns("Deleteall"))
    if text_group==1:
        $ ui.textbutton("{size=+10}Caps (On){/size}", clicked=ui.returns("lowercase"))
    elif text_group==2:
        $ ui.textbutton("{size=+10}Caps (Off){/size}", clicked=ui.returns("uppercase"))

Code: Select all

    if button_selection=="Backspace":
        $ input_text=input_text[:-18]
        jump inputter
Dont change per letter, just "replace all" : ( ," with ,"{size=+14} ) and ( ", with {/size}", )

or, try this :
http://www.kreativrauschen.com/blog/200 ... -in-renpy/
Attachments
Capture.JPG

User avatar
stwkun
Regular
Posts: 82
Joined: Wed Jan 02, 2013 7:57 pm
Organization: Stw Projects
Contact:

Re: renpy.input() in Android

#11 Post by stwkun »

I tried this modification before and looks like it worked, but when the game start the name from character appears with diferent size from the the script, also when you put a name then you decide erased the text, the game failed.

I found a posible solution, I tried this

Code: Select all

ui.textbutton('{size=+50}     {/size}', clicked=ui.returns(text_code))
I modify this line, with empty button, the I created a Keyboard in png (teclado.png)

Code: Select all

            $ input_header = 'Ingrese apellido:'
            show teclado 
well, with this is the solution that I found
Attachments
Sin título.png
TECLADO.png
TECLADO.png

User avatar
dyrarendy
Regular
Posts: 59
Joined: Wed Apr 02, 2014 12:26 pm
Projects: Visual Novel Dating Sims Masa SMA
Location: Indonesia, Cimahi
Contact:

Re: renpy.input() in Android

#12 Post by dyrarendy »

great idea, to make keyboard.png

but, is it really { size 50 } ?

Code: Select all

                ui.textbutton('{size=+50}     {/size}', clicked=ui.returns(text_code))
what resolution your game now ?

User avatar
dyrarendy
Regular
Posts: 59
Joined: Wed Apr 02, 2014 12:26 pm
Projects: Visual Novel Dating Sims Masa SMA
Location: Indonesia, Cimahi
Contact:

Re: renpy.input() in Android

#13 Post by dyrarendy »

I think its done now.

Well, I make a New Thread for this, feel free to visits :

http://lemmasoft.renai.us/forums/viewto ... 07#p317807

User avatar
stwkun
Regular
Posts: 82
Joined: Wed Jan 02, 2013 7:57 pm
Organization: Stw Projects
Contact:

Re: renpy.input() in Android

#14 Post by stwkun »

Great, you also solve the last part, put caps (on - off.) thank you :D

I have another problem, I am trying to solve but until now I couldn't
I would like you help me to find the solution

:arrow: http://lemmasoft.renai.us/forums/viewto ... =8&t=25908

Post Reply

Who is online

Users browsing this forum: Google [Bot]