What does "expression" do?

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
couto886
Newbie
Posts: 9
Joined: Sat Nov 10, 2018 9:29 pm
Contact:

What does "expression" do?

#1 Post by couto886 »

I'm really sorry if this is a stupid question, but I cant figure what is the difference between using just "call" or "jump" and using "call expression" or "jump expression". The code I'm using as a guide use expression constantly, so I suppose there must be some function, but even reading INCOUNTABLE TIMES in the official guide I just cant figure out what this actually does. I would REALLY apreciate if somebody could help me. Again, sorry if this is a dumb question. I really don't know where to look for anymore.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: What does "expression" do?

#2 Post by PyTom »

So, normally when you do:

Code: Select all

jump foo
It will jump to the label foo. However, there are times where you want to jump to a label that's been stored in a variable. For example, one that's beenm computed. Take something like:

Code: Select all

default day = 0

label day_loop:
     $ day += 1
     "The dawn of day [day]."
     
     $ day_label = "start_day_{}".format(day)
     jump expression day_label
What this does it sot assign to day_label the strings "start_day_1", "start_day_2", and so on. Then the jump expression statement causes control to transfer to the appropriate label.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

couto886
Newbie
Posts: 9
Joined: Sat Nov 10, 2018 9:29 pm
Contact:

Re: What does "expression" do?

#3 Post by couto886 »

So the "expression" just allow the variables to be transferred in the jump??

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: What does "expression" do?

#4 Post by rames44 »

Not “transferred.” “expression” says “I am computing the name of the label you should jump to instead of giving it to you directly.”

Post Reply

Who is online

Users browsing this forum: Google [Bot]