Character interaction screen

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
Abuelitaland
Regular
Posts: 135
Joined: Fri Jun 07, 2013 9:12 pm
Projects: Ways To The Grave(18+/Gore), Pantyline(18+)
Tumblr: sketchyland
Location: U.S.
Contact:

Character interaction screen

#1 Post by Abuelitaland » Tue Dec 31, 2013 4:32 pm

Siiiighhh I've hit a wall here, making this thing. It turned out to be uh more complicated than i first thought and I don't know what I'm doing anymore haha... Actually I could use some help from someone good at programming if any of y'all would be kind enough.
hh.png
You see, two columns of four "slots". as for the items, I only want them to show up in a slot on this screen if you have that item in your inventory. when you click it, i want it to show an image and there'll be a couple of lines of dialogue in the usual textbox and then go back to this screen. I want for the to be an option in the very last slot no matter what, though.
ggh.png
yeesh let me know if that was too vague or if i left out some necessary information

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Character interaction screen

#2 Post by Showsni » Tue Dec 31, 2013 5:43 pm

I'd do it using screen language: http://www.renpy.org/doc/html/screens.html to make a screen for the inventory, and have a list to store whether you have the items or not.

First, set up the screen, and stick some boxes in there for the items to go in, and the list of inventory items. Assuming you want it like in your picture where the same items always take the same inventory slot, something like this:

Code: Select all

init:
    $ box = Solid("#ff0000", area=(0,0,160,120))
    screen inv:
        vbox xalign 0.0:
            frame:
                xpadding 10
                ypadding 10
                xalign 0.5
                yalign 0.5
                if "knife" in inventory:
                    imagebutton auto "knife_%s.png" action Jump('Knife')
                else:
                    add box
            frame:
                xpadding 10
                ypadding 10
                xalign 0.5
                yalign 0.5
                if "cigar" in inventory:
                    imagebutton auto "cigar_%s.png" action Jump('Cigar')
                else:
                    add box
            frame:
                xpadding 10
                ypadding 10
                xalign 0.5
                yalign 0.5
                if "hat" in inventory:
                    imagebutton auto "hat_%s.png" action Jump('Hat')
                else:
                    add box
            frame:
                xpadding 10
                ypadding 10
                xalign 0.5
                yalign 0.5
                if "walkman" in inventory:
                    imagebutton auto "walkman_%s.png" action Jump('Walkman')
                else:
                    add box
                

        vbox xalign 1.0:
            frame:
                xpadding 10
                ypadding 10
                xalign 0.5
                yalign 0.5
                if "mouse" in inventory:
                    imagebutton auto "mouse_%s.png" action Jump('Mouse')
                else:
                    add box
            frame:
                xpadding 10
                ypadding 10
                xalign 0.5
                yalign 0.5
                if "dirigible" in inventory:
                    imagebutton auto "dirigible_%s.png" action Jump('Dirigible')
                else:
                    add box
            frame:
                xpadding 10
                ypadding 10
                xalign 0.5
                yalign 0.5
                if "syringe" in inventory:
                    imagebutton auto "syringe_%s.png" action Jump('Syringe')
                else:
                    add box
            frame:
                xpadding 10
                ypadding 10
                xalign 0.5
                yalign 0.5
                if "dove" in inventory:
                    imagebutton auto "dove_%s.png" action Jump('Dove')
                else:
                    add box
Now you need to populate the inventory, sometime after the start label, so that it gets saved properly...

Code: Select all

$ inventory = ["knife", "syringe", "dove"]
To add or remove things use

Code: Select all

 $ inventory.append("hat")
$ inventory.remove("knife")
To show and hide the screen use

Code: Select all

show screen inv
hide screen inv
The actions as I've written will cause you to Jump to a label for each item, which will then need to send you back to the game. Alternatively you could so something like make them set a variable, then have that cause text to show up:

Code: Select all

imagebutton auto "syringe_%s.png" hovered SetVariable("infotext", "syringe") unhovered SetVariable("infotext", "nothing")
Then at the bottom of the screen:

Code: Select all

if infotext == "syringe":
    text "It's a syringe"
if infotext == "knife":
    text "It's a knife"
etc.

Well, you can basically do what you want. Check out the screen language and screen actions pages on the documentation!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]