the quietest shrieking over a simple stats menu [solved]

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.
Post Reply
Message
Author
queergames
Newbie
Posts: 12
Joined: Mon Oct 28, 2013 11:37 pm
Contact:

the quietest shrieking over a simple stats menu [solved]

#1 Post by queergames »

so here's the deal: i'm making a game which has a small stats menu on the top right. seems easy, yes? apparently not. i don't even want to show you guys the code because i KNOW that it's a mess. i've never used screens before and it really shows. i've already tried nabbing someone else's python code, and you can imagine how that's going for me.

what i need the stats to do is the following:
display the level (which changes based on exp. so if your exp is less than 21, you're level 1. between 21 and 50, you're level 2, etc. but it needs to display the LEVEL and no the EXP)
display a bar (which ive figured out) which has a max of 100. if the value reaches 100, the game ends.
display money. which should be simple, but i've been so stuck on the level thing i could scream.

code is below if you really must see it, but like i said... it's essentially useless.

thanks in advance for your patience with me.

SOLUTION:

Code: Select all

init python:
    def add_dys(d):
        store.dys += d
        if store.dys > 100:
            renpy.jump("game_over") #this code makes it such that if the "dys" value goes over 100, the game ends and jumps to the scene labeled game over

# The game starts here.
label start:

    $ exp = 0
    $ dys = 0
    $ money = 10

    show screen stat_menu

screen stat_menu:
    frame:
        align (1.0, 0.0)    #this aligns the stat box to the top right     
        xmaximum 200 #this sets the maximum width of the box
        background "#393939" #this sets the background colour an image can also be used
        has vbox
        if exp <= 20:
            text "Level 1"
        if exp >= 21 and exp <= 50:
            text "Level 2"
        if exp > 51:
            text "Level 3"
        bar value dys range 100 #this creates the dysphoria bar
        text "Money: [money]"

"Blah blah blah."

"Hey there!  Before we get started, why not tell us your name?"
    
$ povn = renpy.input(_("Type your name and press return/enter.")) or _("Player")
    
"oh my god."
    
$ add_dys(10)
    
"In theory, dysphoria should go up."
    
$ exp += 21
    
"Level should increase to 2."

return

label game_over:
    
    "Adrien\'s dysphoria got too high.  Game over!"

return
Last edited by queergames on Sat Feb 14, 2015 7:37 pm, edited 1 time in total.

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: the quietest shrieking over a simple stats menu

#2 Post by SundownKid »

You should check out Screen Language, this is outdated code. Current documentation is here: http://www.renpy.org/doc/html/screens.html

It should be something more like:

Code: Select all

label start:
     $ exp = 0
     $ dys = 0
     $ money = 0
     n "Blah blah blah"
     show screen stat_menu

screen stat_menu:
    vbox:
        xalign 1.0
        yalign 0.0
        xysize (300,300)
        if exp < 21:
            text "Level 1"
        if exp > 21 and exp < 50:
            text "Level 2"
        if exp > 50:
            text "Level 3"
        bar value "dys" range 100
        text "Money: [money]"
I'm not sure if it will totally work but it should be something like that.

queergames
Newbie
Posts: 12
Joined: Mon Oct 28, 2013 11:37 pm
Contact:

Re: the quietest shrieking over a simple stats menu

#3 Post by queergames »

Thanks. That worked, I think. Now I just need to make it have a background and limit the size. xysize produced an invalid syntax error.

Ugh. I am so not a coder.

edit: also it seems like dysphoria is stuck at 100? i think i can fix that myself, but the size and the clear background are still problems. i've tried reading the linked page, but i can't process any of it because it's not really that clear.

edit 2: hm. the level display is also not working. it works for level 1 but disappears after that.
Attachments
Screen Shot 2015-02-13 at 10.04.57 PM.png

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: the quietest shrieking over a simple stats menu

#4 Post by xavimat »

The "if" statements are missing the numbers 21 and 50:

Code: Select all

if exp < 21:   # what if exp == 21???
            text "Level 1"
