[SOLVED]How can I use the player location?

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
Mord87
Regular
Posts: 26
Joined: Fri May 31, 2019 7:17 pm
Contact:

[SOLVED]How can I use the player location?

#1 Post by Mord87 »

Hello!

I would like to use the player location. I want the player to take a selfie in her room. Her room is a label.
the player already opened her mobile phone in her room. The player on the room label and show screen mobile.
and I want to put a textbutton on the mobile to take a selfie but only in the bedroom.

if #player in the bedroom#:
textbutton "Take a selfie" action SetVariable("selfie", 1)

I hope it is clear.
Thank you
Last edited by Mord87 on Wed Oct 02, 2019 6:36 pm, edited 1 time in total.

eezergoode
Regular
Posts: 58
Joined: Tue Aug 29, 2006 10:55 am
Contact:

Re: How can I use the player location?

#2 Post by eezergoode »

I would use a variable to track player location, i.e when you call or jump to the location label, update the variable to the current location. Then you can check that variable, and only show the text button and the selfie option if it matches. Hope that made sense....
Eezergoode - AKA Rabid Penguin
Team Lead

It does not matter how slowly you go so long as you do not stop.
Confucius
Chinese philosopher & reformer (551 BC - 479 BC)

Mord87
Regular
Posts: 26
Joined: Fri May 31, 2019 7:17 pm
Contact:

Re: How can I use the player location?

#3 Post by Mord87 »

eezergoode wrote: Tue Oct 01, 2019 6:59 pm I would use a variable to track player location, i.e when you call or jump to the location label, update the variable to the current location. Then you can check that variable, and only show the text button and the selfie option if it matches. Hope that made sense....
Hi!

It makes sense and I was thinking of this option. The problem with it, it is a lot of extra writing to write for each jump the label names cos in the future I want to add different locations for selfies and other things. I can make your way but I was hoping there is some code to check the actual label the player on.
Thank You for your help anyway!

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: How can I use the player location?

#4 Post by rayminator »

that why you make notes by using the # sign so you know what they are for something like this

Code: Select all

# this for the bathroom label
label bathroom:
     a "hello there"

eezergoode
Regular
Posts: 58
Joined: Tue Aug 29, 2006 10:55 am
Contact:

Re: How can I use the player location?

#5 Post by eezergoode »

That is one reason my label for the location is the same as my name for the location. I set the location before actually moving to it with a simple variable, like

Code: Select all

$ location = "loc_mcbr"
then return to my main game loop. In the main game loop I have

Code: Select all

call expression (location)
Which then calls the block for whatever location it is, since I use that same "loc_mcbr" for the label as well.

Not sure how well i explained that, since I'm just getting home after a very, very long work day.

I honestly surprised my earlier answer made any sense, I answered from my phone while on break :)
Eezergoode - AKA Rabid Penguin
Team Lead

It does not matter how slowly you go so long as you do not stop.
Confucius
Chinese philosopher & reformer (551 BC - 479 BC)

Mord87
Regular
Posts: 26
Joined: Fri May 31, 2019 7:17 pm
Contact:

Re: How can I use the player location?

#6 Post by Mord87 »

eezergoode wrote: Tue Oct 01, 2019 11:41 pm That is one reason my label for the location is the same as my name for the location. I set the location before actually moving to it with a simple variable, like

Code: Select all

$ location = "loc_mcbr"
then return to my main game loop. In the main game loop I have

Code: Select all

call expression (location)
Which then calls the block for whatever location it is, since I use that same "loc_mcbr" for the label as well.

Not sure how well i explained that, since I'm just getting home after a very, very long work day.

I honestly surprised my earlier answer made any sense, I answered from my phone while on break :)
I just used what you told me earlier. It is working. Thank You

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], Google [Bot], Silac