Page 1 of 1

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

Posted: Sat Mar 28, 2020 6:09 pm
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.

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

Posted: Sat Mar 28, 2020 6:59 pm
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.

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

Posted: Sat Mar 28, 2020 8:07 pm
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.