User input -- numbers

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
ElonMuskIsMyDad
Newbie
Posts: 10
Joined: Sun Nov 29, 2020 4:02 pm
Contact:

User input -- numbers

#1 Post by ElonMuskIsMyDad »

Hello again, everyone.

I've looked everywhere, but I can't find how to correctly allow a player to input an answer, let alone a numerical answer. Renpy gives me an error with this code, stating that

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 180, in script
    $ number = renpy.input(allow="0123456789")
  File "game/script.rpy", line 180, in <module>
    $ number = renpy.input(allow="0123456789")
TypeError: input() takes at least 1 argument (1 given)

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 180, in script
    $ number = renpy.input(allow="0123456789")
  File "C:\Users\14076\Downloads\renpy-7.3.5-sdk\renpy\ast.py", line 914, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\14076\Downloads\renpy-7.3.5-sdk\renpy\python.py", line 2028, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 180, in <module>
    $ number = renpy.input(allow="0123456789")
TypeError: input() takes at least 1 argument (1 given)

Windows-8-6.2.9200
Ren'Py 7.3.5.606
And the 1.0
Tue Apr 27 18:40:02 2021
This here is the code in question.

Code: Select all

$ number = renpy.input(allow="0123456789")
        if number = 65:
            jump puzzlecorrect
        else:
            jump puzzlewrong

What am I doing wrong? I generally only use multiple choice questions, hence my confusion. Thank you!

laure44
Regular
Posts: 84
Joined: Mon Mar 08, 2021 10:55 pm
Projects: Arkan'sTower, Gemshine Lorelei!
Location: France
Contact:

Re: User input -- numbers

#2 Post by laure44 »

Hey there,

Code: Select all

renpy.input(prompt, default=u'', allow=None, exclude=u'{}', length=None, with_none=None, pixel_width=None, screen=u'input', **kwargs)
prompt is required, so you need to specify it, to make it look like this :

Code: Select all

$ number = renpy.input("some text", allow="0123456789")
Also,

Code: Select all

if number = 65:
will return a syntax error. You have to use a double equal sign, like this:

Code: Select all

if number == 65:

ElonMuskIsMyDad
Newbie
Posts: 10
Joined: Sun Nov 29, 2020 4:02 pm
Contact:

Re: User input -- numbers

#3 Post by ElonMuskIsMyDad »

That makes so much more sense. Thank you so much for your help!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]