wildcard question

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
bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

wildcard question

#1 Post by bozance »

Hello all,

I have the following that shows the player where they are when they enter a location:

$location.append("hall")

To do this, first I have to remove the previous location from displaying. Is there a way to say

$location.remove("x")

Where x denotes ANY value? For example, if you moved into the hall from the dining room or living room, "remove" would remove EITHER the dining room or living room from displaying.

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: wildcard question

#2 Post by Aleema »

That's the actual code. Just doesn't take variables, I believe. $location.remove("hall")
What's your problem? Choosing whether to toggle off the dining room or the living room? That seems a logic problem for you, rather than a magic code for Python. When exiting a room, then you should remove it from the location, rather than try to retrospectively find out where you left from the next location.

Is there a reason you're not just doing: $location = "hall" ? Does the location variable really contain multiple values (are you in more than one place at once)?

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: wildcard question

#3 Post by bozance »

I solved it. I just have to clear the variable with $location=[] and then append the new location. I realize this isn't how a list is supposed to be used, but I didn't want to have to create a new actual variable for every room. Not that this method saves that much space probably, but...

Anyway thanks Aleema.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Sugar_and_rice