On screen button to call inventory FIXED AGAIN!

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
User avatar
seldompie
Newbie
Posts: 13
Joined: Sat Nov 03, 2012 4:11 pm
Contact:

On screen button to call inventory FIXED AGAIN!

#1 Post by seldompie » Fri Jan 25, 2013 9:08 pm

Hi,

I've been having a pretty good run of getting Renpy to do all I need of it, but I've got to the point where I need to get into more complex stuff, and it's baffling the heck out of me, even though I'm sure it's something simple.

What I'd like is a permanent on screen button that, when pressed, clears the screen and displays some text that tells the play what their current stats and inventory are. (Game uses both nvl and normal mode)

If someone could type up a script example, that'd be great - I've managed to work out most of the stuff so far just by fiddling with things and poking at the demo program, but the button coding is just making my head spin.

Thanks!
Last edited by seldompie on Sat Jan 26, 2013 6:33 pm, edited 4 times in total.

User avatar
astrobread
Newbie
Posts: 13
Joined: Mon Jan 21, 2013 4:01 am
Contact:

Re: Permanent on screen button to call inventory

#2 Post by astrobread » Fri Jan 25, 2013 11:21 pm

Well this is pretty much exactly what I've been doing for the last couple of days, and I have some sample code in this post here (link)

If you take the first two code blocks you have the means to
1) Show the inventory button
2) When the button is clicked, show a full screen overlay with stuff on it. It doesn't clear the main game window, but it does cover it up and prevent the user from progressing the story until they exit.

In the second code block at that page, you can get rid of the python MakeLine() block and the transform ttfadein. Those were just related to an odd issue I was struggling with.

Also to exit from that inventory screen and return to your story, something like this would work: textbutton "Return" action Return("1")

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: Permanent on screen button to call inventory

#3 Post by saguaro » Sat Jan 26, 2013 10:41 am

Here's a basic template in screen language, if you need something a little less complex.

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"
            text "Items Here"
            label "Stats"
            text "Stats here"
            textbutton "Close" action Hide("inventory")

label start:
    show screen overlay
You can learn more about screens here: http://www.renpy.org/doc/html/screens.html

User avatar
seldompie
Newbie
Posts: 13
Joined: Sat Nov 03, 2012 4:11 pm
Contact:

Re: Permanent on screen button to call inventory

#4 Post by seldompie » Sat Jan 26, 2013 5:04 pm

That works super-great, thanks a lot! It's actually snazzier than what I was trying to do - I was thinking of just having the button trigger a "call" to a nvl clear command and have the inventory on that screen with a return at the end. This is fancier looking though. And it seems having a "call" after "action" isn't allowed anyway.

But this is great, thanks!

User avatar
seldompie
Newbie
Posts: 13
Joined: Sat Nov 03, 2012 4:11 pm
Contact:

Re: On screen button to call inventory NOT FIXED AFTER ALL!

#5 Post by seldompie » Sat Jan 26, 2013 6:27 pm

Okay, the inventory on a screen looks great, but I was wanting the player to be able to select to use say, a health up item while on the inventory screen. My ideal code would be something like this -

Code: Select all

label inno:
 screen overlay:
    frame:
        xalign 0.0 yalign 1.0
        hbox:
            textbutton "Status" action call invento

##############

label invento:
 nvl clear
 " You have [monkey] monkeys and [gins] bottles of gin"
 menu:
  "Drink some gin" if gins>0:
      nvl clear
      " You drink a  bottle of gin. Tasty!"
      $gins = gins - 1
      $drunk = drunk + 1
      jump invento

  "Okay":
     return
  
.. And that'd take the player back to wherever they were. I can't use call after an action though, and while I figured out how to use a Jump, after viewing the inventory screen, it just dumps you back to the main menu. Is there any way to use a call here?


EDIT - haha, just realised a guy about 2 posts down has just solved the same problem :D I needed a ui.callsinnewcontext. Everything is sweet again.

Post Reply

Who is online

Users browsing this forum: No registered users