I need help for a "life indicator"
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.
I need help for a "life indicator"
Hi everyone!
I discovered renpy about a month ago and i am currently developing a dating sim game with it and i have some problems i hope you can help me to resolve.
In the "demo" game included there is something about "life indicators" (those used for battles), can i have them all the game on?
I mean, i want each character to have a "Love indicator" and each time you answer or do something the character likes the indicator level goes up till the end of the game. Could this be possible?
....any suggestion?
I discovered renpy about a month ago and i am currently developing a dating sim game with it and i have some problems i hope you can help me to resolve.
In the "demo" game included there is something about "life indicators" (those used for battles), can i have them all the game on?
I mean, i want each character to have a "Love indicator" and each time you answer or do something the character likes the indicator level goes up till the end of the game. Could this be possible?
....any suggestion?
-The moment i wake up, before i put on my makeup i say a little prayer for you.-
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
This isn't quite the same, but you could probably play with it to get what you want. For instance, instead of ui.vbox() ... ui.close() you might use:
Code: Select all
ui.bar(range=max_love_points,value=my_love_points,
xpos=0.5,ypos=0.02,xanchor=0.5,yanchor=0.0)
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
I assume you mean display the indicator throughout the game, right?neohin wrote:In the "demo" game included there is something about "life indicators" (those used for battles), can i have them all the game on?
If you want to display an indicator with the text onscreen, you need to add a function to this list that creates the bar.PyTom wrote:Overlays are used to display information above the scene currently displayed. The overlay is regenerated each time an interaction with the user begins, making it suitable for displaying to the user things like statistics or dates.
[...]
Overlays are set up by adding to the config.overlay_functions list [...]. These functions are called for each interaction, which allows the overlay to change to reflect the status of game variables.
Code: Select all
# First, set up the variables and functions...
init python:
$ max_love_points = 50 # total available points
$ my_love_points = 0 # current points
def love_indicator():
ui.bar(range=max_love_points,value=my_love_points,
xpos=0.5,ypos=0.02,xanchor=0.5,yanchor=0.0)
config.overlay_functions.append(love_indicator)
# ... then change the points value as the game progresses.
menu:
"Where should we go?"
"To a movie":
"... That was a bust. How could I know she loved horror flicks?"
"{i}I{/i} ended up clinging onto {i}her{/i} in fear."
$ my_love_points += 2 # Well, not bad.
"To the park":
"... We decided to take a walk in the park."
"Halfway around the lake, she unexpectedly took hold of my hand."
$ my_love_points += 5 # Wow! Good going!
um...i have a problem (again)
When i try to run the game the script tells me it's expecting for a statement:
--------------
On line 11 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
def love_indicator():
^
On line 14 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
config.overlay_functions.append(love_indicator)
------------------
And then it tells me it's not waiting for an empty block:
------------
On line 143 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: choice menuitem expects a non-empty block.
"So...what's your name?":
^
--------------
I've tried to fix it but the same message keeps appearing...sorry..i'm not too brilliant at this.
When i try to run the game the script tells me it's expecting for a statement:
--------------
On line 11 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
def love_indicator():
^
On line 14 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
config.overlay_functions.append(love_indicator)
------------------
And then it tells me it's not waiting for an empty block:
------------
On line 143 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: choice menuitem expects a non-empty block.
"So...what's your name?":
^
--------------
I've tried to fix it but the same message keeps appearing...sorry..i'm not too brilliant at this.
-The moment i wake up, before i put on my makeup i say a little prayer for you.-
Re: I need help for a "life indicator"
omg!!!
*slaps herself*
It's true, the $ symbols!!!
How can i be so stupid?
thanks a lot!
*slaps herself*
It's true, the $ symbols!!!
How can i be so stupid?
thanks a lot!
Re: I need help for a "life indicator"
Okay then, i've removed the $ symbols...
but still i think your code is wrong, at least coz the script tells me there's an error here:
--------------
$ def love_indicator():
ui.bar(range=max_love_points,value=Tails_love_points,
xpos=0.5,ypos=0.02,xanchor=0.5,yanchor=0.0)
config.overlay_functions.append(love_indicator)
-------------------
In the first and last lines to be perfectly honest.
-----------------------------------------
On line 393 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
ui.bar(range=max_love_points,value=Tails_love_points,
xpos=0.5,ypos=0.02,xanchor=0.5,yanchor=0.0)
^
On line 395 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
config.overlay_functions.append(love_indicator)
^
but still i think your code is wrong, at least coz the script tells me there's an error here:
--------------
$ def love_indicator():
ui.bar(range=max_love_points,value=Tails_love_points,
xpos=0.5,ypos=0.02,xanchor=0.5,yanchor=0.0)
config.overlay_functions.append(love_indicator)
-------------------
In the first and last lines to be perfectly honest.
-----------------------------------------
On line 393 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
ui.bar(range=max_love_points,value=Tails_love_points,
xpos=0.5,ypos=0.02,xanchor=0.5,yanchor=0.0)
^
On line 395 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
config.overlay_functions.append(love_indicator)
^
Re: I need help for a "life indicator"
In the given example, there are two parts : the init block (ending with "config.overlay_functions.append(love_indicator)") and then a menu part which should be in a label block :
Maybe that's why it fails?
Code: Select all
label somemenu:
menu:
"Where should we go?"
"To a movie":
# etc, etc...
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
Re: I need help for a "life indicator"
All right, I looked up some more details about the ui.bar function. It seems instead of using "range=<range>,value=<value>" you just need to have "<range>,<value>". I got a different error message, however: "ValueError: unpack tuple of wrong size." So this may not be what caused your error.Guest wrote:Okay then, i've removed the $ symbols...
but still i think your code is wrong, at least coz the script tells me there's an error here:
--------------
$ def love_indicator():
ui.bar(range=max_love_points,value=Tails_love_points,
xpos=0.5,ypos=0.02,xanchor=0.5,yanchor=0.0)
config.overlay_functions.append(love_indicator)
-------------------
Also, remember to take out the $s and put it in a python block. I'm not sure but I don't think python defs work in straight Ren'Py code.
As for the "empty block" error, make sure there's something under the menu choice to be executed, and that it's properly indented as a block. If you don't want anything there just yet (or at all) put a pass statement, just so there's something.
That's exactly right. The init block just sets up the variables and functions you need. The menu is just an example of how to change the values while your script is running, specifically the $ my_love_points += 2 part. You can also use $my_love_points -= 2 to deduct from the player's points.monele wrote:In the given example, there are two parts : the init block (ending with "config.overlay_functions.append(love_indicator)") and then a menu part which should be in a label block
P.S. For more control over positioning the bar on the screen, read up in the manual about Widgets. You may also want to move the config.overlay_functions.append(love_indicator) statement out of the init block and into your script at the point you want it to show up: I found that when it's in the init block, it shows up for a moment right before the main menu-- oops!
- PyTom
- Ren'Py Creator
- Posts: 16093
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: I need help for a "life indicator"
No, you don't want to update config.overlay_functions (or any config variable, for that matter) once the game has started running. This is because the values of the config variables are not save, and so may be wrong when the game starts running.
Instead, you want to conditionally show the love bar.
Instead, you want to conditionally show the love bar.
Code: Select all
init python:
def show_love_bar():
if love_points is None:
return
ui.bar(100, love_points, xmaximum=200, xalign=.99, yalign=.1)
config.overlay_functions.append(show_love_bar)
love_points = None
labels start:
$ love_points = 0
"No love points."
$ love_points = 50
"50 love points."
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: I need help for a "life indicator"
I used the code you gave me (Tom)
but...
On line 2 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
def show_love_bar():
^
On line 4 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
config.overlay_functions.append(show_love_bar)
but...
On line 2 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
def show_love_bar():
^
On line 4 of C:\Documents and Settings\Carla\Mis documentos\renpy-6.2.0-full\renpy-6.2.0\Dream Dating STH version/game/script.rpy: expected statement.
config.overlay_functions.append(show_love_bar)
- PyTom
- Ren'Py Creator
- Posts: 16093
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: I need help for a "life indicator"
Can you copy in the code? I suspect you're using "init" instead of the fairly new "init python", but it helps to know exactly what you're doing.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Regular
- Posts: 42
- Joined: Fri Jun 15, 2007 9:45 am
- Location: Philly, USA
- Contact:
Re: I need help for a "life indicator"
...Now, how would you go about displaying that "love indicator" during a date scene, but hiding it at all other times?
"HOLD ON TIGHT" ~ Outfits and expressions, where art thou? And why does Elsa's face look so awful??? *bangs head in*
Everytime you delete a traceback, someone else gets it. -PyTom
Everytime you delete a traceback, someone else gets it. -PyTom
Who is online
Users browsing this forum: Google [Bot]