[SOLVED] Is it possible to make a sprite gallery using SetScreenVariable?

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
User avatar
lacrimoosa
Newbie
Posts: 23
Joined: Tue Jun 05, 2018 8:31 pm
Projects: Alice's Reverie
Organization: Red&Pink games
Tumblr: lacrimoosa, alicesreverie
itch: redpink-games
Contact:

[SOLVED] Is it possible to make a sprite gallery using SetScreenVariable?

#1 Post by lacrimoosa »

I'm attempting to make an outfit/sprite gallery inside of my game's regular gallery. In theory, I'm trying to make it so that clicking on arrows next to the sprite causes a different variation of the sprite to pop up in place of the sprite already there like so:
screenshot0055.png
screenshot0056.png
so far I have added and initialized a variable so I know which sprite to show

Code: Select all

default aliceOutfit = 0
but when I try to increment/decrement the variable using this as the action on the "next" button-

Code: Select all

SetScreenVariable("aliceOutfit", += 1)
I just get an error saying the syntax is invalid.

I figure there has to be a way to do this, whether with or without SetScreenVariable() or something else. If anyone knows an easier or correct way to go about this, it would be a great help! I've searched about to see if anyone had posted about making a sprite gallery but I couldn't find anything.
Last edited by lacrimoosa on Sat Mar 28, 2020 8:09 pm, edited 1 time in total.
Image

An artist/writer/programmer working to get mine and my partner's ideas out into the world through Red & Pink Games!
"Oh geez, looks like the code just broke."

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Is it possible to make a sprite gallery using SetScreenVariable?

#2 Post by gas »

The easier thing that come to my mind is to use a DEQUE (a special list that have stack functions) and a Function() action.

Code: Select all

init python:
    from collections import deque

default dress_list = deque(range(3)) # here three dresses.

# bla bla bla the screen
textbutton "Next" action Function("set_dress",1)
textbutton "Prev" action Function("set_dress",-1)

init python:
    def set_dress(amount):
        dress_list.rotate(amount)
        return True
Now, dress_list[0] is always the value of the dress to show.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
lacrimoosa
Newbie
Posts: 23
Joined: Tue Jun 05, 2018 8:31 pm
Projects: Alice's Reverie
Organization: Red&Pink games
Tumblr: lacrimoosa, alicesreverie
itch: redpink-games
Contact:

Re: Is it possible to make a sprite gallery using SetScreenVariable?

#3 Post by lacrimoosa »

gas wrote: Sat Mar 28, 2020 6:59 pm The easier thing that come to my mind is to use a DEQUE (a special list that have stack functions) and a Function() action.

Code: Select all

init python:
    from collections import deque

default dress_list = deque(range(3)) # here three dresses.

# bla bla bla the screen
textbutton "Next" action Function("set_dress",1)
textbutton "Prev" action Function("set_dress",-1)

init python:
    def set_dress(amount):
        dress_list.rotate(amount)
        return True
Now, dress_list[0] is always the value of the dress to show.
Thank you! That is exactly the thing I had in mind! :D I knew about stacks because of general OOP knowledge, but I had no idea how to work it with ren'py syntax.
Image

An artist/writer/programmer working to get mine and my partner's ideas out into the world through Red & Pink Games!
"Oh geez, looks like the code just broke."

Post Reply

Who is online

Users browsing this forum: Google [Bot]