Ask character's name in Android
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.
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.
Ask character's name in Android
Hey there!
I have a little problem with a game. I've written an easy code where a character asks the player "what's your name", so the player write it.
I know how to do that and it works well on a computer but... when I test it in Android... I can't write!!! The keyboard doesn't appear, and that's why the player can't do anything...
Does anyone know why this happen? Maybe it's necessary to use other code or just it doesn't works in Android.
An example of what I wrote:
$ player_name = renpy.input("What is your name?")
if player_name == "":
$ player_name="Anonymous"
e "Pleased to meet you, %(player_name)s!"
Thank you!
I have a little problem with a game. I've written an easy code where a character asks the player "what's your name", so the player write it.
I know how to do that and it works well on a computer but... when I test it in Android... I can't write!!! The keyboard doesn't appear, and that's why the player can't do anything...
Does anyone know why this happen? Maybe it's necessary to use other code or just it doesn't works in Android.
An example of what I wrote:
$ player_name = renpy.input("What is your name?")
if player_name == "":
$ player_name="Anonymous"
e "Pleased to meet you, %(player_name)s!"
Thank you!
-
- Veteran
- Posts: 356
- Joined: Tue Aug 12, 2008 12:02 pm
- Projects: Valentine Square (writer) Spiral Destiny (programmer)
- Location: The treacherous Brazilian Rainforest
- Contact:
Re: Ask character's name in Android
Worst case, you can use a soft keyboard: http://www.renpy.org/wiki/renpy/frameworks/SoftKeyboard
Keep your script in your Dropbox folder.
It allows you to share files with your team, keeps backups of previous versions, and is ridiculously easy to use.
It allows you to share files with your team, keeps backups of previous versions, and is ridiculously easy to use.
Re: Ask character's name in Android
Thanks but I saw that there is an "android.show_keyboard" and "android.hide_keyboard" functions. But I don't know how to use them...
Anyone knows how to??
Thanks!!
Anyone knows how to??
Thanks!!
- PyTom
- Ren'Py Creator
- Posts: 16088
- 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: Ask character's name in Android
The keyboard doesn't work in Android yet.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: Ask character's name in Android
Oohh...well, I think I need it to my game :S But it's ok.
I guess there will be in the next version o later?
Thank you PyTom!
I guess there will be in the next version o later?
Thank you PyTom!
Re: Ask character's name in Android
It should work in Android.
Code: Select all
init 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 = ''
text_limit = 20
text_list=text_list1
text_group=1
label start:
"What is your name?"
call inputter
$ playername=input_text
"Nice to meet you, [playername]."
return
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("NAME:"+input_text)
$ ui.null(height=30)
$ ui.hbox()
if text_group==1:
$ ui.textbutton("Upper Case")
$ ui.textbutton("Lower Case", clicked=ui.returns("locase"))
elif text_group==2:
$ ui.textbutton("Upper Case", clicked=ui.returns("upcase"))
$ ui.textbutton("Lower Case")
$ ui.close()
if input_text:
$ ui.hbox()
$ ui.textbutton("Done", clicked=ui.returns("Done"))
$ui.textbutton("Backspace", clicked=ui.returns("Backspace"))
$ui.textbutton("Delete all", clicked=ui.returns("Deleteall"))
$ ui.close()
else:
$ ui.hbox()
$ ui.textbutton("Done")
$ui.textbutton("Backspace", clicked=ui.returns("Backspace"))
$ui.textbutton("Delete all", clicked=ui.returns("Deleteall"))
$ ui.close()
$ 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=="upcase":
$text_group=1
jump inputter
elif button_selection=="locase":
$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
Last edited by shuen on Mon May 07, 2012 8:51 am, edited 4 times in total.
Re: Ask character's name in Android
Oh yeah shuen, you're fucking awsome!! xD. I used that code and made other changes like add numbers, an "space" button, the letter "ñ" for spanish... And it works perfectly well on Android!
Just great Also with this new knowlodge I had other ideas to do in a game.
Thank you!
Just great Also with this new knowlodge I had other ideas to do in a game.
Thank you!
Re: Ask character's name in Android
This code is originally from the korea inputter.
It also help me alot to make my Chinese inputter.
People always helping each other and would like to share their code that why I love this forum and Ren'py.
P.s. I change the code above, Just find out the prepare_text is useless for english inputter....
It also help me alot to make my Chinese inputter.
People always helping each other and would like to share their code that why I love this forum and Ren'py.
P.s. I change the code above, Just find out the prepare_text is useless for english inputter....
Re: Ask character's name in Android
Yes, I already noticed about that. Just one last question: what "select_text=button_selection" does? I never have seen these statements and I wanna understand all the code :S
Thanks!
Thanks!
Re: Ask character's name in Android
This is related to $ button_selection=ui.interact()
But the select_text is for the input_text += text_code
Just make it more easy to recognize for myself.
of course you can remove $ select_text=button_selection and write it as
The result is the same.
But the select_text is for the input_text += text_code
Just make it more easy to recognize for myself.
Code: Select all
$ select_text=button_selection
python:
for text_code in text_list:
if select_text==text_code:
input_text += text_code
jump inputter
Code: Select all
python:
for text_code in text_list:
if button_selection==text_code:
input_text += text_code
jump inputter
Re: Ask character's name in Android
Ok, thanks, I got it.
And what about "text_code"? Is also a variable made by yourself? I don't understand how it works, it searchs inside of the "text_list"?
And what about "text_code"? Is also a variable made by yourself? I don't understand how it works, it searchs inside of the "text_list"?
Re: Ask character's name in Android
You can make you own python list,
the list I created is named "text_list", and it contains some "text_code". (of course you can name any names you want.)
text_list=["Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M"]
after create the list, you can use "for-in" statement to loop the items in a list:
for text_code in text_list:
Here you can know more about python list
Simple example
the list I created is named "text_list", and it contains some "text_code". (of course you can name any names you want.)
text_list=["Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M"]
after create the list, you can use "for-in" statement to loop the items in a list:
for text_code in text_list:
Here you can know more about python list
Simple example
Code: Select all
label start:
$ basket = ['apple', 'orange', 'mango', 'pear', 'lemon', 'banana']
$ ui.vbox()
python:
for fruit in basket:
ui.text(fruit)
$ ui.close()
Re: Ask character's name in Android
Wow, ok. Thank you!!
My problem was that I didn't understand why the variable "text_code" wasn't declared at the beggining... like in many others languages. So I thought it was a function, procedure or something else... But now I know not to declare the variable type in Python .
That's all!
My problem was that I didn't understand why the variable "text_code" wasn't declared at the beggining... like in many others languages. So I thought it was a function, procedure or something else... But now I know not to declare the variable type in Python .
That's all!
Who is online
Users browsing this forum: Ahrefs [Bot]