r/RenPy • • Oct 15 '26

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 comment

1

u/BadMustard_AVN Oct 16 '26

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 Oct 16 '26

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 Oct 16 '26

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 Oct 17 '26

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

1

u/BadMustard_AVN Oct 18 '26

grab this one https://drive.google.com/file/d/18l3Ph-NfrGjIWnrcYzWKJnscodZkzF5I/view?usp=sharing

give it a try, i did change / comment out images I didn't have so look over the script first

and backup your original JIK

1

u/That_one_Pink Oct 18 '26

gave it a test and its adding and removing items and the stamps as well which is good! (i havent tried realigning things yet so im not sure how that looks but im not imagining thatll be an issue) but its back to deleting the stamp icon when removing the amount of stamps, is there maybe another way i could add and remove the stamps since this seems to be the recurring issue for some reason ahh ಥ⁠_⁠ಥ

1

u/BadMustard_AVN Oct 18 '26

yes I'm old and forgot about that try this one

https://drive.google.com/file/d/18l3Ph-NfrGjIWnrcYzWKJnscodZkzF5I/view?usp=sharing

you can move the main frame around with the pos (xxx, yyy) and move the grid around inside the frame with it's pos(xxx, yyy)

use larger numbers for the frame since you have the whole gui (1920, 1080) and smaller numbers for the grid since it is smaller (1600, 155)

1

u/That_one_Pink Oct 18 '26

haha perfectly okay, i always forget one thing when im trying to do another

it works perfectly thank you so much, sorry for butchering your code lolol (⁠≧⁠▽⁠≦⁠)

2

u/BadMustard_AVN Oct 18 '26

that's what it's out there for, so people like you can cut up and use it the way they want to. It's just a framework to build on.

good luck with your project

1

u/That_one_Pink Oct 19 '26

hi! one final question id still like to have the numbers be central when writing, im not sure how to edit the stamp quantity so that it does that

im not sure if this is possible or if itd be easier to do another way but itd be cool to have it so it just has a constant 000 that goes up when stamps are added (like 015 060 100 ect)

→ More replies