Dev Blog #4

6/27/16 – 6/28/16


Phone Puzzle

I finally got the phone puzzle to work! I have no idea why, but it does. When I tried using a String to store the currently inputted numbers through an action from the imagebutton, I didn’t put parenthesis around the variable name that held the password, which caused it to break (I’M NOT USED TO PYTHON OK).

However, I figured out that the action AddToSet() causes the button to become deactivated afterwards, while SetScreenVariable does not. Why? I may never know. The final code ended up being super simple:

screen phone:
    default code = ""
    imagebutton idle"phone/1_base.png" hover"phone/1_hover.png" focus_mask True action SetScreenVariable("code", code + "1")
    imagebutton idle"phone/2_base.png" hover"phone/2_hover.png" focus_mask True action SetScreenVariable("code", code + "2")
    #continue for buttons 3-9
    imagebutton idle"phone/confirm.png"focus_mask True action If(code == "1234", Jump("openphone"), Jump("fail"))

I also implemented a text message system where the player can view Holly’s texts through a series of screens. Once the player unlocks the phone, the script calls a screen that will then allow the player to select who to read messages from. I made 5 buttons to represent five different conversations, and upon selecting a button, it jumps to the specified label in the script. Here’s it in action (disregard bad art for now):

The script was super redundant to write, and I know there’s better ways (such as creating a class, etc), but I’m still too new to Python to dare to attempt that.

screen select:
    imagebutton idle"phone/dad_base.png" hover"phone/dad_hover.png" focus_mask True action Jump("dadphone") 
#continue for other conversations


#phones
label dadphone:
    show phone dadphone
    pause
    jump plsnomore

label plsnomore:
    show phone messages
    call screen select

I added a “plsnomore” label because it added at least a LITTLE BIT of efficiency to this terribly inefficient code. For a first game, I think it’s pretty aight.

I’ve been spending a lot of time playing Black Desert Online and it’s been distracting me a lot from trying to develop this game. WHY CODE WHEN YOU CAN TAME WILD HORSES AM I RIGHT??

Later, I realized that even I didn’t need a confirm button as shown in the video. I found out here the code will only check after being called through an action or a python block. Instead of a confirm button, I added it as a conditional to the number buttons themselves to check the passcode if it were 4 digits long.

I added another action statement, but then quickly came to the realization that an imagebutton will only perform the first action so I couldn’t do that. I ended up doing something super awkward by combining everything into one action statement.

#action for the other numbers
action If(len(code) < 3,SetScreenVariable("code", code + "5"), If(len(code) == 3, Jump("fail")))

#action for the correct ending number
action If(len(code) < 3,SetScreenVariable("code", code + "6"), If(len(code) == 3, If(code == "641", Jump("openphone"), Jump("fail"))))

First, I check if the previous 3 numbers are correct for the ending digit. The passcode is “6416”, so when the player presses “6”, it will check if the length of the passcode String is 3 digits long, and if it is, it will then check if they are the correct 3 digits. I also added the code for 5 to show that if the player enters 4 wrong buttons, the code jumps to the “fail” screen.

 

Leave a comment