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.
thanks to your guys help ive made a good age verification prompt. i then made a function to cycle images and text, but i think my format is wrong. whats the right way to do this?
init python:
def show_text_with_image(image, texts):
renpy.show(image)
for text in texts:
renpy.say(None, text)
renpy.pause()
renpy.hide(image)
# Define a list of story elements, each with an image and corresponding texts
init:
$ story_elements = [
{"image": "1.png", "texts": ["Text 1 for Image 1", "Text 2 for Image 1", "Text 3 for Image 1"]},
{"image": "2.png", "texts": ["Text 1 for Image 2", "Text 2 for Image 2"]}
]
# The script of the game goes in this file.
default age_prompt = False
# The game starts here.
label start:
"Welcome to My Awesome Game!"
call age_verification_prompt
call display_story
return
label age_verification_prompt:
menu:
"All characters in this game are 18 or older. Are you 18 years old or older?"
"Yes":
$ age_prompt = True
"No":
$ age_prompt = False
if age_prompt:
return
else:
"Sorry, you must be 18 or older to play this game."
"Goodbye!"
$ renpy.quit()
return
label display_story:
python:
for element in story_elements:
show_text_with_image(element["image"], element["texts"])
return
computerwhiz10101010 wrote: ↑Sun Jan 07, 2024 6:01 pm
thanks to your guys help ive made a good age verification prompt. i then made a function to cycle images and text, but i think my format is wrong. whats the right way to do this?
I don't know what your "story-elements" is for, but I guess it's just some scripted "in-between" sequences? Make sure to understand that loading from within those story lines won't work, since you're calling a python block. But if you're not going to repeat this story sequence, why create a variable to begin with? It's a bad idea! Why don't you just create story and narration in a normal Renpy fashion?
...
# Use a define (if it will never change) or default (if it can change) here, don't create your game related variables inside python
define story_elements = [
{"image": "1.png", "texts": ["Text 1 for Image 1", "Text 2 for Image 1", "Text 3 for Image 1"]},
{"image": "2.png", "texts": ["Text 1 for Image 2", "Text 2 for Image 2"]}
]
...
# you don't need a variable here, why save the choice?
label age_verification_prompt:
menu:
"All characters in this game are 18 or older. Are you 18 years old or older?"
"Yes":
return
"No":
"Sorry, you must be 18 or older to play this game."
"Goodbye!"
$ renpy.quit()
return