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.
-
MiaLee
- Newbie
- Posts: 11
- Joined: Tue Jul 20, 2010 5:25 am
- Location: Toruń, Polska
-
Contact:
#1
Post
by MiaLee » Wed Feb 11, 2015 1:56 pm
Hi. I want to make screen with Stats & Inventory.
Code: Select all
screen overlay:
frame:
xalign 1.0 yalign 0.0
hbox:
textbutton "Inventory/Stats" action Show("inventory")
screen inventory:
modal True
frame:
xalign 0.5 yalign 0.5
vbox:
label "Inventory"
frame:
xalign 0.0
yalign 0.0
vbox:
for i in inventory:
$ iname = "img/" + i + ".png"
text "Items Here"
label "Stats"
text "Inteligencja [int]"
text "Szczęście [luck]"
text "Empatia [emp]"
text "Siła [sila]"
textbutton "Close" action Hide("inventory")
I am adding something...
Code: Select all
$ inventory.append("hat")
show screen overlay
Aaaand nothing.
Of course I have "hat.png" in folder img. But it won't show up. It even doesn't have to be an image, text would be okay too. How can I do it? I feel like I've tried everything to make my Inventory work.
-
Riverbird
- Newbie
- Posts: 21
- Joined: Wed Feb 11, 2015 2:41 pm
- Deviantart: RiverbirdAlpha
-
Contact:
#2
Post
by Riverbird » Wed Feb 11, 2015 2:49 pm
The line:
$ iname = "img/" + i + ".png"
Won't display anything - it's just iterating through the inventory and setting the variable iname to the filename you want to display.
If you change it to:
That should do the trick ^_^
-
MiaLee
- Newbie
- Posts: 11
- Joined: Tue Jul 20, 2010 5:25 am
- Location: Toruń, Polska
-
Contact:
#3
Post
by MiaLee » Wed Feb 11, 2015 4:19 pm
OMG yes. Thanks You so much.
One more thing. I want to make items clickable only in certain moments in game, so... Something True/False depending on item name.
Code: Select all
for i in inventory:
$ iname = "img/" + i + ".png"
add iname # It's okay!
$ ilabel = i + "label"
$ ilabel = False
if ilabel == True:
$ iname = i + "_%s.JPG"
imagebutton auto iname action Jump(i)
Then, somewhere in game just switch between $ arrowlabel = True / False to make things clickable.
But it doesn't work. I don't really know how to make this works.
-
octacon100
- Regular
- Posts: 163
- Joined: Thu Sep 12, 2013 11:23 pm
- Projects: Regeria Hope
- Organization: Golden Game Barn
- IRC Nick: Octacon100
- Location: Boston, MA
-
Contact:
#4
Post
by octacon100 » Wed Feb 11, 2015 4:28 pm
Usually with that I make two imagebuttons, one with the action you want, and one with a NullAction(), using the if between the two:
Like this:
Code: Select all
if ilabel == True:
$ iname = i + "_%s.JPG"
imagebutton auto iname action Jump(i)
else:
$ iname = i + "_%s.JPG"
imagebutton auto iname action NullAction()
Pretty sure that will do the trick. Not sure how your ilabel variable works.
-
MiaLee
- Newbie
- Posts: 11
- Joined: Tue Jul 20, 2010 5:25 am
- Location: Toruń, Polska
-
Contact:
#5
Post
by MiaLee » Wed Feb 11, 2015 5:29 pm
i've done that, but even when set on True, clicking do not force jumping to another label.
Code: Select all
[...] hbox:
for i in inventory:
$ ilabel = i + "label"
$ ilabel = False
if ilabel==True:
$ iname = "img/" + i + "_%s.png"
imagebutton auto iname action Jump(i)
else:
$ iname = "img/" + i + "_%s.png"
imagebutton auto iname action NullAction()
And at the beginning of the game:
Code: Select all
$ inventory.append("arrow")
$ arrowlabel = True
show screen overlay
-
octacon100
- Regular
- Posts: 163
- Joined: Thu Sep 12, 2013 11:23 pm
- Projects: Regeria Hope
- Organization: Golden Game Barn
- IRC Nick: Octacon100
- Location: Boston, MA
-
Contact:
#6
Post
by octacon100 » Wed Feb 11, 2015 5:35 pm
Do you have a label the same name as what 'i' is?
Like
label hat:
-
octacon100
- Regular
- Posts: 163
- Joined: Thu Sep 12, 2013 11:23 pm
- Projects: Regeria Hope
- Organization: Golden Game Barn
- IRC Nick: Octacon100
- Location: Boston, MA
-
Contact:
#7
Post
by octacon100 » Wed Feb 11, 2015 5:38 pm
Oh, the screen is setting ilabel to false.
You might be better off creating a "item" class, giving it a name variable, and a enabled variable. That way you can use stuff like i.name and i.enabled to create your screen.
-
MiaLee
- Newbie
- Posts: 11
- Joined: Tue Jul 20, 2010 5:25 am
- Location: Toruń, Polska
-
Contact:
#8
Post
by MiaLee » Wed Feb 11, 2015 5:44 pm
I have "lebel arrow" (my item is "arrow")... Well, even if I remove that statement, there is still the same problem.
If it really cannot be done then I'll check out classes. Thanks anyway ;3
Users browsing this forum: zyric