but i would be glad if i could get some help with my code.
I'm trying to create a game which is somewhat between genre of 'professor latyon' and some web-puzzle-type thing
The problem that i am having right now is
If you think of the game 'professor layton', when you press the 'input answer' button,
you would reach another screen which you could input your answer.
similarly, i would like the player to input a certain 'word' so to check their answer
for the input method, i want them to use their keyboard to submit the answer
so looking through some tutorials i guess using renpy.input would give a keyboard input?
but i think i was struggling at some various situations and tried different things
such as
first i tried to call a label (which has renpy.input in it) within the screen,
but after the label it skips the after screen statements(?) which i was not intended to work that way
so i search how to use a user-created functions(?) and tried to put the renpy.input() inside the function i created
and call the function using "action Function()" thing that is used in Screens,
however, I've got this error,
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 12, in script
call screen InputAnswerTypeWord
File "renpy/common/000statements.rpy", line 519, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "renpy/common/00action_other.rpy", line 517, in __call__
rv = self.callable(*self.args, **self.kwargs)
File "game/script.rpy", line 4, in Inputing_AnswerType_Word
InputType_Word = renpy.input("Input Your Answer")
Exception: Cannot start an interaction in the middle of an interaction, without creating a new context.
here is the code i used is this:
Code: Select all
init -1 python:
def Inputing_AnswerType_Word():
global InputType_Word
InputType_Word = renpy.input("Input Your Answer")
InputType_Word = InputType_Word.strip()
label start:
default InputType_Word = ""
default Answer_Player = ""
"This is the start of the game"
call screen InputAnswerTypeWord
"You have answered, [Answer_Player]"
screen InputAnswerTypeWord():
modal True
timer 0.0001 action SetVariable("InputType_Word", "")
frame:
textbutton "Input":
action Function(Inputing_AnswerType_Word)
align(.5, .5)
frame:
textbutton "Confirm":
action [
SetVariable("Answer_Player", InputType_Word),
Hide("InputAnswerTypeWord"),
]
align(.4, .6)
frame:
textbutton "Go Back":
action [
Hide("InputAnswerTypeWord"),
Hide("ButtonOfNumbersInput")
]
align(.6, .6)
text "[InputType_Word]":
align(.5,.8)
I searched about the error and found some of the advices,
but i believe this time i have failed to understand what it means of the terms of
"starting an interaction" and "creating a new context" means.
The Other option that i have tried to do is using
Code: Select all
screen input2:
window:
style "nvl_window"
input id "input" xalign 0.5 yalign 0.5
which i have no idea what this does,
but i am slightly dissatisfied because of two things
1. If i press the Enter key when the input is in progress,
it just ends the current Screen and having the same problem which i have mention earlier
2. So I tried to make a new button which allows to continue to use the screen properties without getting out of the screen
however, I couldn't find a way to disable the Enter key (or at least i didn't understand some of the code)
==============================================================================================
To sum up my Question,
How can i use the .input command properly within screen and get that answer to save in some variable?
in this case, if player press "Input" : player would give an input via keyboard
Then, text "[InputType_Word]": will display the inputed answer
then, if pressed "Confirm": the answer(InputType_Word) will be equal to (Answer_Player)
OR
if using the style "nvl_window" method, is there a way to disable the Enter key?
As an alternative, if disabling the Enter key throughout the whole gameplay is possible, i think using "nvl_window" method would work perhaps?
sry of me laying down a bunch of questions, but i do think there are some various method to solve this kind of matter,
so i would like to learn some new coding ways which i may used in the future
thanks for reading