[Solved] Comparing Specific Content within an Index of Two Lists (if list_a[0] == pie && list_b == cherry)

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
shrexylexy
Newbie
Posts: 6
Joined: Tue May 24, 2022 7:15 pm
Contact:

[Solved] Comparing Specific Content within an Index of Two Lists (if list_a[0] == pie && list_b == cherry)

#1 Post by shrexylexy »

Hello!

I'm fairly new to Ren'PY and working within Python for these projects. I am looking to see if there is a way to compare specific indexes of two different lists.

Essentially I am creating a class scheduler and need to obtain the order of the classes. I have the schedule creator as a drag and drop minigame where you drag classes you want into the available slots. I want to make an order out of which classes they put in specific spots.

I figure in an amalgamation of languages it would look something like this:

If (list_classes[0] == "Math") && (list_time[0] == "9AM"){
jump Math9am
}

However, I haven't been able to find anything in the handbook or other posts that help with this.

Any help and advice would be greatly appreciated, thanks!!!
Last edited by shrexylexy on Thu Jun 09, 2022 5:08 pm, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Comparing Specific Content within an Index of Two Lists (if list_a[0] == pie && list_b == cherry)

#2 Post by philat »

For that specific use case: jump expression list_classes[0]+list_time[0] https://www.renpy.org/doc/html/label.ht ... -statement

In general, the python syntax for what you put down would simply be

Code: Select all

if list_classes[0] == "Math" and list_time[0] == "9AM":
    jump Math9AM

shrexylexy
Newbie
Posts: 6
Joined: Tue May 24, 2022 7:15 pm
Contact:

Re: Comparing Specific Content within an Index of Two Lists (if list_a[0] == pie && list_b == cherry)

#3 Post by shrexylexy »

Amazing, thank you!! That's a lot simpler than I thought. I was definitely overcomplicating things. I'll try it out and update with my progress in case future people have the same problems I did :)

shrexylexy
Newbie
Posts: 6
Joined: Tue May 24, 2022 7:15 pm
Contact:

Re: Comparing Specific Content within an Index of Two Lists (if list_a[0] == pie && list_b == cherry)

#4 Post by shrexylexy »

Hi all!
this is what I have for my code:

Code: Select all

 def orderofclasses():
        if order[0] == "00 piece" and time[0] == "00": #if the first piece is the first in the list and ison the first time droppable
            jump Cowboy1
It keeps telling me that the jump Cowboy1 has a syntax error. and points to the end of the line as though it were expecting a semicolon or something. I can't figure out what it wants as the code in the Renpy documentation also appears to have their jump statements lined up the way I have mine.

Am I missing something obvious?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Comparing Specific Content within an Index of Two Lists (if list_a[0] == pie && list_b == cherry)

#5 Post by Ocelot »

jump Cowboy1 is a RenPy statement and cannot be used in Python block. Either make it into RenPy code, or use Python equivalent: renpy.jump("label_name")
< < insert Rick Cook quote here > >

shrexylexy
Newbie
Posts: 6
Joined: Tue May 24, 2022 7:15 pm
Contact:

Re: Comparing Specific Content within an Index of Two Lists (if list_a[0] == pie && list_b == cherry)

#6 Post by shrexylexy »

Thank you!! I'm now not receiving any errors. Can't believe I missed that haha

Post Reply

Who is online

Users browsing this forum: No registered users