*'entervar' is a simple True/False variable that relies on K_ENTER
Code: Select all
default phone = ""
init python:
def phone_func(newstring):
def format():
firstphone = newstring
firstphone = firstphone + "-"
store.phone = firstphone
store.entervar = False
renpy.restart_interaction()
def backspace():
firstphone = newstring
firstphone = firstphone[:-2]
store.phone = firstphone
store.entervar = False
renpy.restart_interaction()
def backspacenorm():
firstphone = newstring
firstphone = firstphone[:-1]
store.phone = firstphone
store.entervar = False
renpy.restart_interaction()
firstphone = newstring
if (len(firstphone) == 3):
format()
if (len(firstphone) == 4):
backspace()
ui.keymap(K_BACKSPACE=backspace)
screen phone_input():
vbox:
button:
id "phone_input1"
xysize (1100,55)
action NullAction()
add Input(default=phone, changed=phone_func, length=8, button=renpy.get_widget("phone_input","phone_input1"))
if phone == "555-5555" and entervar:
timer 0.25 action Play("sound2", "se/boop.ogg")
elif phone is not "555-5555" and entervar:
timer 0.25 action Play("sound2", "se/mork.ogg")
else:
timer 0.25 action NullAction()