Menu and button help for a beginner? (Party/mission select)

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
DaKriKi
Newbie
Posts: 3
Joined: Wed Nov 02, 2016 9:52 pm
Contact:

Menu and button help for a beginner? (Party/mission select)

#1 Post by DaKriKi » Wed Nov 02, 2016 11:59 pm

Hi, so I'm not completely inexperienced with coding, but between a few factors (namely having not touched python in an age) I'm running into a wall.

Currently in the middle of trying(and failing) basic menu building for a game and I'm beating my head trying to understand calling screens, utilizing buttons etc. I'm trying to go through the wiki and get some lernin' done as the documentation is leaving me confused. I tried looking through the cookbooks and whenever I found promising bits, such as the image button tutorial, it was either not working out for me or it had a caution about being dated.

I just need some good advice on how to start the suckers and then using them to pass appropriate variables.


For staffing, the idea is this:
Four Slot Choice Grid. Player clicks portrait areas over each ‘background’. This activates the right side panel, which has the list of characters. Clicking the character’s portrait chooses them, and places their portrait in the original frame. Resetting is done by clicking the portrait again and selecting someone else. The player cannot progress until all four slots are full. (I was also fiddling with the idea of drag & drop) From there it would set various flags based on mission number, who was selected, etc.

For mission select, we're aiming at just having two boxes with image and then mouseover shows data on the right side panel.

I'm totally lost on how to actually utilize and call screens and going through the Tutorial code for the dayplanner, the ui class is used but is depreciated.

The idea is they'll be called say around 10 times through the game, but with big conditional shifts.
The other thing I'm not cure how it works is the Tutorial uses separate script files that it jumps to based on buttons, and based on where we're planning to go for structure that seems better than one fat script file.

I'm not interested in making anything have flashy bits or anything yet, I just want to have a path forward on making these suckers function, and then scan for conditionals and set some flags.

i really want to utilize renpy as half my favorite VNs were put together with this and now for someone that's done a decent bit of coding and has been building simple stuff in gamemaker for a few weeks (but not the things I aim to make), I am getting frustrated at my inability to understand simple menu-making... :oops:

User avatar
Kia
Miko-Class Veteran
Posts: 912
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Skype: KiaAzad
Contact:

Re: Menu and button help for a beginner? (Party/mission sele

#2 Post by Kia » Thu Nov 03, 2016 5:48 am

it took me lots of time to write and debug something similar and I guess you'll need to spend even more on it, so forget about searching for a shortcut.
first thing first, you need to learn everything about screens https://www.renpy.org/doc/html/screens.html specially buttons.
then you need to list your characters in lists, if your characters have stats you need to include that information as well. then all you need is few "for" loops and "if" statements to bring them to the screen and probably some python functions to calculate the stats.
if it's your first project, I suggest to tackle something easier first, like customizing your GUI.

philat
Eileen-Class Veteran
Posts: 1751
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Menu and button help for a beginner? (Party/mission sele

#3 Post by philat » Thu Nov 03, 2016 6:29 am

Since I'm bored at work, this is a simple two member selection screen. It's limited to the character selecting part of your post, because I'm lazy. It's also not meant to be a finished product, just a pointer for where you will eventually want to be going. However, I do think (or hope) that the code should be enough of a hint for you to figure out most of the other stuff you want to do. Do keep in mind that you will need to account for things like save/load, rollback, incorporating images, blah blah.

I just reread your post and you also want SensitiveIf for the done button in select1, but I'm too lazy to add it now. As Kia suggested above, you can also use for loops to avoid some tedious hard coding, but I didn't bother since I'm just providing two slots and characters. I'm not touching any of the stat stuff either.

As for your files, renpy treats all files as one big file. It makes no difference whether you have one script.rpy file with a bunch of labels or labels broken off into their own files.

Code: Select all

screen select1():
    vbox:
        xalign 0.1
        yalign 0.1
        textbutton party[0].name action Show("select2", slot=0)
        textbutton party[1].name action Show("select2", slot=1)
        textbutton "Done" action Return()

screen select2(slot=1):
    vbox:
        xalign 0.9
        yalign 0.1
        textbutton "Char 1" action [Function(setlistindex, party, slot, char1), Hide("select2")]
        textbutton "Char 2" action [Function(setlistindex, party, slot, char2), Hide("select2")]
        textbutton "None" action [Function(setlistindex, party, slot, charnone), Hide("select2")]

init -2 python:
    class Char():
        def __init__(self, name):
            self.name = name
    charnone = Char("None")

    def setlistindex(lst, index, char):
        lst[index] = char

default party = [charnone, charnone]

label start:

    python:
        char1 = Char("Char1")
        char2 = Char("Char2")

    call screen select1

    $ printparty = [x.name for x in party]

    "Party: [printparty]"

    if char1 in party:
        "Char1 is in your party."
    else:
        "Char1 is not in your party."

DaKriKi
Newbie
Posts: 3
Joined: Wed Nov 02, 2016 9:52 pm
Contact:

Re: Menu and button help for a beginner? (Party/mission sele

#4 Post by DaKriKi » Thu Nov 03, 2016 4:31 pm

@Philat

See, that looks more like python code, more like what my brain thinks of regarding creating objects and instances.
I'm more mystified as far as how screens work and the like and utilizing the built-in methods because I'm having trouble finding examples.

There's no stats, the idea is you're the boss, and you just pick who is on the job for the particular scenario.
What I'm more lost on is how calling a screen works, and scanning buttons and the rest for states

User avatar
Ocelot
Miko-Class Veteran
Posts: 849
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Menu and button help for a beginner? (Party/mission sele

#5 Post by Ocelot » Thu Nov 03, 2016 5:09 pm

Screen language is a kind of markup language in RenPy. Like HTML, it describes how things are looking, what will happen if you hover on things, click them, etc..

Calling a screen is like calling a function, it means to show the screen and stop executing code until screen will return something (via Return action or some inherent property of some displayables, like input area reaction on Enter key).
< < insert Rick Cook quote here > >

philat
Eileen-Class Veteran
Posts: 1751
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Menu and button help for a beginner? (Party/mission sele

#6 Post by philat » Thu Nov 03, 2016 7:17 pm

The class objects are barebones examples to show how you refer to an object in a list and is attributes in screen elements (textbutton party[0].name). The point of the example code is the screens, which show basic examples of showing and hiding screens, passing a variable between screens, and using a custom function as a screen action. Beyond that, you're gonna have to just look through the documentation.

The imagebutton tutorial should work fine as far as I know.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1885
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question
Projects: Slumberland
Location: Brazil
Contact:

Re: Menu and button help for a beginner? (Party/mission sele

#7 Post by Donmai » Sun Nov 13, 2016 7:13 am

philat wrote:The imagebutton tutorial should work fine as far as I know.
I've seen people reporting problems trying to use the Imagebutton Framework with latest Ren'Py. viewtopic.php?p=433180#p433180
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

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

Re: Menu and button help for a beginner? (Party/mission sele

#8 Post by trooper6 » Sun Nov 13, 2016 10:53 am

If you want examples of what screens look like, make a new project and look at the code for your screens and GUI ren'py files.
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

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Jacksono