The title is weird, but basically I want to make it to where it asks the player to input a word, I.E. in my game I want the player to be forced to type out "A date" when the character asks them why they are there. He is in control of the player, is what im trying to do.
I want it to be when the player hits any random key it types out one letter of the phrase.
I hope this makes sense, I dont know where else to look for help lol
Type out predetermined word when player types?
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.
-
- Newbie
- Posts: 13
- Joined: Fri Jul 23, 2021 10:06 am
- Contact:
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Contact:
Re: Type out predetermined word when player types?
You can try this.
This only responds to any alphabet letter and digit. If you want to capture all the keys on the keyboard, might be better to do this inside a CDD instead.
Another option that I could think of...
This should respond to any key I guess...
Code: Select all
init python:
import string
screen fixed_input(input):
default current_input = []
default input_ = list(input)
default keysyms = tuple("keyup_{}".format(l) for l in string.ascii_letters + string.digits)
if input_:
key keysyms:
action Function(current_input.append, input_.pop(0))
if current_input:
key "input_backspace" action Function(input_.insert, 0, current_input.pop(-1))
key "input_enter" action Return()
text "".join(current_input)
Code: Select all
label start:
call screen fixed_input("A date")
Another option that I could think of...
Code: Select all
init -1509 python:
@renpy.pure
class FixedInputValue(InputValue, FieldEquality):
identity_fields = [ "input", "target_input" ]
equality_fields = [ "returnable" ]
def __init__(self, input, target_input, default=True, returnable=False):
self.default = default
self.returnable = returnable
self.input = input
self.target_input = target_input
def get_text(self):
return "".join(self.input)
def set_text(self, value):
self.input.clear()
self.input += self.target_input[:len(value)]
renpy.restart_interaction()
Code: Select all
screen fixed_input(input):
default input_ = []
default fixed_input_value = FixedInputValue(input_, input)
input:
value fixed_input_value
Code: Select all
label start:
call screen fixed_input("A date")
-
- Newbie
- Posts: 13
- Joined: Fri Jul 23, 2021 10:06 am
- Contact:
Re: Type out predetermined word when player types?
So I tried the top code, but it didnt type out anything when I pressed keys, the second code gives me a syntax errorhell_oh_world wrote: ↑Mon Aug 16, 2021 5:42 am You can try this.Code: Select all
init python: import string screen fixed_input(input): default current_input = [] default input_ = list(input) default keysyms = tuple("keyup_{}".format(l) for l in string.ascii_letters + string.digits) if input_: key keysyms: action Function(current_input.append, input_.pop(0)) if current_input: key "input_backspace" action Function(input_.insert, 0, current_input.pop(-1)) key "input_enter" action Return() text "".join(current_input)
This only responds to any alphabet letter and digit. If you want to capture all the keys on the keyboard, might be better to do this inside a CDD instead.Code: Select all
label start: call screen fixed_input("A date")
Another option that I could think of...Code: Select all
init -1509 python: @renpy.pure class FixedInputValue(InputValue, FieldEquality): identity_fields = [ "input", "target_input" ] equality_fields = [ "returnable" ] def __init__(self, input, target_input, default=True, returnable=False): self.default = default self.returnable = returnable self.input = input self.target_input = target_input def get_text(self): return "".join(self.input) def set_text(self, value): self.input.clear() self.input += self.target_input[:len(value)] renpy.restart_interaction()
Code: Select all
screen fixed_input(input): default input_ = [] default fixed_input_value = FixedInputValue(input_, input) input: value fixed_input_value
This should respond to any key I guess...Code: Select all
label start: call screen fixed_input("A date")
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Type out predetermined word when player types?
We'd need to see the code you are trying and the error message...
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Re: Type out predetermined word when player types?
Awesome! Been looking for something like this to create a screen by hacker man type, http://tentaculus.ru/hackerman/
Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Who is online
Users browsing this forum: Bing [Bot]