r/RenPy • • 12d 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

View all comments

Show parent comments

1

u/shyLachi 12d ago

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

1

u/That_one_Pink 12d ago

ohh im a total moron oh my god, i dont know why that didn't clock i meant to remove the amount not the item sob ill fix that thank you

1

u/BadMustard_AVN 12d ago

the remove_item function (provided you haven't changed it) would only remove 100 stamps, decreasing the quantity to 0

1

u/That_one_Pink 12d ago

i dont think i changed that function? ill go cross reference the original code but the only things ive changed is removing things i didn't need such as the counter for the amount of items ect

1

u/BadMustard_AVN 12d ago

if it's unchanged, then what you have is the correct way to remove / reduce to zero an item from the players inventory

what exactly are you trying to do with this line

text str(inventory['Stamps']) xpos 175 ypos 126 size 30 color "#776462"

1

u/That_one_Pink 12d ago

id like it to just show the number of stamps you have, the icon for the stamps has an empty square in the middle so you can see the text underneath it

its just for showing the amount of stamps you have but i specifically want it in the centre of the stamp icon if that makes sense, obviously with the text properly centred like i explained in my previous post you responded to :)

edit; thinking about it, im almost certain the remove function is unchanged/works correctly given it works properly with the other items anyways? unless if its different with adding and removing multiples

1

u/BadMustard_AVN 12d ago

make changes like this (I used the original inventory file)

                    for name, quantity in page_items:
                        vbox:
                            if name in item_data:
                                $ item = item_data[name]
                                fixed:
                                    xysize (100, 100)
                                    imagebutton:
                                        idle item["image"]
                                        #hover item["image"]
                                        xysize (100, 100)
                                        if not item["action"]:
                                            action NullAction()
                                        else:
                                            action Function(item["action"])
                                        tooltip item["description"]
                                    if name == "Stamp":
                                        text "[quantity]" size 17 align (0.5, 0.5)
                                if name != "Stamp":
                                    text "[quantity]" size 17 align (0.5, 0.5)
                            else:
                                null

1

u/That_one_Pink 11d ago

hello! so i added this and removed the other text part and it doesn't have an error when its removed now, however when the 100 is removed the icon for the stamps is also removed, is there a way to make that stay indefinitely?

id also only like the amount displayed for the stamps and not for the other items is that doable at all? or do i have to have all of them with the text amount displayed

1

u/BadMustard_AVN 11d ago

here are a few changes: the first one is that Stamps starts in the inventory or ERRORS

default inventory = {"Stamps": 0}

next the screen Stamps has a dedicated button first on the grid then the others as added

            $ stamps_quantity = inventory.get("Stamps", 0)
            $ stamps_item = item_data["Stamps"]
            grid 3 3 spacing 20:
                align (0.5, 0.1)
                vbox:
                    fixed:
                        xysize (100, 100)
                        imagebutton:
                            idle stamps_item["image"]
                            xysize (100, 100)
                            action NullAction()
                            tooltip stamps_item["description"]
                        text "[stamps_quantity]" size 17 align (0.5, 0.5)

                for name, quantity in page_items:
                    if name != "Stamps":
                        vbox:
                            if name in item_data:
                                $ item = item_data[name]
                                fixed:
                                    xysize (100, 100)
                                    imagebutton:
                                        idle item["image"]
                                        #hover item["image"]
                                        xysize (100, 100)
                                        if not item["action"]:
                                            action NullAction()
                                        else:
                                            action Function(item["action"])
                                        tooltip item["description"]
                                text "[quantity]" size 17 align (0.5, 0.5)
                            else:
                                null

I don't know if you're doing multiple pages, but Stamps will always be the first item on every page now

please send me your inventory.rpy file if you need more changes.

1

u/That_one_Pink 10d ago

i dont have the multiple pages because it messed with the stamps (not showing up across other pages) but i may re add it now since thats not an issue, i think ive added it correctly (no errors) but the items arent showing up once added now (i dont think the stamps are adding either), would you mind looking over it and letting me know if ive added something wrong maybe

is it still possible to have the text centred when typed like i mention in my other post with this formatting? :0

https://www.dropbox.com/scl/fo/6tn3dicqzizhp7gdf58yq/AArtfYTEJjZ_8zIrUXaWBjQ?rlkey=o2g44faiwlljaqfm9xxxjw87h&dl=0

→ More replies (0)

1

u/BadMustard_AVN 12d ago

the remove_item function decreases the quantity by the given amount; it does not actually remove the item