Displaying arrays in renpy,

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
Tentacles
Regular
Posts: 69
Joined: Tue Jul 14, 2009 10:02 pm
Projects: Uploaded Fairy ( Interactive Comic )
Deviantart: otissalmoneus
Github: LWFlouisa
Contact:

Displaying arrays in renpy,

#1 Post by Tentacles » Mon Jul 06, 2015 6:40 pm

I haven't been here for a while, but tried to learn some coding to get the most out of Ruby and Renpy. But ran into some coding specific problems along the way.

I wanted to ask if Renpy is capable of displaying arrays. Or is there a need for this considering that Renpy has a built in choose function. I know how to do a basic battle system, though when I was learning Ruby briefly there was an odd thing about hp >= processing as if it were hp <=, and so hp <= goes straight to game over.

But I'm wanting to have these arrays if I need them: (Ruby verison)

Code: Select all

mainmenu = ['Continue', 'Check HP', 'Time', 'Exit']

Code: Select all

yesno = ['Yes', 'No']
I briefly tried Ruby for visual novels sense I wanted a way to create a maze, then it turns out that I can relatively easily create a maze function on my own just with built in choices in nvl mode. But I'm not sure if the build in choices would have the look I want for Fight and Flee, and Attack and Defend.

I think I can relatively easily find if/else functions.

I prefer Renpy just because you can actually jump to a label, while Ruby has that horrendously vague break function. I have to put in comments about which place some place breaks to. So inputting face and cube hopping is much easier.

Side-note: I don't need a complicated battle system, it would be front view if there was a graphic. But technically its just the battle system you would put in a text-adventure.
I develop horror romance interactive comics. Currently working on my first.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Displaying arrays in renpy,

#2 Post by trooper6 » Mon Jul 06, 2015 6:57 pm

Python has lists (and sets and dicts and tuples, etc). And since Python has them, renpy has them. I use them all the time to keep track of things.

Now...when you say "displaying arrays" what do you mean?
With your yes/no...that just sounds like a menu.

Code: Select all

menu:
    "Do you deface the statue?"
    "Yes":
        jump statue_y
    "No":
        jump statue_n
You don't need an array for that.
That main menu of yours sounds like it is just a screen with some buttons on it....which, I don't think you need an array for that either.

Have you read through the Renpy QuickStart? http://www.renpy.org/doc/html/quickstart.html
You might want to look through the renpy documentation and look at the code of a few sample games. Because...I think you are asking the wrong question.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Tentacles
Regular
Posts: 69
Joined: Tue Jul 14, 2009 10:02 pm
Projects: Uploaded Fairy ( Interactive Comic )
Deviantart: otissalmoneus
Github: LWFlouisa
Contact:

Re: Displaying arrays in renpy,

#3 Post by Tentacles » Mon Jul 06, 2015 7:13 pm

Yea I looked at it, though it's been like seven years sense I last look. it's probably been updated.

Cool beans! I don't need arrays. Yea in Ruby it didn't come with the ability to automatically display menus, so I had to use arrays to display choices, then use input processing to make choices. Weird program.
I develop horror romance interactive comics. Currently working on my first.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Displaying arrays in renpy,

#4 Post by trooper6 » Mon Jul 06, 2015 7:37 pm

If you haven't looked at the renpy documentation in seven years, definitely look at it again--a lot has changed!
Note: I do use lists...normally to hold inventory or days of the week...things like that. But for menus? Just use the menu command.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Tentacles
Regular
Posts: 69
Joined: Tue Jul 14, 2009 10:02 pm
Projects: Uploaded Fairy ( Interactive Comic )
Deviantart: otissalmoneus
Github: LWFlouisa
Contact:

Re: Displaying arrays in renpy,

#5 Post by Tentacles » Mon Jul 06, 2015 10:38 pm

Oh I'm browsing through, I'm noticing it doesn't talk about defining variables. I know how to do the basics, though variables have always been something I've struggled with

All the variables below I seem to be struggling to define.

Code: Select all


label battle:
    
    menu:
        
        "Fight":
            jump bat_choices

label bat_choices:
    
    if hp == 0:
        jump gameover
    elif ehp == 0:
        jump victory
    
    menu:
        
        "Attack":
            jump damage
        
        "Defend":
            jump reduced_damage
        
        "First Aid":
            jump firstaid

label damage:
    
    n 'You recieve'
    $ hp -= 1
    n 'damage.'
    
    n 'Rat recieves'
    $ ehp -= 1
    n 'damage.'
    
    jump battle
    
label reduced_damage:
    
    n 'You recieve'
    $ hp -= 1
    n 'damage.'
    
    n 'Rat recieves'
    $ ehp -= 1
    n 'damage.'
    
    jump battle

label firstaid:
    
    "You healed for"
    $ hp += 1
    "life points."
    
    jump battle
    
label gameover:
    
    n "You lost the battle."
    
    return

label victory:
    
    n "You won the battle"
    
    jump start

And this is the error I got.

Code: Select all


File "game/script.rpy", line 2: expected statement.
    hp = 10 
       ^

File "game/script.rpy", line 3: expected statement.
    atk = 7 
        ^

File "game/script.rpy", line 4: expected statement.
    grd = 2 
        ^

File "game/script.rpy", line 6: expected statement.
    ehp = 8 
        ^

File "game/script.rpy", line 7: expected statement.
    eatk = 3 
         ^

File "game/script.rpy", line 8: expected statement.
    egrd = 2 
         ^

File "game/script.rpy", line 11: expected statement.
    eDice_hero = [1, 2, 3, 4, 5, 6]
               ^

File "game/script.rpy", line 12: expected statement.
    eDice_hero_2 = [1, 2, 3, 4, 5, 6]
                 ^

File "game/script.rpy", line 13: expected statement.
    eDice_hero_3 = [1, 2, 3, 4, 5, 6]
                 ^

File "game/script.rpy", line 14: expected statement.
    eDice_hero_4 = [1, 2, 3, 4, 5, 6]
                 ^

File "game/script.rpy", line 15: expected statement.
    eDice_monster = [1, 2, 3, 4, 5, 6]
                  ^

File "game/script.rpy", line 18: expected statement.
    gold = 0
         ^
Side-Note: Also noticed an inventory function, Renpy continues to impress me. I'll keep looking through it.
I develop horror romance interactive comics. Currently working on my first.

User avatar
SinnyROM
Regular
Posts: 166
Joined: Mon Jul 08, 2013 12:25 am
Projects: Blue Birth
Organization: Cosmic Static Games
Contact:

Re: Displaying arrays in renpy,

#6 Post by SinnyROM » Mon Jul 06, 2015 11:00 pm

It's a bit tough to tell without seeing the code around lines 2,3, etc., but I'm going to guess that those variable assignments are not in a Python block or prefixed with a $. Some info on Python declarations here: http://www.renpy.org/doc/html/python.html

Tentacles
Regular
Posts: 69
Joined: Tue Jul 14, 2009 10:02 pm
Projects: Uploaded Fairy ( Interactive Comic )
Deviantart: otissalmoneus
Github: LWFlouisa
Contact:

Re: Displaying arrays in renpy,

#7 Post by Tentacles » Mon Jul 06, 2015 11:13 pm

Awesome! I'll definitely look.
I develop horror romance interactive comics. Currently working on my first.

Post Reply

Who is online

Users browsing this forum: Ocelot