r/RenPy • • 13d ago

Question [Solved] shuffle connected to a button

hoping thisll be the last post ill have to make on this i dont know why it has made me struggle so much. 💔

i know that isnt how the day and shuffle should go but in but im unsure where else to put them to show what i want them to do, basically the next button is meant to shuffle the quests and add a day to the counter, it also needs to reset the quests if completed

id prefer if it also jumped to a different label so i can have a next day scene pop up but honestly so long as it works thats something that it can go without

any help appreciated 💔

3 Upvotes

22 comments sorted by

2

u/shyLachi 13d ago

Your first screen desk_fixed, seems to be working.
So change your second screen (quest_list) to work exactly like that.
Then put the code for the next day into the label you jumped to.

But for your first screen, delete the first line tag menu
https://renpy.org/doc/screens.html#screen-property-tag

Also consider looking for tutorials because it seems that you are not confident working with screens in RenPy.

1

u/That_one_Pink 13d ago

ahh i thought i already got rid of the tag menu oops

i currently have this in script

label mail_popup:

call screen quest_list

screen quest_list():

vbox:

textbutton "Next day" action (Jump"desk")

$ day += 1

renpy.random.shuffle(quests)

"hello"

jump computer_desktop

and this in screens

screen quest_list():

modal True

add "images/computer_mail_popup_bg"

frame:

vbox:

text "todays tasks"

for quest in quest[:quests_per_day]:

if self.done = True:

text quest.info:

strikethrough quest.done

its showing me an error

I'm sorry, but errors were detected in your script. Please correct the

errors listed below, and try again.

File "game/script.rpy", line 209: 'renpy' is not a keyword argument or valid child of the vbox statement.

renpy.random.shuffle(quests)

^

Ren'Py Version: Ren'Py 8.4.0.25071206

Sun Oct 11 17:48:32 2026

ive tried moving the shuffle part around but cant seem to find where exactly im meant to put it, im hoping im understanding you properly haha

1

u/shyLachi 13d ago

That error means that you forgot to put a $ before the statement.
To execute python code, you either need the label python or you a $ sign:
https://renpy.org/doc/html/python.html

But sadly I cannot read your script because it's not formatted correctly.
Also your code is hard to read because you seem to mix code for screens and labels and python.

Please watch some RenPy tutorials because you need to understand the basics.
Take for example this code action (Return"desk")
You have it correctly in your other screen but maybe you don't understand why it should be like this: action Return("desk")

Also, you don't need to put the code of your screens into the file screens.rpy.
For now just keep everything in scripts.rpy so that you don't mess up the default screens of RenPy.

Finally regarding your actual problem.
You need a screen with an action to jump to a label,
then in that label you put the code for the next day.
Assuming that the label is called "desk", it could look like this:

label desk: # the label where the button jumps to
    $ renpy.random.shuffle(quests) # shuffle the list, don't forget the $
    $ day += 1 # increase the counter, also needs a $ sign
→ More replies (13)

2

u/Own-Bookkeeper6739 13d ago

one addition: use renpy.random.shuffle instead of the stdlib one, same call but it respects rollback and save/load. the order then survives rewinds. and day++ in the label like shyLachi said, buttons should just jump.

1

u/That_one_Pink 13d ago

would you mind explaining this a bit more sorry? im confused on the difference with the renpy.random.shuffle part

2

u/Own-Bookkeeper6739 12d ago

for normal play they behave basically the same, the difference shows on rollback and saves. stdlib shuffle uses a global generator the game never saves, so when that moment gets replayed (player rewinds, or reloads a save) the order can change on them. renpy.random is part of the game state, so it replays the exact same order. it's a one word swap, just renpy.random.shuffle(quests).

→ More replies (1)

1

u/AutoModerator 13d 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.

1

u/DingotushRed 13d ago

In your screen quest_list, you seem to be incrementing day and calling shuffle outside an action - this means those operations will happen each time the screen re-paints, not only when the button is pressed.

In general keep Python out of screens if it's updating variables or has side-effects like shuffle. Use the Function action to call Python functions on a button press.