So I have this locket with characters and you need to put the correct combination to open it, i created a list for the characters that will go in each slot, a pointer that points in which location the slot is and an image for each character that will change as the letter changes here is the code:
default leftLetters = ["a", "i", "m", "o", "q"]
default leftPointer = 0
default centerLetters = ["f", "r", "s", "u", "e"]
default centerPointer = 0
default rightLetters = ["x", "c", "d", "t", "v"]
default rightPointer = 0
define leftLetterSelectedImage = "buttons/characters/left_slot_o.png"
define middleLetterSelectedImage = "buttons/characters/middle_slot_u.png"
define rightLetterSelectedImage = "buttons/characters/right_slot_t.png"
Now I have this function that is used to change them, shown bellow:
def changeDownLeftChar():
global leftPointer
global leftLetterSelectedImage
store.leftPointer = (leftPointer + 1) % len(leftLetters)
nextLetter = leftLetters[leftPointer]
leftLetterSelectedImage = f"buttons/characters/left_slot_.{nextLetter}.png"
print("Ok")
print(leftPointer)
renpy.restart_interaction()
def changeUpLeftChar():
global leftPointer
global leftLetterSelectedImage
leftPointer = (leftPointer - 1) % len(leftLetters)
store.leftPointer = leftPointer
nextLetter = leftLetters[leftPointer]
leftletterimage = Image(f"buttons/characters/left_slot_.{nextLetter}.png")
print("Ok")
print(leftPointer)
renpy.restart_interaction()
And this buttons that triggers the function:
screen cabinet_arrows():
# Left slot
imagebutton auto "buttons/up_arrow_%s.png" xpos 0.295 ypos 0.022 focus_mask True at arrows action Function(changeDownLeftChar)
imagebutton auto "buttons/down_arrow_%s.png" xpos 0.295 ypos 0.61 focus_mask True at arrows action Function(changeUpLeftChar)
The thing is that the print function print variable changed, but when I click another time on the button and trigger the function it resets to normal so if i use the changeDownLeftChar function it will always print 1 instead of 1,2,3,4 and so on, because the variable doesn’t change in Ren’pys context, anybody knows why and how to solve it?
Thanks in advance!