if exp > 21 and exp < 50:  # what if exp == 21 or == 50 ???
            text "Level 2"
if exp > 50:
            text "Level 3"  # what if exp == 50???
I suggest:

Code: Select all

if exp < 21:
            text "Level 1"
elif exp < 51:
            text "Level 2"
else:
            text "Level 3"
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

queergames
Newbie
Posts: 12
Joined: Mon Oct 28, 2013 11:37 pm
Contact:

Re: the quietest shrieking over a simple stats menu

#5 Post by queergames »

xavimat wrote:The "if" statements are missing the numbers 21 and 50:

Code: Select all

if exp < 21:   # what if exp == 21???
            text "Level 1"
if exp > 21 and exp < 50:  # what if exp == 21 or == 50 ???
            text "Level 2"
if exp > 50:
            text "Level 3"  # what if exp == 50???
I suggest:

Code: Select all

if exp < 21:
            text "Level 1"
elif exp < 51:
            text "Level 2"
else:
            text "Level 3"
I've figured out the levels by simply using <= (something I've done for another project) but the screen still has no background and is stretched across the entire game. Is there some properties I'm missing or don't understand which control these things?

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: the quietest shrieking over a simple stats menu

#6 Post by trooper6 »

Hi queergames,

In my game I have a panel that hangs out over on the right side of the screen. It has a background (which in my case is an image) and has very specific dimensions. I did this using style properties.

The screen looks like this:

Code: Select all

screen control():
    frame:
        style_group "game"
        xalign 1.0
        yalign 0.0
The screen then has some vboxes and some buttons, etc. (Not important for this example).

Then somewhere else I define the style. In this case I have defined it after the screen, but you could do it before I suppose:

Code: Select all

style game_frame is default:
    background Frame("00 images/00Intertitle2_64x71.png", 64, 71)
    xmargin 10
    ymargin 10
    xminimum 250
    yminimum 748
    xmaximum 250
    ymaximum 748
Hope that helps!

ETA: You don't have to give it a special style of course. You could just define it in your element directly. I do have a frame that I've specified its ymaximum like so:

Code: Select all

frame:
    ymaximum 160
    add myClock xanchor 0.5 yanchor 0.5
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: the quietest shrieking over a simple stats menu

#7 Post by xavimat »

Sundowkid's solution using frame, as trooper6 suggests:

Code: Select all

screen stat_menu:
    frame:
        align (1.0, 0.0)        
        xysize (300,300)
        background "bg_stat.png"
        has vbox
        if exp <= 20:
            text "Level 1"
        if exp > 20 and exp <= 50:
            text "Level 2"
        if exp > 51:
            text "Level 3"
        bar value "dys" range 100
        text "Money: [money]"
Some explanation:
- Using frame because has the background property to add an image (and vbox hasn't it).
- align (#, #) is the same that adjusting separately xalign and yalign
- xysize doesn't throw an error if correctly indented and with the parenthesis. I'd suggest here the same size as the background image. Actually, xysize is the same that setting separately xmaximum, xminimum, ymaximum, yminimum.
- has vbox adds a vbox inside the frame, to set the following elements vertically.

EDIT:
if the value reaches 100, the game ends
This has nothing to do with the screen stat_menu, used only to display the info, not to check it. You need a separate way (maybe a function) to checkt. My suggestion (not tested):

Code: Select all

init python:
    def add_dys(d):
        store.dys += d
        if store.dys > 100:
            renpy.jump("game_over")

label start:
    $ dys = 0
    # in your game don't use:
    # dys += 20
    # because it won't be checked.
    # Instead, dys is increased using:
    $ add_dys(120)
    
    # ...      
    
label game_over:
    "END"
    $renpy.full_restart()
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

queergames
Newbie
Posts: 12
Joined: Mon Oct 28, 2013 11:37 pm
Contact:

Re: the quietest shrieking over a simple stats menu

#8 Post by queergames »

Perfect! I figured it all out and it's working perfectly. Thanks so much to everyone.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]