Linux,Androidは日本語入力ができないためJpInputを使用する
(Ren'Pyの用意するrenpy.inputは現在Windows,Mac,ブラウザ版が日本語入力可能)
永続変数の用意
options.rpy
default persistent.name_keep = ""
背景画像の用意
images.rpy
image game_menu = Solid("#B7B5C6E6", xsize=1280, ysize=720) image n ="n.webp"
画面の用意
screens.rpy
screen input(prompt): style_prefix "input" key "mouseup_3" action GetText("input","input") if not renpy.android: style_prefix "input" window: xalign 0.0 yalign 0.0 if preferences.language == None: text _("主人公の名前入力\n{size=-15}(ひらがな または カタカナ){/size}"): xpos 610 ypos 140 line_leading 10 else: text _("主人公の名前入力\n{size=-15}(ひらがな または カタカナ){/size}"): xpos 700 ypos 120 line_leading 10 vbox: xpos 675 ypos 285 xalign 0.0 text prompt style "input_prompt" input id "input" vbox: textbutton _("決定"): action GetText("input","input") xpos 433 ypos 500 else: style_prefix "input2" window: text _("名前入力\n{size=-10}(ひらがな または カタカナ){/size}"): xalign 0.1 ypos 50 vbox: xalign 0.5 xsize 410 ypos 50 text prompt style "input_prompt" input id "input" style input_prompt is default style input_text is default style input_button is default style input_button_text is default style input2_button is input_button style input2_button_text is input_button_text style input2_text is default style input_window: background "n" style input2_window: background "color2" xsize 1280 ysize 720 style input_text: size 50 text_align 0.5 yalign 0.5 color gcolor5 style input: xalign 0.3 yalign 0.5 size 70 alt _("、現在の名前、[persistent.name_keep]") style input_button: idle_background "color1" xsize 854 ysize 220 activate_sound gsound1 style input_button_text: xalign 0.5 yalign 0.5 size 70 color gcolor2 hover_color gcolor5
key "mouseup_3" action GetText("input","input"):マウスの右クリックをするとOKボタン、エンターを押したときと同じ動作をするようにする
名前変換ラベルの用意
script.rpy
label start
label start: if persistent.name_keep == "": call name_change(1) from _call_name_change
label name_change
show game_menu if preferences.language == "en_us": $ if persistent.name_keep == "" : persistent.name_keep = "Chiyako" if renpy.windows or renpy.macintosh: $ persistent.name_keep = renpy.input("",default=persistent.name_keep, length=10,allow="abcdefghijklmnopqrstuvwxyzéèàçêôîöëÉÈÀÇÊÔÎÖËABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") elif renpy.emscripten: show n $ persistent.name_keep = renpy.input("Enter the name of the MC.",default=persistent.name_keep, length=10,allow="abcdefghijklmnopqrstuvwxyzéèàçêôîöëÉÈÀÇÊÔÎÖËABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") $ if persistent.name_keep == "" : persistent.name_keep = "Chiyako" else: $ if persistent.name_keep == "" : persistent.name_keep = "ちやこ" if renpy.windows or renpy.macintosh: $ persistent.name_keep = renpy.input("",default=persistent.name_keep, length=5,allow="あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわうをんアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワウヲンがぎぐげござじずぜぞだぢづでどばびぶべぼガギグゲゴザジズゼゾダヂヅデドバビブベボぱぴぷぺぽパピプペポぁぃぅぇぉっゃゅょゎァィゥェォヵヶッャュョabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789éèàçêôîöëÉÈÀÇÊÔÎÖË0123456789") elif renpy.emscripten: show n $ persistent.name_keep = renpy.input("主人公の名前を入力してください。", length=5,default=persistent.name_keep, allow="あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわうをんアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワウヲンがぎぐげござじずぜぞだぢづでどばびぶべぼガギグゲゴザジズゼゾダヂヅデドバビブベボぱぴぷぺぽパピプペポぁぃぅぇぉっゃゅょゎァィゥェォヵヶッャュョabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789éèàçêôîöëÉÈÀÇÊÔÎÖË0123456789") else: python: persistent.name_keep = JpInput.jpinput("", default=persistent.name_keep, with_none=None, linux_prompt='', mobile_prompt='') $ if persistent.name_keep == "" : persistent.name_keep = "ちやこ" $ renpy.choice_for_skipping() #ブラウザ版セーブ用 if rtn == 2: call screen preferences() else: return
renpy.emscripten このゲームがブラウザ版である場合True
default input欄にデフォルト名を入れる場合は指定
length 名前の長さ制限
allow 許可する文字
オプション画面での用意
preferences.rpy
textbutton _("主人公の名前変更") action Call("name_change",2)