Random Label Problem

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.
Post Reply
Message
Author
Ashleet
Newbie
Posts: 4
Joined: Wed Aug 10, 2011 2:14 pm
Contact:

Random Label Problem

#1 Post by Ashleet »

Good day, everyone.
I have a small problem that I would like to ask for help on.

I am a big fan of tabletop roleplaying, and one f my favourite adventures contains a magical forest where the players end up in a random place after having walked for a day. I'm looking to simulate this in a game I'm making, but I'm not sure how t do it.

I've made separate labels for each "location" the player can reach while wandering in the forest, but I don't fully understand how to make the game randomize which label the player ends up going to. Any help would be appreciated. Thank you for your time.


Ashleet
Newbie
Posts: 4
Joined: Wed Aug 10, 2011 2:14 pm
Contact:

Re: Random Label Problem

#3 Post by Ashleet »

*goes to read up on it, like a good wannabe-game-developer*

[Edit] Ok, that was fairly easy. Now, when the player enters a location for the first time, I intend the game to give a detailed explanation of the location to the player, but if they reach the same place twice, they won't need that detailed explanation.

A beautiful field of golden flowers surround a large tree where faeries dance amog the leaves could simply become I'm back at the golden field, and the faeries are still dancing or something.

Are there any good places to read up on that? I've done for research on true/false statements, but I'm kinda stupid, so I don't really understand them :-(

User avatar
Alex
Lemma-Class Veteran
Posts: 3097
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Random Label Problem

#4 Post by Alex »

Well, untill you find another solution...

Code: Select all

init:
    $ location_one_seen = False # sets the variable value
    $ location_two_seen = False
    # etc.

label location_one:
    if not location_one_seen: # checks the value
        $ location_one_seen = True # changes the value
        "Detailed explanation"
        "And even more"
    "Ordinary stuff"
Are there any good places to read up on that? I've done for research on true/false statements, but I'm kinda stupid, so I don't really understand them
http://en.wikipedia.org/wiki/Boolean_data_type

QotC
Regular
Posts: 54
Joined: Thu Feb 17, 2011 8:53 pm
Contact:

Re: Random Label Problem

#5 Post by QotC »

^You'll want an 'else' in there, I think.

Code: Select all

init:
    $ location_one_seen = False # sets the variable value
    $ location_two_seen = False
    # etc.

label location_one:
    if not location_one_seen: # checks the value
        $ location_one_seen = True # changes the value
        "Detailed explanation"
        "And even more"
    else
        "Ordinary stuff"
Otherwise, you'll get something like:
This is a beautiful field full of golden flowers and dancing fairies. I'm back at the golden field, and the fairies are still dancing.
;)

Ashleet
Newbie
Posts: 4
Joined: Wed Aug 10, 2011 2:14 pm
Contact:

Re: Random Label Problem

#6 Post by Ashleet »

Ok, I've gotten this part down as well. Thank you for the help.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]