SOLVED - Cycling through backgrounds on a screen with button

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
Deji
Cheer Idol; Not Great at Secret Identities
Posts: 1592
Joined: Sat Oct 20, 2007 7:38 pm
Projects: http://bit.ly/2lieZsA
Organization: Sakevisual, Apple Cider, Mystery Parfait
Tumblr: DejiNyucu
Deviantart: DejiNyucu
Location: Chile
Contact:

SOLVED - Cycling through backgrounds on a screen with button

#1 Post by Deji »

I want to implement a little tips/tutorial thingie with Previous, Next and Exit buttons, so when you start it starts on the first screen/tips image and when you click Next it goes to the next one, and if you click previous it goes to the previous one, right?

So my logic tells me something like this should work:

Code: Select all

screen tutorial:
    default cur_screen_num = 1
    python:
        cur_screen = "assets/ui/tut/tips_%s.jpg"%(cur_screen_num)
    add cur_screen
    imagebutton:
        auto "assets/ui/tut/tips_prev_%s.png"
        action SetScreenVariable(cur_screen_num, cur_screen_num-=1)
        hovered Play("sound", "assets/sfx/menu_hover3.ogg")
        xpos 80
        ypos 680
    imagebutton:
        auto "assets/ui/tut/tips_next_%s.png"
        action SetScreenVariable(cur_screen_num, cur_screen_num+=1)
        hovered Play("sound", "assets/sfx/menu_hover3.ogg")
        xpos 1040
        ypos 680
    imagebutton: 
        auto "assets/ui/tut/tips_exit_%s.png"
        action Return()
        hovered Play("sound", "assets/sfx/menu_hover3.ogg")
        xpos 1140
        ypos 15
The I call the screen with call.
Buuuut the SetScreenVariable hates me. It doesn't even work if I change the second value to 1 or "1" for testing, it still gives me an error.
I honestly don't know how to do this and it doesn't seem like a straightforward solution for a beginner like me... help? :')
Last edited by Deji on Thu Jul 30, 2015 11:34 pm, edited 1 time in total.
Image
Tumblr | Twitter
Forever busy :')
When drawing something, anything, USE REFERENCES!! Use your Google-fu!
Don't trust your memory, and don't blindly trust what others teach you either.
Research, observation, analysis, experimentation and practice are the key! (:

User avatar
chocojax
Miko-Class Veteran
Posts: 705
Joined: Sun Oct 25, 2009 11:27 am
Projects: Umbra, Familiarity, Maleficent Justice
Tumblr: chocojax
Location: California
Contact:

Re: Cycling through backgrounds on a screen with buttons. Ho

#2 Post by chocojax »

I believe it should be:

Code: Select all

action SetScreenVariable("cur_screen_num", curr_screen_num+1)
  # BTW, it's curr_screen_num+1 when you're handing in a value, the +=1 only works when doing assignment like:
  # curr_screen_num = 1
  # curr_screen_num += 1 

User avatar
Deji
Cheer Idol; Not Great at Secret Identities
Posts: 1592
Joined: Sat Oct 20, 2007 7:38 pm
Projects: http://bit.ly/2lieZsA
Organization: Sakevisual, Apple Cider, Mystery Parfait
Tumblr: DejiNyucu
Deviantart: DejiNyucu
Location: Chile
Contact:

Re: Cycling through backgrounds on a screen with buttons. Ho

#3 Post by Deji »

OMG YES IT WORKS NOW!
Thank you, chocojax!

(Basically I didn't know I had to put the var name in "" ^^;;; )
Image
Tumblr | Twitter
Forever busy :')
When drawing something, anything, USE REFERENCES!! Use your Google-fu!
Don't trust your memory, and don't blindly trust what others teach you either.
Research, observation, analysis, experimentation and practice are the key! (:

Post Reply

Who is online

Users browsing this forum: Google [Bot]