How to make a notepad for the Player with text input?

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
SpagootBoi
Regular
Posts: 25
Joined: Sun Mar 22, 2020 12:02 am
Completed: Infatuation (Visual Novel Adaptation), Kimbark Street
Projects: Canyonlands: American Folklore, True Two Heart (Restoration Project)
Tumblr: plant324
itch: plantmama
Contact:

How to make a notepad for the Player with text input?

#1 Post by SpagootBoi »

Salutations. I seek help with making it so an input that's always open to the player manages to somehow act like a notepad for the player to record important information they may encounter in the game. I used the following tutorial, viewtopic.php?f=51&t=38080, using the button tutorial provided. I've run into a fault with it, as for my purposes I need the lines to indent after reaching the end of the line.

How would I go about doing this? And additionally, how would I also add a feature where the player can scroll through previous text with enough indentations?

Thank you to any replies I get!
Image


User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How to make a notepad for the Player with text input?

#2 Post by Per K Grok »

SpagootBoi wrote: Sun Mar 14, 2021 8:59 pm Salutations. I seek help with making it so an input that's always open to the player manages to somehow act like a notepad for the player to record important information they may encounter in the game. I used the following tutorial, viewtopic.php?f=51&t=38080, using the button tutorial provided. I've run into a fault with it, as for my purposes I need the lines to indent after reaching the end of the line.

How would I go about doing this? And additionally, how would I also add a feature where the player can scroll through previous text with enough indentations?

Thank you to any replies I get!

Here you have some code that will give you a input frame to add lines of text to a notebook.
In the notebook each text will show up with a number and a button to delete that text. The text will show up in a viewport so there will be possibility to scroll if needed.

The core of the notebook is a list in which the text lines (strings) are stored as posts. You can add new posts at the end of the list and removing posts at a certain position with pop().

I'm not sure if this matches what you wanted, probably not the most elegant solution, but I hope it at least gives you something you can have as a start and tweak around till you get what it was you actually wanted.

Code: Select all


init python:
    def entpst():
        notelist.append(post)
        return

    def delpost(x):
        notelist.pop(x)
        return

default notelist=[]
default post=""

screen noteinput():
    frame:
        vbox:
            text "Write new entry:"
            input value VariableInputValue('post', returnable=False)
            textbutton "Save entry" action Function(entpst), SetVariable("post",""), Show("notebook")
            textbutton "Show notebook" action Show("notebook")


screen notebook():

    frame:
        ypos 200
        $ nomb=1
        vbox:

            text "Notes"
            textbutton "Close Notes" action Hide("notebook")
            side "c b r":
                area (10, 60, 600, 400)
                viewport id "vp":
                    vbox:
                        for x in notelist:
                            text str(nomb) + ". " + x
                            textbutton "Delete post" action Function(delpost, nomb-1)
                            $ nomb +=1

                bar value XScrollValue("vp")
                vbar value YScrollValue("vp")



label start:

    show screen noteinput




Post Reply

Who is online

Users browsing this forum: No registered users