Example needed - scrollable set size frame

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
Evildumdum
Regular
Posts: 191
Joined: Sun Jan 18, 2015 8:49 am
Projects: ApoclypseZ
Contact:

Example needed - scrollable set size frame

#1 Post by Evildumdum »

I put up a question a while back asking how to set the parameters of a frame so it will always stay the same size and just allow the player to scroll down if needs be. I got pointed towards some great material and thanks to that i now know the commands to use. I can now set the size of the frame correctly, but im struggling to make it so you can scroll down.

I learn really well if i am shown an example and then adapt it and pull it apart. Can anyone please change this code to make it so you can scroll down the frame? I'll be able to get it from that. Thankyou :)

Code: Select all

screen gun_choice_screen:
    textbutton "Back" xalign 0.5 yalign 0.8 action Jump("attack_menu")
    frame area 0.01,0.8,350,200:
        has vbox
        if rusty_pistol == True:
            textbutton "Rusty pistol: [pistol_ammunition]" action Jump("weapon_rusty_pistol")
        if pistol == True:
            textbutton "Pistol: [pistol_ammunition]" action Jump("weapon_pistol")
        if sawn_off_shotgun == True:
            textbutton "Sawn off shotgun: [shotgun_ammunition]" action Jump("weapon_sawn_off_shotgun")
        if double_barrel_shotgun == True:
            textbutton "Double barrel shotgun: [shotgun_ammunition]" action Jump("weapon_double_barrel_shotgun")
"If at first you don't succeed, try hitting it with a shoe."

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Example needed - scrollable set size frame

#2 Post by Alex »


User avatar
Evildumdum
Regular
Posts: 191
Joined: Sun Jan 18, 2015 8:49 am
Projects: ApoclypseZ
Contact:

Re: Example needed - scrollable set size frame

#3 Post by Evildumdum »

I've read that bit, but while i understand what the commands do, i dont understand in what context to use them. The example script shown there just confused me since i couldn't work out how it connected to and affected the frame and screen.
"If at first you don't succeed, try hitting it with a shoe."

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Example needed - scrollable set size frame

#4 Post by trooper6 »

If it were me (I can't do this now, because I have to go to a meeting). I would take that code and put it in a project and see what it looks like.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Evildumdum
Regular
Posts: 191
Joined: Sun Jan 18, 2015 8:49 am
Projects: ApoclypseZ
Contact:

Re: Example needed - scrollable set size frame

#5 Post by Evildumdum »

The code is from my project, that the problem. I have tried every way of using the viewport commands i can think of but i dont seem to be using them correctly. :(

Im basically asking for a sample so i can dissect it and find out in what contect to use the commands.
"If at first you don't succeed, try hitting it with a shoe."

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Example needed - scrollable set size frame

#6 Post by trooper6 »

I'm at a cafe so I can't teach myself how to do viewports and then tell you at the moment.

But what I recommend (this is what I would do myself), is make a brand new blank project. You say you want sample code, there is sample code on the page Alex linked to. Put that sample code in your new blank project (you'll have to get the washington.jpg from the tutorial folder, I believe), then run the project so you can see how it works.

Note that sample code is a screen, so after your start label you'll have to show the screen.
Also note, since the sample code on the page Alex linked to uses a side rather than a frame as its container, so you might want to look up the side object as well.

So, take that code, put it in a new project and then run it.

One more side note, if you want more bits of sample code above and beyond the example in the documentation, you can also do a search here for the term "viewport," I just did that and noticed there are quite a few examples of viewports in action. I won't be home for another 9-10 hours, so I can't do this myself. But you should be able to work it out yourself with some trial and error--using the code in the documentation in a new blank testing project.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
orz
Regular
Posts: 126
Joined: Tue Apr 21, 2015 10:19 pm
Contact:

Re: Example needed - scrollable set size frame

#7 Post by orz »

Consider something like this.

Code: Select all

screen gun_choice_screen:
    textbutton "Back" xalign 0.5 yalign 0.8 action Jump("attack_menu")
    viewport:
        area (0.01, 0.8, 350, 200)
        draggable True
        has vbox
        if rusty_pistol == True:
            textbutton "Rusty pistol: [pistol_ammunition]" action Jump("weapon_rusty_pistol")
        if pistol == True:
            textbutton "Pistol: [pistol_ammunition]" action Jump("weapon_pistol")
        if sawn_off_shotgun == True:
            textbutton "Sawn off shotgun: [shotgun_ammunition]" action Jump("weapon_sawn_off_shotgun")
        if double_barrel_shotgun == True:
            textbutton "Double barrel shotgun: [shotgun_ammunition]" action Jump("weapon_double_barrel_shotgun")
What may have been throwing you off was the use of 'side "c b r"' in the documentation's example, but that's only there to set up the bar and vbar's position (and the bar and vbar are there to act as scrollbars).

User avatar
Evildumdum
Regular
Posts: 191
Joined: Sun Jan 18, 2015 8:49 am
Projects: ApoclypseZ
Contact:

Re: Example needed - scrollable set size frame

#8 Post by Evildumdum »

Yes! This is perfect. I'll play around with this tomorow and see what i can figure out (my brain is fried tonight, i've spent the last eight hours programming new items into the game). Thankyou so much for the help.
"If at first you don't succeed, try hitting it with a shoe."

Post Reply

Who is online

Users browsing this forum: Google [Bot]