I am trying to add a phone pin number unlock puzzle to my game. I plan on using it in a couple of places: with a phone and with a safe. Both images have a key pad and enter/ reset button, and will be unlocked with 4 digits. I looked at this thread about number password unlocks viewtopic.php?t=1625 but I can't figure out how to use renpy.input without the keyboard, and just using imagebuttons. I also need to ensure the numbers are in a specific order so the pin only unlocks with the correct combination.
Another way of thinking about this was using AddToSet, which I've never used before. I thought I'd try it out but sadly it crashes.
My code:
Code: Select all
screen safeunlock_search:
imagebutton idle Solid("#0000", xysize=(51, 42)) action AddToSet("safenumber", "1") xpos 752 ypos 460 focus_mask None
imagebutton idle Solid("#0000", xysize=(51, 44)) action AddToSet("safenumber", "4") xpos 752 ypos 505 focus_mask None
imagebutton idle Solid("#0000", xysize=(51, 46)) action AddToSet("safenumber", "7") xpos 752 ypos 552 focus_mask None
#etc for all numbers
imagebutton idle Solid("#0000", xysize=(51, 46)) clicked Return('enter') xpos 752 ypos 601 focus_mask None
Code: Select all
label cupboardsafe_explore:
#$ safenumber = renpy.input("What is the code?", "1504", length=4) ## pls ignore this attempt
call screen safeunlock_search
$ result = _return
if result == "enter":
if "safenumber" == [1.0, 5.0, 0.0, 4.0]:
mil "Got it!"
else:
mil "That didn't work."
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 9516, in script call
call corneropen_explore
File "game/explore.rpy", line 2244, in script
call screen safeunlock_search
File "renpy/common/000statements.rpy", line 531, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "renpy/common/00action_data.rpy", line 417, in __call__
self.set.add(self.value)
AttributeError: 'unicode' object has no attribute 'add'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 9516, in script call
call corneropen_explore
File "game/explore.rpy", line 2244, in script
call screen safeunlock_search
File "/Applications/renpy-6.99.11-sdk/renpy/ast.py", line 1949, in execute
self.call("execute")
File "/Applications/renpy-6.99.11-sdk/renpy/ast.py", line 1937, in call
return renpy.statements.call(method, parsed, *args, **kwargs)
File "/Applications/renpy-6.99.11-sdk/renpy/statements.py", line 277, in call
return method(parsed, *args, **kwargs)
File "renpy/common/000statements.rpy", line 531, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "/Applications/renpy-6.99.11-sdk/renpy/exports.py", line 2905, in call_screen
rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
File "/Applications/renpy-6.99.11-sdk/renpy/ui.py", line 297, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "/Applications/renpy-6.99.11-sdk/renpy/display/core.py", line 2702, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "/Applications/renpy-6.99.11-sdk/renpy/display/core.py", line 3518, in interact_core
rv = root_widget.event(ev, x, y, 0)
File "/Applications/renpy-6.99.11-sdk/renpy/display/layout.py", line 998, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "/Applications/renpy-6.99.11-sdk/renpy/display/layout.py", line 998, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "/Applications/renpy-6.99.11-sdk/renpy/display/layout.py", line 998, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "/Applications/renpy-6.99.11-sdk/renpy/display/screen.py", line 714, in event
rv = self.child.event(ev, x, y, st)
File "/Applications/renpy-6.99.11-sdk/renpy/display/layout.py", line 998, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "/Applications/renpy-6.99.11-sdk/renpy/display/behavior.py", line 962, in event
return handle_click(self.clicked)
File "/Applications/renpy-6.99.11-sdk/renpy/display/behavior.py", line 897, in handle_click
rv = run(action)
File "/Applications/renpy-6.99.11-sdk/renpy/display/behavior.py", line 320, in run
return action(*args, **kwargs)
File "renpy/common/00action_data.rpy", line 417, in __call__
self.set.add(self.value)
AttributeError: 'unicode' object has no attribute 'add'