How to make a button that opens a vbox to it's right
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.
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.
-
zeroTheHero
- Regular
- Posts: 64
- Joined: Mon May 07, 2018 10:49 am
- Contact:
How to make a button that opens a vbox to it's right
I've been searching for a couple days but can't seem to find a solution. To give an example, I want to make a textbutton saying 'Pokemon' that opens some buttons in a vbox to it's right (say a list of 6 pokemon names). Each button with Pokemon name then opens a vbox with Pokemon moves. Selecting a Pokemon move does some action, like damaging an enemy.
I've played around with the button's "action" property but there's no action(show) command and I can't get action(call) to work here. How should I go about this? Any help would be appreciated!
I've played around with the button's "action" property but there's no action(show) command and I can't get action(call) to work here. How should I go about this? Any help would be appreciated!
Re: How to make a button that opens a vbox to it's right
Actually there is action(show) command. Here is how I'm using it:
In my case this repleces whole screen menu "extra" with "extra2" and vice versa in menu "extra2". I don't if this helps you but you might find solution to show only portion of screen.
I for example would really like to know how to replace only part of screen.
Code: Select all
hotspot(25,484,149,40) action [Show("extra2",transition=None),Hide("extra")]I for example would really like to know how to replace only part of screen.
Re: How to make a button that opens a vbox to it's right
I haven't tried this but I'd imagine you can achieve this by using a combination of showif and ToggleScreenVariable()
Something along the lines of this (not tested):
Something along the lines of this (not tested):
Code: Select all
screen pokemons:
default showbuttons = False
hbox:
textbutton "show buttons" action ToggleScreenVariable("showbuttons")
showif showbuttons:
vbox:
textbutton "Pikachew" action Return("Pikachew")
textbutton "Bubblesaura" action Return("Bubblesaura")
textbutton "Charmingdan" action Return("Charmingdan")
-
zeroTheHero
- Regular
- Posts: 64
- Joined: Mon May 07, 2018 10:49 am
- Contact:
Re: How to make a button that opens a vbox to it's right
Thanks for the replies, I really appreciate it. And sorry for getting back so late, I really needed some sleep
Anyways, I tried your codes:
@ kostek00
I saw the doc for https://www.renpy.org/doc/html/screen_a ... 0show#Show, and tried this
Doesn't work 
Firstly, when we return("Pikachew") we return a string, right? How do we return a screen with Pikachew's moves? Sorry for asking, but I couldn't find return() in the documentation apart from an example. I tried this:
(Ignore, Noob code incoming, keeping it because it makes other posts relevant)
Doesn't work
Second, I don't really get what TogglescreenVariable does, do you know if there's a tutorial on lemma for it? I searched, but couldn't find one. Seeing some more sample code would help me understand it better I think
Thanks for your time, I really appreciate it!
Anyways, I tried your codes:
@ kostek00
I saw the doc for https://www.renpy.org/doc/html/screen_a ... 0show#Show, and tried this
Code: Select all
screen button():
button:
textbutton "Pika" action[ Show("Move1", transition = None)] Wow, your code works! And it's so cool how you guys can say complex code correctly without any testing.kivik wrote: ↑Mon May 07, 2018 11:47 amI haven't tried this but I'd imagine you can achieve this by using a combination of showif and ToggleScreenVariable()
Something along the lines of this (not tested):Code: Select all
screen pokemons: default showbuttons = False hbox: textbutton "show buttons" action ToggleScreenVariable("showbuttons") showif showbuttons: vbox: textbutton "Pikachew" action Return("Pikachew") textbutton "Bubblesaura" action Return("Bubblesaura") textbutton "Charmingdan" action Return("Charmingdan")
Firstly, when we return("Pikachew") we return a string, right? How do we return a screen with Pikachew's moves? Sorry for asking, but I couldn't find return() in the documentation apart from an example. I tried this:
(Ignore, Noob code incoming, keeping it because it makes other posts relevant)
Code: Select all
screen battle():
screen pokemons:
default showbuttons = False
hbox:
textbutton "show buttons" action ToggleScreenVariable("showbuttons")
showif showbuttons:
vbox:
textbutton "Pikachew" action Return(screen(Pikachew))
...
screen Pikachew():
vbox:
textbutton "Thunder" action Return("Thunder")
Second, I don't really get what TogglescreenVariable does, do you know if there's a tutorial on lemma for it? I searched, but couldn't find one. Seeing some more sample code would help me understand it better I think
Thanks for your time, I really appreciate it!
Last edited by zeroTheHero on Tue May 08, 2018 12:49 am, edited 6 times in total.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
- Contact:
Re: How to make a button that opens a vbox to it's right
ToggleScreenVariable (to the best of my limited knowledge) takes a variable you define and switches it between True and False.
I don't understand the significance of "screen" in it, but basically its an on / off trigger.
I don't understand the significance of "screen" in it, but basically its an on / off trigger.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
-
zeroTheHero
- Regular
- Posts: 64
- Joined: Mon May 07, 2018 10:49 am
- Contact:
Re: How to make a button that opens a vbox to it's right
Thank you so much, this really helped clear kivik's code a lot for me.
To summarize my post, kivik showed me how to open a vbox from a textbutton using showif and ToggleScreenVariable
What I'm trying to do is open another vbox from textbutton in above mentioned vbox. So, I tried turning
Code: Select all
return("Pikachew") Code: Select all
return(screen(Pikachew)) Sorry if I'm not clear, if there's any doubt I'd happily clear it for you.
Thanks
Re: How to make a button that opens a vbox to it's right
Hey sorry I had an early night and just seen this. Glad the code works, that's a pleasant surprise!
Now if you want another set of vboxes, you'd just nest another layer of vboxes, so another set of variables can be toggled to turn the second set of vboxes on and off. The way my code works isn't that it does a show screen (that shows a new screen, not a vbox) but it relies on the showif keyword.
Not sure if you click on the link I gave above (I linked it on the showif and the ToggleScreenVariable keywords) to read more about it. The idea is that you put a condition in your showif - if it's True it shows what's inside its block; otherwise it hides it, thus toggling a screen variable will show and hide the vbox for you.
To do this at a second level, you'll probably just need to use a second screen variable:
This time the screen variable takes a string, because we want to know which pokemon you've clicked on, and we can set it using SetScreenVariable().
I've also added frames this time to add a bit of a placeholder for where these vboxes will be.
Now the Return function, I assumed you'll be calling the screen from your code, and thus Return() is the best way to return what choice your player made. So your game code should look something like this:
Or maybe you have it in a condition block:
Even the screen code can be simplified if you use a list, dictionary or ordereddict to store the list of pokemons and their corresponding information. However you may want to get to grips with this first.
Now if you want another set of vboxes, you'd just nest another layer of vboxes, so another set of variables can be toggled to turn the second set of vboxes on and off. The way my code works isn't that it does a show screen (that shows a new screen, not a vbox) but it relies on the showif keyword.
Not sure if you click on the link I gave above (I linked it on the showif and the ToggleScreenVariable keywords) to read more about it. The idea is that you put a condition in your showif - if it's True it shows what's inside its block; otherwise it hides it, thus toggling a screen variable will show and hide the vbox for you.
To do this at a second level, you'll probably just need to use a second screen variable:
Code: Select all
screen pokemons:
default show_pokemons = False
default show_pokemon = False
hbox:
frame:
xsize 300
ysize 400
textbutton "show buttons" action ToggleScreenVariable("show_pokemons")
frame:
xsize 300
ysize 400
showif show_pokemons:
vbox:
textbutton "Pikachew" action SetScreenVariable("show_pokemon", "pikachew")
textbutton "Bubblesaura" action SetScreenVariable("show_pokemon", "bubblesaura")
textbutton "Charmingdan" action SetScreenVariable("show_pokemon", "charmingdan")
frame:
xsize 300
ysize 400
showif show_pokemon == "pikachew":
vbox:
label "Pikachew"
text "Teeth"
text "add more stuff here"
textbutton "Attack" action Return("pikachew")
showif show_pokemon == "bubblesaura":
vbox:
label "Bubblesaura"
text "Soap"
text "add more stuff here"
textbutton "Attack" action Return("bubblesaura")
showif show_pokemon == "charmingdan":
vbox:
label "Charmingdan"
text "Charisma"
text "add more stuff here"
textbutton "Attack" action Return("charmingdan")
I've also added frames this time to add a bit of a placeholder for where these vboxes will be.
Now the Return function, I assumed you'll be calling the screen from your code, and thus Return() is the best way to return what choice your player made. So your game code should look something like this:
Code: Select all
call screen pokemons
if _return:
call expression _return + "_attack"
Code: Select all
call screen pokemons
if _return == "pikachew"
# do bite attack
if _return == "bubblesaura"
# do bubble attack stuff
etc..
-
zeroTheHero
- Regular
- Posts: 64
- Joined: Mon May 07, 2018 10:49 am
- Contact:
Re: How to make a button that opens a vbox to it's right
kivik thank you so much for taking your time out for this! I went through your code and it made so much sense. It's funny how I knew I just had to repeat your code, but for the life of me I couldn't figure out how. Even if I'd known about SetScreenVariable, I doubt I'd be able to write what you've come up with. I can't imagine the mental gymnastics programmers go through to solve 'simple' problems like this. Seriously, thanks, you've not only solved my problem but also made me a better coder(I hope XD)
On a side note, have you played any pokemon? The names you chose suggest you do, but the attacks... XD
On a side note, have you played any pokemon? The names you chose suggest you do, but the attacks... XD
Re: How to make a button that opens a vbox to it's right
Glad to be of help! To be fair you had the idea, and you were curious enough to wonder if it's possible, and I just had a play with it based on what I knew. I only knew all that stuff because I've been lurking and reading every thread on the forum as well, I didn't know about showif until a few weeks ago!zeroTheHero wrote: ↑Tue May 08, 2018 12:31 pmkivik thank you so much for taking your time out for this! I went through your code and it made so much sense. It's funny how I knew I just had to repeat your code, but for the life of me I couldn't figure out how. Even if I'd known about SetScreenVariable, I doubt I'd be able to write what you've come up with. I can't imagine the mental gymnastics programmers go through to solve 'simple' problems like this. Seriously, thanks, you've not only solved my problem but also made me a better coder(I hope XD)
On a side note, have you played any pokemon? The names you chose suggest you do, but the attacks... XD
I did play the first gen pokemon games (I'm pretty ancient), I just thought pikachew was funny and had fun with the rest
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
Re: How to make a button that opens a vbox to it's right
edit, post deleted:
Sorry posted in the wrong thread.
Sorry posted in the wrong thread.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], _ticlock_