Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
In my game, there's a door locked by code. Once unlocked, I want the player to be able to pass between the hidden room and the door room without having to re-enter the code or re-read the protag's text. I've tried by myself, but my code isn't working.
label CodeDoor:
if dooropen == True:
jump backroomfirst
else:
h "Whoa.....What's up with this door?"
h "It's metal. Could it be steel?"
h "Why is something like {i}this{/i} here? This house is worn-down and falling apart. This is a state of the art security door!"
h "What in the world could be behind it?"
h "Looks like a number code is required to open it."
$ answer = renpy.input(_("Code:"))
"[answer]"
if answer =="7":
h "The door opened."
$ dooropen == True
jump backroomfirst
else:
h "Damn, that was wrong. The door wouldn't budge."
h "I need to find the code."
jump BRDoorF[/c]
This is at the Start label, in case its important:
[c]label start:
$ found_cannedpeas = False
$ found_beefjerky = False
$ found_machete = False
$ found_salmon = False
$ found_codepapers = False
$ found_gloves = False
$ dooropen = False
init:
$ faright = Position(xpos=0.80, xanchor=0.5, ypos=0.5, yanchor=0.5)
$ flash = Fade(.25, 0, .75, color="#fff")
As is, the game just repeats the text. Help? ;-;
Last edited by aussieducky on Mon Aug 10, 2015 4:41 am, edited 1 time in total.
I am a teenager who would like, very much, to finish a visual novel ;D
I don't know much about coding, but I'll try not to be a bother.
label CodeDoor:
if dooropen == True:
jump backroomfirst
else:
h "Whoa.....What's up with this door?"
h "It's metal. Could it be steel?"
h "Why is something like {i}this{/i} here? This house is worn-down and falling apart. This is a state of the art security door!"
h "What in the world could be behind it?"
h "Looks like a number code is required to open it."
$ answer = renpy.input(_("Code:"))
"[answer]"
if answer =="7":
h "The door opened."
$ dooropen = True # <-- this was the problem
jump backroomfirst
else:
h "Damn, that was wrong. The door wouldn't budge."
h "I need to find the code."
jump BRDoorF
This is at the Start label, in case its important:
label start:
$ found_cannedpeas = False
$ found_beefjerky = False
$ found_machete = False
$ found_salmon = False
$ found_codepapers = False
$ found_gloves = False
$ dooropen = False
init:
$ faright = Position(xpos=0.80, xanchor=0.5, ypos=0.5, yanchor=0.5)
$ flash = Fade(.25, 0, .75, color="#fff")
Oh, sorry! D: I thought the button I clicked would do that, but apparently not
Also, thank you! The code works perfectly now.
Could I ask you one more variables question? There's one object in the game I want the player to click three times before an event is triggered. I know how to trigger an even involving multiple objects, but not just one ;-;
I am a teenager who would like, very much, to finish a visual novel ;D
I don't know much about coding, but I'll try not to be a bother.
Basically, at the start you have to set a variable that will count the amount of times that the object was clicked, let's call the variable click_amount:
Keep in mind that unless the code is inside a python block, you'll have to use "$ click_amount += 1" rather than just "click_amount += 1"
But yeah, there are all sorts of ways you can do this and each has different options. You could check it with "if click_amount < 3:" and then have it skip to something else in that case, or you could have "if click_amount >= 3:" which would allow you to track clicks past 3 but the door would still work after that. it all depends on what you want to do with it.