Hello there. I'm trying to insert a screen which performs like a console, so that a player can input some command and get response. I do not know much about python and the Ren'py console example is too complex for me now. But with the help of many topics in this forum, part of the functions have been realized.
However, there are still two problems I cannot understand:
1) I have removed K_RETURN from the keymap say column, and in normal gameplay K_RETURN just doesn't work. But when the screen is shown, it works again. More than that, in the screen the mouse1 seems to be bound with K_RETURN. When mouse1 is clicked, the input text also returns. I understand that the document says "This may also raise renpy.IgnoreEvent to ignore the press. Otherwise, the enter-press is propagated to other displayables." However, I'm not sure how to use "raise renpy.IgnoreEvent()" correctly. If it is inserted after enter(self) return, it doesn't work, if before, the input cannot return. I use a scissors-and-paste InputValue class:
Code: Select all
init python:
class EnterInputValue(InputValue, FieldEquality):
default = True
editable = True
returnable = False
identity_fields = [ ]
equality_fields = [ "variable", "returnable" ]
def __init__(self, variable, default=True, returnable=False):
self.variable = variable
self.default = True
self.returnable = returnable
def get_text(self):
return ""
def set_text(self, s):
_set_field(store, self.variable, s, "variable")
#renpy.restart_interaction()
def enter(self):
return 0
raise renpy.IgnoreEvent()
#renpy.restart_interaction()
Code: Select all
image bg white= "#FFFFFF"
define ideinput = ""
define ideinput2 = ""
define ideoutput = ""
default idelog = ""
screen ide_screen:
$yadj.value = yadjValue
modal False
dismiss action Return()
window:
background "bg white"
xalign 0.5
ypos 1080
ysize 250
viewport yadjustment yadj:
scrollbars "vertical"
draggable True
mousewheel True
vbox:
if idelog != "":
text "[idelog]" size 28
input:
size 28
#default ""
prefix "Mir3>"
multiline False
copypaste True
ypos 0
value EnterInputValue('ideinput')#, default=True,returnable=True)
if ideinput != "":
$ ideinput2 = str.lower(ideinput)
$ ideinput2 = ideinput2.strip()
#$ ideinput2 = ideinput2.replace(' ','')
if idelog == "":
$ idelog =idelog+"Mir3>"+ideinput +'\n'
else:
$ idelog =idelog+'\n' +"Mir3>"+ideinput +'\n'
if ideinput2 == "mir3":
$ideoutput = "notbad"
elif ideinput2 == "clear":
$ideoutput = ""
$idelog =""
else:
$ideoutput = "?"
#text "[ideinput]" size 28
#text "[ideoutput]" size 28
$ idelog =idelog +ideoutput
#$ renpy.config.periodic_callbacks.append(keep_ticking)
$ renpy.restart_interaction()
show screen ide_screen()