Inventory help?

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
dale01102
Newbie
Posts: 9
Joined: Sat Feb 03, 2018 7:58 pm
Contact:

Inventory help?

#1 Post by dale01102 » Sat Jun 16, 2018 7:37 pm

Could someone walk me through a super basic inventory.
I don't need HP or MP or anything like that just items to be stored in my inventory with a description of that item.
Its for a Tycoon game that I am working on, and I can't get my head around what to do.
I had a look at (viewtopic.php?f=51&t=23071) but don't full understand it but I do get parts of it. Would of been nice if it had diagrams and pitchers of what part of the code dose what, my dyslexia kicks in when I read a description of something i don't full understand

User avatar
Sword of Akasha
Regular
Posts: 61
Joined: Sun Dec 14, 2014 6:51 am
Projects: Shadows of Shattered Dreams
Organization: Akashic Creative Studios
Deviantart: Sword-of-Akasha
Contact:

Re: Inventory help?

#2 Post by Sword of Akasha » Sun Jun 17, 2018 2:24 am

I remember having the same issue when I was first starting out. Lemme see.

You're basically creating a screen with an image map. Below I've attached my version.

In your actual game script. You plug in the if conditions so that objects pop up when you have them. You declare them at the beginning of the game.

Code: Select all

## assorted items -------------------------------------------------------------------------------------------------------
    $ save_name = "Chapter 0 Dreams of Spring and Love"
    $ inventoryon = False
    $ flowers = False
    $ capeclasp = True
    $ inventoryhint = False
    $ noteshint = False
    $ musichint = False
    $ griffinletter = False
    $ zebrascroll = False
    $ demo = True
    
## Ammunition -------------------------------------------------------------------------------------------------------
    $ shotgems = 3
    $ shotgemsfrost = 2
    $ shotgemslight = 2
    $ shotgemsfire = 0
This stuff goes into your screens.rpy file. You create screens for the inventory items too. I even have a hover so that people know you're selecting stuff.

The action ShowMenu("objectrobe") jumps you to another screen where you can have details about your item. Put an action in your quick menu show players can jump to your inventory screen.

Code: Select all

# Inventory menu
# 

screen inventory():
    window:
        style "gm_root"
    tag menu
    use navigationreturnonly
    imagemap:
        ground "objects/inventory.png"
        hover "objects/inventory2.png"

        hotspot (20, 15, 150, 150) action Show("objectmagestaff")
        hotspot (173, 15, 150, 150) action ShowMenu("inventory")
        hotspot (327, 15, 150, 150) action ShowMenu("inventory")
        hotspot (475, 15, 150, 150) action ShowMenu("inventory")
        hotspot (625, 15, 150, 150) action ShowMenu("inventory")
# Row
        hotspot (20, 172, 150, 150) action ShowMenu("objectrobe")
        hotspot (173, 172, 150, 150) action ShowMenu("objecthat")
        hotspot (327, 172, 150, 150) action ShowMenu("inventory")
        hotspot (475, 172, 150, 150) action ShowMenu("inventory")
        #hotspot (625, 172, 150, 150) action ShowMenu("inventory")
# Row
        hotspot (20, 322, 150, 150) action ShowMenu("inventory")
        hotspot (173, 322, 150, 150) action ShowMenu("inventory")
        hotspot (327, 322, 150, 150) action ShowMenu("inventory")
        hotspot (475, 322, 150, 150) action ShowMenu("inventory")
        hotspot (625, 322, 150, 150) action ShowMenu("current_track")
        
    if capeclasp:    
            imagemap:
                    ground "objects/capeclasp.png"
                    hover "objects/capeclasp2.png"
                    hotspot (475, 172, 150, 150) action ShowMenu("objectcapeclasp")
        
    if flowers:    
            imagemap:
                    ground "objects/flowers.png"
                    hover "objects/flowers2.png"
                    hotspot (625, 172, 150, 150) action ShowMenu("objectflowers")
    if shotgems > 0: 
            imagemap:
                    ground "objects/shotgem.png"
                    hover "objects/shotgem2.png"
                    hotspot (173, 15, 150, 150) action ShowMenu("objectshotgem")
            frame:
                    xpos (288)
                    ypos (122)
                    has vbox
                    text "{i}[shotgems] {/i}"
    if shotgemsfrost > 0: 
            imagemap:
                    ground "objects/shotgemfrost.png"
                    hover "objects/shotgemfrost2.png"
                    hotspot (327, 15, 150, 150) action ShowMenu("objectshotgemfrost")
            frame:
                    xpos (438)
                    ypos (122)
                    has vbox
                    text "{i}[shotgemsfrost] {/i}"
    if shotgemslight > 0: 
            imagemap:
                    ground "objects/shotgemlight.png"
                    hover "objects/shotgemlight2.png"
                    hotspot (475, 15, 150, 150) action ShowMenu("objectshotgemlight")
            frame:
                    xpos (588)
                    ypos (122)
                    has vbox
                    text "{i}[shotgemslight] {/i}"
    if shotgemsfire > 0: 
            imagemap:
                    ground "objects/shotgemfire.png"
                    hover "objects/shotgemfire2.png"
                    hotspot (625, 15, 150, 150) action ShowMenu("objectshotgemfire")
            frame:
                    xpos (738)
                    ypos (122)
                    has vbox
                    text "{i}[shotgemslight] {/i}"   
                    
    frame:
        xpadding 10
        ypadding 10
        xalign 0.05
        yalign 0.9
        
        has vbox
        text "Inventory"
        
    imagemap:
        ground "objects/jumptonotesbutton.png"
        hover "objects/jumptonotesbutton2.png"
        hotspot (503, 495, 230, 100) action [Play("sound", "soundeffects/Sound Effect - Paper Rustle 6.mp3", selected=None), ShowMenu("fieldnotes")]
Here's what it looks like put together. I got a counter for consumables.
inventory example.png
Image

dale01102
Newbie
Posts: 9
Joined: Sat Feb 03, 2018 7:58 pm
Contact:

Re: Inventory help?

#3 Post by dale01102 » Sun Jun 17, 2018 10:46 am

A bit different but it has given me an idea for a different style of inventory thank you.

Post Reply

Who is online

Users browsing this forum: MrDracosaurio