need help with inventory? (screens??)

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
kenmas
Newbie
Posts: 3
Joined: Thu Jun 22, 2017 12:27 am
Tumblr: royalpalmkenma
Contact:

need help with inventory? (screens??)

#1 Post by kenmas »

ive been working on this all day and i really can't seem to catch a break. i need help with screens. i'm learning disabled and simply don't understand half of what's posted online (or can't find anything specifically for what i need)? everything's really vague and i just really need help. i just want my inventory bar to show up in the top right corner and display the inventory you pick up along the way. this is what i have so far in my scripts portion of coding.

i don't understand what i need to do in the ?? screens ?? section. please, help if you can.

Code: Select all

# The script of the game goes in this file.
image blank = "blank.jpg"
image mauve = "mauveresize.png"
image mauvepjs = "mauveresizepjs.png"
image brick = "brickresize.png"
image brickhome = "brickhome.jpg"
image brickfrown = "brickresizefrown.png"
image inventory = "inventory.jpg"

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define m = Character("mauve")
define b = Character("brick")
define fastdissolve = Dissolve(.2)

screen inventory_screen():
    vbox:
        align (0.9, 0.0)
        text "Inventory:"
        for item in backpack:
            text ("[item]")

# The game starts here.

label start:
    $backpack = set()
    show inventoryscreen("inventory")

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    scene blank

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.



    # These display lines of dialogue.

    "i'm tired of feeling sad all the time."
    "i wish i could be a more likeable person."
    "i don't want to put on a fake smile just to make those around me more comfortable."
    "but i'm tired of bringing down the people i care about."
    "i can't help but be like this."
    play music "Harlequin.mp3"
    show mauvepjs at right

    m "i have nothing to do today, but i have to get out of bed whether i like it or not."

    menu:
        "get out of bed":
            jump getoutofbed
label getoutofbed:
    m "should i even bother getting dressed?"
    menu:
        "get dressed":
            $ dressed = True
            jump continue1
        "don't get dressed":
            $ dressed = False
            jump continue1
label continue1:
    if dressed == True:
        "mauve changed out of her pjs."
        play sound "CLOTHES.ogg"
        hide mauvepjs
        show mauve at right
    m "i'm not sure if i'm hungry or not. should i eat something?"
    menu:
        "skip breakfast":
            jump skipbreakfast
        "eat breakfast":
            jump eatbreakfast
label skipbreakfast:
    m "i'll grab something now and eat it later."
    "mauve picked up a banana."
    jump skippbreakfast

label eatbreakfast:
    m "i'll just have something quick."
    menu:
        "eat handful of dry cereal":
            $ crunch = True
            jump finishbreakfast
        "eat protein bar":
            $ crunch = True
            jump finishbreakfast 
label finishbreakfast:
    if crunch == True:
        play sound "CRUNCH.ogg"
label skippbreakfast:
    m "i should go out today. i haven't spoken to or seen my friends in weeks."
    m "who should i go visit?"
    menu:
        "brick":
            $ brickhouse = True
            jump brickhome
        "cobalt":
            $ cobhouse = True
            jump cobhome
        "fern":
            $ fernhouse = True
            jump fernhome
        "mustard":
            $ mushouse = True
            jump mushome
label brickhome:
    if brickhouse == True:
        scene brickhome
        show brick at left
        if dressed == True:
            show mauve at right
        if dressed == False:
            show mauvepjs at right
        play music "JAUNTY.mp3"
        with fastdissolve
    b "hey, mauve! long time, no see! how have you been?"
    m "hey, brick. i've  been ... busy. how about you?"
    b "i was just about to head to the gym. you wanna come?"
    m "i'll ... pass, but thanks anyway."
    hide brick
    show brickfrown at left
    with fastdissolve
    b "oh, alright."
    m "sorry."
    hide brickfrown
    show brick at left
    with fastdissolve
    b "no need to apologize!"
    b "do you think you could do me a favor?"
    m "i guess."
    b "i borrowed headphones from fern about a week ago but i haven't had time to return them. do you think you could return them for me?"
    m "sure."
    play sound "CLOTHES.ogg"
    "mauve received the headphones."
    b "thanks so much! i really appreciate it!"
    m "no problem ..."
    
# This ends the game.


    return

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: need help with inventory? (screens??)

#2 Post by DannyGMaster »

I can't really be sure without testing since I don't have all those images, but the problem seems to be in this part:

Code: Select all

screen inventory_screen(): 
    vbox:
        align (0.9, 0.0)
        text "Inventory:"
        for item in backpack:
            text ("[item]")

# The game starts here.

label start:
    $backpack = set()
    show screen inventory_screen("inventory")
The main problem is you are calling your screen the wrong way. Instead of 'show inventory_screen()', to show a screen the statement must be 'show screen inventory_screen()'. Also, in the screen itself, you should not pass it "inventory" (that is a single string) instead you should pass the backpack variable itself. I don't know what your set() function does, I would assume it adds a new item to the inventory. In any case, you may want to revise your code with this:

Code: Select all

screen inventory_screen(inventory): 
    vbox:
        align (0.9, 0.0)
        text "Inventory:"
        for item in inventory:
            text ("[item]")

# The game starts here.

label start:
    $ backpack = set()
    show inventory_screen(backpack)
At least this should get the screen to show up where you want it to, assuming backpack does contain something that can be interpreted as text.
The silent voice within one's heart whispers the most profound wisdom.

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: need help with inventory? (screens??)

#3 Post by trooper6 »

DannyGMaster gave you this code, which is mostly right:
DannyGMaster wrote:

Code: Select all

screen inventory_screen(inventory): 
    vbox:
        align (0.9, 0.0)
        text "Inventory:"
        for item in inventory:
            text ("[item]")

# The game starts here.

label start:
    $ backpack = set()
    show inventory_screen(backpack)
At least this should get the screen to show up where you want it to, assuming backpack does contain something that can be interpreted as text.
But remember current best practices is to initialize your variables using "default" outside of a label. Like so:

Code: Select all

screen inventory_screen(inventory): 
    vbox:
        align (0.9, 0.0)
        text "Inventory:"
        for item in inventory:
            text ("[item]")

# The game starts here.

default backpack = set()

label start:
    show inventory_screen(backpack)
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

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: need help with inventory? (screens??)

#4 Post by DannyGMaster »

trooper6 is right, I am aware of the importance of default, I didnt mention it because I assumed it could have been defined elsewhere in another file where the code for the inventory would be.
The silent voice within one's heart whispers the most profound wisdom.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot]