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.
-
SteelRazer
- Newbie
- Posts: 10
- Joined: Thu Dec 06, 2018 12:25 pm
-
Contact:
#1
Post
by SteelRazer » Thu Dec 06, 2018 1:11 pm
Hello
I want to print a list as days in a viewport
I have a problem with printing the list, basically it has problem with indices I don't know how to fix. In python shell it works when I use i but not in ren'py.
(List indices must be integers, not unicode)
Code: Select all
define days = ['mon','tue','wen','thu']
screen days_screen():
frame:
viewport:
scrollbars "vertical"
xmaximum 500
mousewheel True
draggable True
has vbox
$ rows = len(days)
for i in range(0, len(days)):
text "[days[i]]"
label start:
call screen days_screen
return
If it's in a wrong thread, move it there.
Thanks everybody for help
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#2
Post
by Alex » Thu Dec 06, 2018 2:23 pm
That happened 'cause you showing text in a screen, try it like
Code: Select all
default my_list = ["one", "two", "three"]
screen list_scr():
vbox:
align(0.2, 0.1)
for i in range(0, len(my_list)):
text "%s" % my_list[i]
vbox:
align(0.4, 0.1)
for i in my_list:
text"[i]"
label start:
scene black
"..."
show screen list_scr
"?"
-
SteelRazer
- Newbie
- Posts: 10
- Joined: Thu Dec 06, 2018 12:25 pm
-
Contact:
#3
Post
by SteelRazer » Thu Dec 06, 2018 2:37 pm
It works but breaks the viewport idea. I want to be able to add x items to the list and then have it displayed in a viewport.
but your
solved the problem. Also is there any way to add to the text like textbutton a hover action to show an image? For example with your list, when I would hover over a 1 it would show a image on x,y pos on the screen. Simply adding a hovered with image to a textbutton makes it unresponsive
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#4
Post
by Alex » Thu Dec 06, 2018 4:40 pm
Actually, for i in my_list - is more preferable way.
And what's wrong with putting it inside a viewport?
You can add a hovered action of showing screen that contains an image and unhovered action of hiding that screen.
Code: Select all
image img_1:
"img_1.png"
image img_2:
"img_2.png"
image img_3:
"img_3.png"
default my_list = [["one","img_1"], ["two", "img_2"], ["three", "img_3"]]
screen img_scr(img=None):
add img align(0.4, 0.1)
#text img align(0.4, 0.1)
screen list_scr():
vbox:
align(0.2, 0.1)
for i in my_list:
textbutton str(i[0]) action [[]] hovered Show("img_scr", img=i[1]) unhovered Hide("img_scr")
label start:
scene black
"..."
show screen list_scr
"?"
https://www.renpy.org/doc/html/screens.html#textbutton
https://www.renpy.org/doc/html/screen_actions.html#Hide
-
SteelRazer
- Newbie
- Posts: 10
- Joined: Thu Dec 06, 2018 12:25 pm
-
Contact:
#5
Post
by SteelRazer » Thu Dec 06, 2018 5:03 pm
Work very well. I just meant that your code didn't use my viewport originally but I got it already working in viewport. Just one last thing what is that action you used in list_scr. And thank you so much.
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#6
Post
by Alex » Thu Dec 06, 2018 5:16 pm
Well, to be sensitive (change its state, do hovered/unhovered actions) button must have an action
is insensitive.
So, if you don't have an actual action for the button you can use NullAction() or an empty list of action [[]]
('cause you can set a list of actions for the button, like)
Code: Select all
textbutton "!!!" action [Show("some"screen"), Hide("the_other_screen")]
https://www.renpy.org/doc/html/screen_a ... NullAction
Users browsing this forum: Google [Bot]