[SOLVED] Interpolating Data in Labels

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
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

[SOLVED] Interpolating Data in Labels

#1 Post by Westeford »

I have a (hopefully) simple question.
Can data interpolation be used in labels? I know it can be used in text, but I'd like to use it for labels.

I'll try to explain why I'm trying to do. The player is put into a debate, they must pick the right piece of evidence that contradicts a statement.
"bullet_selected" coincides with the bullet. for example if bullet1 is selected then "bullet_selected" will equal 1. "bullet_correct"'s value coincides with the correct evidence. So for this bullet_correct = 1, so bullet_selected must = 1 in order to get the correct answer.

The interpolation comes in for debate_num. The first debate is label db1: the second is db2, etc.

Code: Select all

define bullet1 = "Alpha"
define bullet2 = "Beta"
define bullet_correct = 1
define debate_num = 1

label trial_checker: #When a statement is clicked, it jumps to this label.
    if bullet_selected == bullet_correct: #If right, then jump to the transitioning out of debate phase.
        jump db[debate_num].c #debate_num counts up after the jump.
    else:
        jump db[debate_num].loop #If wrong, then jump back to beginning of the debate.
My hope is to reduce repeating code and use just this label.
Basically I want to know if and how to interpolate data in labels.

I appreciate any input. Thank you for reading this post.
Last edited by Westeford on Tue Dec 11, 2018 7:10 pm, edited 1 time in total.

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

Re: Interpolating Data in Labels

#2 Post by Alex »


User avatar
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

Re: Interpolating Data in Labels

#3 Post by Westeford »

Alex wrote: Thu Dec 06, 2018 5:08 pm Try

Code: Select all

$ renpy.jump("db[debate_num].c")
https://www.renpy.org/doc/html/statemen ... renpy.jump
Brought up an error saying it can't find label db[debate_num].c.
Thanks for your input.

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

Re: Interpolating Data in Labels

#4 Post by Alex »

Well - ok, another approach

Code: Select all

$ renpy.jump("db%s.c" % debate_num)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Interpolating Data in Labels

#5 Post by Remix »

jump expression db[debate_num].c # or any python expression that resolves to a string

I am presuming that db is a dictionary keyed by debate_num and holding objects that contain an attribute named c that holds a string
Frameworks & Scriptlets:

User avatar
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

Re: Interpolating Data in Labels

#6 Post by Westeford »

Alex wrote: Thu Dec 06, 2018 6:00 pm Well - ok, another approach

Code: Select all

$ renpy.jump("db%s.c" % debate_num)
Sorry for the late reply. But this worked perfectly.
Thank you very much.

Post Reply

Who is online

Users browsing this forum: No registered users