A new screen question
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.
-
- Regular
- Posts: 45
- Joined: Sun May 11, 2008 12:24 am
- Location: Somwhere dark so I can relax
- Contact:
A new screen question
Scrolled through the renpy cookboks and tutorials, and wondering how to create an in-game ui button which when it is clicked,it brings up a new label (I plan to make it the label for viewing explanations, so that the players can look at it anytime when they forget something. My game has many japanese terms.) Can you help?
A life is a life, there's no need to rush anything.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
-
- Veteran
- Posts: 249
- Joined: Sat May 01, 2010 6:11 pm
- Projects: School's Out! -- A GxB or GxG VN/Dating Sim
- Location: The Netherlands, Noord-Brabant
- Contact:
Re: A new screen question
Try editing this to your liking (it's what I'm using for a 'stats' button):
"explanations" would be the name of the label in this case
I'm not 100% sure this is the best way to do it, but it works =D
Xx
Code: Select all
ui.hbox(xpos=369, ypos=561, xanchor='left', yanchor='top')
ui.imagebutton("idle.png", "hover.png", clicked=ccinc("explanations"), xminimum=62, yminimum=36)
ui.close()
I'm not 100% sure this is the best way to do it, but it works =D
Xx
-
- Regular
- Posts: 45
- Joined: Sun May 11, 2008 12:24 am
- Location: Somwhere dark so I can relax
- Contact:
Re: A new screen question
Code: Select all
I'm sorry, but an exception occured while executing your Ren'Py
script.
NameError: name 'ccinc' is not defined
While running game code:
- script at line 876 of D:\renpy-6.10.2\Hikaru_Wish/game/script.rpy
- python at line 876 of D:\renpy-6.10.2\Hikaru_Wish/game/script.rpy.
A life is a life, there's no need to rush anything.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
-
- Veteran
- Posts: 249
- Joined: Sat May 01, 2010 6:11 pm
- Projects: School's Out! -- A GxB or GxG VN/Dating Sim
- Location: The Netherlands, Noord-Brabant
- Contact:
Re: A new screen question
Oh, oops Sorry 'bout that.
I'm using the on screen buttons cookbook thing which defines ccinc ^^" http://www.renpy.org/wiki/renpy/doc/coo ... _Game_Menu
You actually might want to take a look at that
Anyway, replace it with this:
and it should work.
I'm using the on screen buttons cookbook thing which defines ccinc ^^" http://www.renpy.org/wiki/renpy/doc/coo ... _Game_Menu
You actually might want to take a look at that
Anyway, replace it with this:
Code: Select all
renpy.curried_call_in_new_context("explanations")
-
- Regular
- Posts: 45
- Joined: Sun May 11, 2008 12:24 am
- Location: Somwhere dark so I can relax
- Contact:
Re: A new screen question
So, in the script at the point when I want to button to appear...
But it dissapeared at the next dialouge, when himiko talks again. How do I make it appear until some point in the game?
Code: Select all
himiko "You can check the dictionary every time."
$ ui.hbox(xpos=369, ypos=561, xanchor='left', yanchor='top')
$ ui.imagebutton("idle.png", "hover.png", clicked = renpy.curried_call_in_new_context("explanations"), xminimum=62, yminimum=36)
$ ui.close()
himiko "Good." ## ui.umagebutton dissapears? Why?
##some more scripts
himiko "Now I want to borrow the dictionary"
## The ui.image button dissapears here
But it dissapeared at the next dialouge, when himiko talks again. How do I make it appear until some point in the game?
Last edited by Karasu_Noir on Fri May 28, 2010 10:35 pm, edited 1 time in total.
A life is a life, there's no need to rush anything.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
-
- Veteran
- Posts: 249
- Joined: Sat May 01, 2010 6:11 pm
- Projects: School's Out! -- A GxB or GxG VN/Dating Sim
- Location: The Netherlands, Noord-Brabant
- Contact:
Re: A new screen question
Aha. Well, that's because it's supposed to go in an init python block ^^" Which goes before your start label.
And if you want it to appear at a certain time, use a variable for that.
So, basically, the game starts of with the button turned off. To turn it on, set show_button_game_menu to True To turn it off again, set it to False.
Sorry for taking so long in helping out.. I'm still new to the whole 'helping people out' thing ^^"
Anyway, this should work =D (tested it in an empty template, just to be sure XD)
And if you want it to appear at a certain time, use a variable for that.
Code: Select all
init python:
show_button_game_menu = False
def button_game_menu():
if show_button_game_menu:
ui.hbox(xpos=281, ypos=575, xanchor='left', yanchor='top')
ui.imagebutton("idle.png", "hover.png", clicked=renpy.curried_call_in_new_context("explanations"), xminimum=37, yminimum=22)
ui.close()
config.overlay_functions.append(button_game_menu)
label start:
"No button"
$ show_button_game_menu = True
"Yay, a button!"
"Extra text :)"
$ show_button_game_menu = False
"Bye, button :("
Sorry for taking so long in helping out.. I'm still new to the whole 'helping people out' thing ^^"
Anyway, this should work =D (tested it in an empty template, just to be sure XD)
-
- Regular
- Posts: 45
- Joined: Sun May 11, 2008 12:24 am
- Location: Somwhere dark so I can relax
- Contact:
Re: A new screen question
Code: Select all
$ show_button_game_menu = False
def button_game_menu():
if show_button_game_menu:
ui.hbox(xpos=281, ypos=575, xanchor='left', yanchor='top')
ui.textbutton("Dictionary", clicked=renpy.curried_call_in_new_context("explanations"), xminimum=37, yminimum=22)
ui.close()
$ config.overlay_functions.append(button_game_menu)
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
On line 28 of D:\renpy-6.10.2\Hikaru_Wish/game/script.rpy: expected statement.
def button_game_menu():
^
A life is a life, there's no need to rush anything.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
-
- Veteran
- Posts: 249
- Joined: Sat May 01, 2010 6:11 pm
- Projects: School's Out! -- A GxB or GxG VN/Dating Sim
- Location: The Netherlands, Noord-Brabant
- Contact:
Re: A new screen question
That's because you added two '$'
Just copy past everything from above the start label and it should work.
Just copy past everything from above the start label and it should work.
-
- Regular
- Posts: 45
- Joined: Sun May 11, 2008 12:24 am
- Location: Somwhere dark so I can relax
- Contact:
Re: A new screen question
Hmm...
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
On line 26 of D:\renpy-6.10.2\Hikaru_Wish/game/script.rpy: expected statement.
show_button_game_menu = False
^
On line 28 of D:\renpy-6.10.2\Hikaru_Wish/game/script.rpy: expected statement.
def button_game_menu():
^
On line 36 of D:\renpy-6.10.2\Hikaru_Wish/game/script.rpy: expected statement.
config.overlay_functions.append(button_game_menu)
^
A life is a life, there's no need to rush anything.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
-
- Veteran
- Posts: 249
- Joined: Sat May 01, 2010 6:11 pm
- Projects: School's Out! -- A GxB or GxG VN/Dating Sim
- Location: The Netherlands, Noord-Brabant
- Contact:
Re: A new screen question
Alright, I'm lost :S
I copy pasted everything in an empty renpy files and it works fine for me...
Expected statement is usually something with identation or when there's a colon missing or something. Make sure all your identations are correct and check if you didn't accidentaly deleted a colon or something.
I copy pasted everything in an empty renpy files and it works fine for me...
Expected statement is usually something with identation or when there's a colon missing or something. Make sure all your identations are correct and check if you didn't accidentaly deleted a colon or something.
-
- Regular
- Posts: 45
- Joined: Sun May 11, 2008 12:24 am
- Location: Somwhere dark so I can relax
- Contact:
Re: A new screen question
I think because I have init: so I put the code right below init:
I put init phyton: and init: in a separate place and it worked.
Thank you.
Another question, so I made a new label, how do I make it return to the scene where I clicked it before?
I put init phyton: and init: in a separate place and it worked.
Thank you.
Another question, so I made a new label, how do I make it return to the scene where I clicked it before?
Code: Select all
label explanation:
scene bg dict
## Long, long explanation
##Want to put a button to return to the previous scene
A life is a life, there's no need to rush anything.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
Just sit back and relax.
But don't take too long.
.............Or darkness will eat you.
- azureXtwilight
- Megane Procrastinator
- Posts: 4118
- Joined: Fri Mar 28, 2008 4:54 am
- Completed: Fantasia series (ROT and ROTA), Doppleganger: Dawn of The Inverted Soul, a2 (a due), Time Labyrinth
- Projects: At Regime's End
- Organization: Memento-Mori VNs, Team Sleepyhead
- Location: Yogyakarta, Indonesia.
- Contact:
Re: A new screen question
I think you don't need to do that, because the scene returns when you click at the explanation label after the long explanation is done. Maybe it is you who did something wrong.Karasu_Noir wrote:I think because I have init: so I put the code right below init:
I put init phyton: and init: in a separate place and it worked.
Thank you.
Another question, so I made a new label, how do I make it return to the scene where I clicked it before?
Code: Select all
label explanation: scene bg dict ## Long, long explanation ##Want to put a button to return to the previous scene
Re: A new screen question
When you "call" some label "in new context", you need to "return" to game context.
If you need a button, it could be like
Code: Select all
label explanation:
scene bg dict
## Long, long explanation
return
Code: Select all
label explanation:
scene bg dict
## Long, long explanation
$ ui.textbutton ("Return", clicked=ui.returns("True") #place the button on the screen (add xpos, ypos, xalign etc. to change its position; this button actualy do nothing - its just clickable
$ ui. interact() # game will wait until button clicked
# when button clicked, we can go farther
return
- azureXtwilight
- Megane Procrastinator
- Posts: 4118
- Joined: Fri Mar 28, 2008 4:54 am
- Completed: Fantasia series (ROT and ROTA), Doppleganger: Dawn of The Inverted Soul, a2 (a due), Time Labyrinth
- Projects: At Regime's End
- Organization: Memento-Mori VNs, Team Sleepyhead
- Location: Yogyakarta, Indonesia.
- Contact:
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot]