Reading arguments in new label

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
User avatar
Stapper
Regular
Posts: 96
Joined: Wed Feb 27, 2013 9:54 pm
Contact:

Reading arguments in new label

#1 Post by Stapper »

I can't seem to find how I can read arguments I passed into a function. Should be super easy, just can't find any examples. I want to have a basic profile page and use an argument to define which character's profile is being displayed. I'm using the ui.callsinnewcontext function to call the profile label with the character in the argument:

Code: Select all

ui.callsinnewcontext("profile", "protagonist")
Then how do I actually read that argument so that I can display information accordingly in the profile label, for example:

Code: Select all

ui.image("images/profiles/???.png")
where ??? is the argument so that it shows protagonist.png

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Reading arguments in new label

#2 Post by Asceai »

Code: Select all

label profile(protag):
  # ...
  $ui.image("images/profiles/%s.png" % protag)
EDIT: If you're learning ren'py from the wiki, keep in mind it's seriously out of date. Use the documentation instead.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Reading arguments in new label

#3 Post by xela »

Try:

Code: Select all

ui.callsinnewcontext("profile", profile="protagonist")

Code: Select all

ui.image("images/profiles/%s.png"%profile)
Like what we're doing? Support us at:
Image

User avatar
Stapper
Regular
Posts: 96
Joined: Wed Feb 27, 2013 9:54 pm
Contact:

Re: Reading arguments in new label

#4 Post by Stapper »

Ah thanks! Glanced at it and already it looks much better.

I'll give this a go :D

Post Reply

Who is online

Users browsing this forum: Google [Bot]