Persistent UI Element

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
BrandonDeVITO
Newbie
Posts: 6
Joined: Wed Jan 23, 2013 12:09 pm
Completed: N/A
Projects: JUMPr (A Universe Jumping Android RPG)
Organization: 5|N Interactive
Contact:

Persistent UI Element

#1 Post by BrandonDeVITO » Wed Jan 23, 2013 5:11 pm

I finally thought to create:

Code: Select all

python:

        if KARMA == 0:
            ui.imagebutton("images/0.png", "images/0.png", clicked=ui.jumps("jumpr_menu"),xalign=0.0, yalign=0.0)
...for my basic UI.

Basically, I need a bar that does the following:

•Changes to 1 of eleven images (Based on Karma being "Off",1,2,3,4,5,6,7,8,9,10)
•Links to the jumpr_menu label
•Is always present on the screen.

Right now, this event disappears after the text begins. Is there a way to tell this event to ALWAYS BE ON? ☺

Any assistance would be greatly appreciated.

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

Re: Persistent UI Element

#2 Post by astrobread » Thu Jan 24, 2013 9:00 am

Just to make sure I understand, while the player is progressing through the story you want a button available at all times that looks different depending on the player's accumulated karma?

If I'm following, I'd suggest putting the code you listed inside a screen, call it karmabutton. This screen should exist at the top level, do not place it inside the start label. Next, inside the actual start label write "show screen karmabutton".

This will show the screen that draws your ImageButton, and it will overlay on top of the main story area based on the coordinates you give it. Now the next problem is getting it to change as the player's karma increases.

Screens only update themselves when an event happens; fortunately the player simply progressing the story will cause the screen to refresh for you. So the instant you boost the KARMA stat won't cause the button to change, however I'm guessing the next line of dialogue will just pop up and refresh it for you anyways. If you need greater control of the refresh I can think of an idea or two though.

User avatar
BrandonDeVITO
Newbie
Posts: 6
Joined: Wed Jan 23, 2013 12:09 pm
Completed: N/A
Projects: JUMPr (A Universe Jumping Android RPG)
Organization: 5|N Interactive
Contact:

Re: Persistent UI Element

#3 Post by BrandonDeVITO » Thu Jan 24, 2013 11:24 am

Astro,

It sounds to me as if you've correctly analyzed my issue. And your advice sounds like it's where I'm headed. I'm going to learn to make a screen now, as it's something I've never done before in this engine.

{EDIT}

I created a screen... It's idiot proof. And that completed the last piece of the puzzle. I now have the following spaced throughout the scritpt:

•A Screen with the Autoupdating Karma % bar. (There are ten images, and each time I grant 'KARMA' to the user, I have an event that says

Code: Select all

if KARMA >= 10:
    $ KARMA = 10
...becuase it's a choice screen that grants the Karma, it updates as soon as the event ends.
•Clicking the Karma bar brings you to a called menu which contains an imagemap for navigation. You can't 'Jump' to another event unless you have the Karma to do so.
•Using the imagemap resets the Karma to '0', consuming the charge. If you don't have enough to use it, you get an error message, and a return command.
•The Image Map is connected to an event with a set of variables combining to make the name of an even label. So when the EVENT and GIRL variables are placed side by side, it creates the name of the event that's being transitioned to. Meaning, the event CHANGES where it sends you automatically, based on your story progression.

The only real challenge I face is that every event has a 12 line header. When I begin a new section, I copy from a template, and enter in the data to keep my variables honest. If I mess this part up, it will be a debugging nightmare. But ten years in game QA has made me a patient man.

That took some doing, but now that the UI is in place I can continue on the road to creating a game worth playing.

The trick of keeping the player involved in the narrative, and not just playing took me weeks to come up with. Thanks to the support here on the forums, I am able to move forward. Thank you very much.
Last edited by BrandonDeVITO on Thu Jan 24, 2013 11:49 am, edited 1 time in total.

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

Re: Persistent UI Element

#4 Post by astrobread » Thu Jan 24, 2013 11:47 am

Here's one I'm using at the moment:

Code: Select all

screen flowbutton:
    vbox xalign 0.99 yalign 0.3:
        textbutton "Flow" action ui.callsinnewcontext("flow_screen_label")
You'd just replace the textbutton with your tree of "if" statements and various imagebuttons. Could probably ditch the vbox for a frame or something, I just have it in place for positioning and in case I want to add more buttons later.

Depending on what you plan for the karma button, you may or may not want to use ui.callsinnewcontext. I'm using it because I'm calling up a full screen menu inside that label, and I want to be able to easily return to where the story last left off at. If you're trying to jump to a different story point instead, then something like ui.jumps might be better

Post Reply

Who is online

Users browsing this forum: Bing [Bot]