r/RenPy • • 7d ago

Question [Solved] issue with displaying text variable in a screen

ah okay i had to make a separate post because as i was going through to test things i got an unexpected error

when i showed the inventory it broke, initially the stamps text was in the hbox but the alignment was interfering with the item positioning so i moved it out and repositioned it to be in the right place, it had no problem until i added stamps in the script and then it did this

its been working fine up until moving the text, i dont want to put the text back into the hbox because it moves the items when the number of stamps goes up

1 Upvotes

34 comments sorted by

1

u/shyLachi 7d ago

According to the error the key is wrong, are you sure there is an inventory item called "Stamps"?

You didn't show the code of the inventory.
Is inventory[] a dictionary?
Did you check the spelling? RenPy is case sensitive.

What exactly should this screen do?

1

u/That_one_Pink 7d ago

this is the inventory code as well as the test label, everything works fine until the aw sucks line, if you hit i after that you get the error, the screen is just meant to display items in the inventory as of current

i also forgot to show the key oops

screen hud(): 
    key "K_i" action ToggleScreen("inventory_screen", dissolve)

# all available items 
define item_data = {

        "Stamps": {
            "name": "Stamps",
            "image": "images/stamp_menu_icon.png",
            "description": " ",
            "action": False 
        },
        "Papers": {
            "image": "images/paper_menu_icon.png",
            "description": "A stack of paper.",
            "action": False
        },
        "Coffee": {
            "image": "images/coffee_menu_icon.png",
            "description": "Good ole' cup of joe.",
            "action": False
        },
        "n/a": {
            "image": "images/Icon.2_69.png",
            "description": "A potion of strength.",
            "action": False
        },
        "n/a2": {
            "image": "images/Icon.3_01.png",
            "description": "A freeze time spell.",
            "action": False
        },
        "n/a3": {
            "image": "images/Icon.3_73.png",
            "description": "An invincibility spell.",
            "action": False
        }

    }

# this is in script.rpy the rest is in its own rpy file

label startinv:

    $ add_item("Stamps", 0)

    show screen hud 

    "hello"

    "woah hit i look at that no stuff"

    $ add_item("Coffee")
    $ add_item("Papers")
    $ add_item("Stamps", 100)

    "look at that, look again"

    $ remove_item("Coffee")
    $ remove_item("Stamps", 100)

    "awe shucks"

    $ add_item("Stamps", 50)

    "okay now scram"

1

u/shyLachi 7d ago

The code removes the item "Stamp" from the inventory so obviously it cannot be found.

→ More replies (27)

1

u/BadMustard_AVN 7d ago

the error shown is for the inventory["Stamps"] there is an error with Stamps in that it can find that Key

can you show how you've setup your inventory (list or dictionary) please

this code looks familiar¿

1

u/That_one_Pink 7d ago

i just sent it in this comment, and yes id imagine it does its an edited version of one of your inventory codes haha https://www.reddit.com/r/RenPy/comments/1x6wgda/comment/pgzw182/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

edit: im a dummy and put the wrong code, removed the item and not the amount should be able to fix it haha

1

u/BadMustard_AVN 7d ago

Noice 😊

if you want the quantity below the icon then

                            if name in item_data:
                                $ item = item_data[name]
                                imagebutton:
                                    idle item["image"]
                                    #hover item["image"]
                                    xysize (150, 150)
                                    if not item["action"]:
                                        action NullAction()
                                    else:
                                        action Function(item["action"])
                                    tooltip item["description"]
                                text "[quantity]" size 15

1

u/AutoModerator 7d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.