Results 1 to 7 of 7
  1. #1
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235

    .txt Dialog/quest/book system v2

    Hello,

    This is a txt dialog/book/quest system, you load in a txt file, the first line will be the title, every other line acts like a page out of a book and we are then able to skip trough the pages/lines and load other txt files on the fly.

    # v2 changes--- it needed some cleaning.
    # - nothing runs in true pulse anymore
    # - added page numbers
    # - added a line break to new line option
    # - added auto. visibility toggle for the next/back buttons
    # - added manual visibility toggle for the page numbers
    # - no unlinked errors anymore


    example:
    preview.png
    info: The top bar is where we show the first line from the txt file
    below that. we showing 1 line out of a txt file that holds several line breaks.
    We have 4 lines in this txt file 1 title and 3 lines that act as pages, that's why we have 3/3 page numbers.


    "So simply said, the black buttons are npc's/books, they each open a txt file, and then we just skip trough the lines with next/back buttons. You need to extend this if you want more/other options"

    dialog_v2.zip


    Have fun with it,
    Cotaks
    Last edited by Cotaks; 05-Jan-18 at 12:14.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  2. #2
    Member BluePrintRandom's Avatar
    Join Date
    Jul 2008
    Location
    NoCal Usa
    Posts
    18,513
    Nice!

    I will have to try to remember to dig at this,

    could you provide more info?
    any imports?

    are you using bfont or bitmap font or uv font?
    Break it and remake it - Wrectified
    If you cut off a head, the hydra grows back two.
    "headless upbge"



  3. #3
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Originally Posted by BluePrintRandom View Post
    Nice!

    I will have to try to remember to dig at this,

    could you provide more info?
    any imports?

    are you using bfont or bitmap font or uv font?
    It's nothing fancy(made this back in 2013), someone needed an example,
    just reading out a txt or any file and use readlines() to get the data, then we use that to skip trough it. It imports textwrap to create readable text. The text itself are just 2 text objects one used for title and one for the details.

    I searched for the thread i used this in, /n new lines did not work inhere, i had build an other version but that one is lost due to hdd crash so you guys have to do with this and adjust it yourself if needed(use <br> in the text and use replace('<br>','\n') to create \n (new lines). (Don't know if you can still use textwrap with it, to long ago).

    So simply said, the black buttons are npc's/books, they each open a txt file, and then we just skip trough the lines with next/back buttons. You need to extend this if you want more/other options
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  4. #4
    Member JustinBarrett's Avatar
    Join Date
    Jul 2009
    Location
    Trier(near), Germany
    Posts
    2,292
    I fought a lot with using escape sequences in mine, in the end I just used additional text objects....it's not so elegant, but it works without a lot of code overhead.

    I also use string to int to read what is the next line to read based on selections in the sub text...
    so I have a text file for each npc that looks like the following...somewhat.

    this is text line 1
    line 2
    line 3
    line 4
    line 5 etc
    this line tells whether there is more text to read e.g. 'continue' if not it reads the following lines and enables sub text
    response 1 here I just state which line to 'goto' for the next piece of read lines
    response 2 same as response one functionality wise
    this is always repeat..just reseting the read lines index
    this is always goodbye

    now they also have different text files based on some world variables like the main quest stage or random statements and those read a different file per character. It is far more in depth, but this is the gist of it.


    so I am curious cotaks, what do you do for a living...you seem to be a very competent, albeit straightforward, coder. I always like the functionality versus simplicity ratio of your work....I think you have a nice balance.
    "The crows seem to be calling my name." Thought Kaw.
    Myrlea, "The Shepherd's Quest" formerly "Valiant" [project]



  5. #5
    Member BluePrintRandom's Avatar
    Join Date
    Jul 2008
    Location
    NoCal Usa
    Posts
    18,513
    I had a thought,

    use render to texture, and a camera and 1 text object,
    every few frames add a letter to a word.

    we render the text to texture and then move the uv over,
    and repeat.

    this way there is only 1 word worth of triangles.....

    to clear just replace the image buffer w/a empty buffer
    Break it and remake it - Wrectified
    If you cut off a head, the hydra grows back two.
    "headless upbge"



  6. #6
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Originally Posted by JustinBarrett View Post
    I fought a lot with using escape sequences in mine, in the end I just used additional text objects....it's not so elegant, but it works without a lot of code overhead.

    I also use string to int to read what is the next line to read based on selections in the sub text...
    so I have a text file for each npc that looks like the following...somewhat.

    this is text line 1
    line 2
    line 3
    line 4
    line 5 etc
    this line tells whether there is more text to read e.g. 'continue' if not it reads the following lines and enables sub text
    response 1 here I just state which line to 'goto' for the next piece of read lines
    response 2 same as response one functionality wise
    this is always repeat..just reseting the read lines index
    this is always goodbye

    now they also have different text files based on some world variables like the main quest stage or random statements and those read a different file per character. It is far more in depth, but this is the gist of it.


    so I am curious cotaks, what do you do for a living...you seem to be a very competent, albeit straightforward, coder. I always like the functionality versus simplicity ratio of your work....I think you have a nice balance.
    This is basically the same setup but without answers, this is just an example on how to read and skip trough a txt file and use it's data.

    I don't do much for a living, due to back problems no one wants to have me, so while i have a degree in ICT, i converted myself into doing volunteers work. And for that i teach people(with/without autism) to work with computers, install/repair and extend them, so basically the whole a-z package. This includes learning office packages, helping with programming/creating websites etc. So in short i help them with any problem they have or with anything they want to learn.

    The programming part is purely a hobby, i started creating websites around 20 years ago, still building sites once a while, then i found blender. I like gaming, and i like programming, so blender is a real treat for me, it keeps me busy on boring days. I am terrible in designing/texturing (due to i create everything my self and that is time consuming.), but i manage my way around with programming(yup that's why you don't see me enter bgmc, or seeing full games from me). I have created tons of use full things/scripts, and if i or my students don't need my resources anymore then i'm sharing it with the community here (not everything ends up here).

    So basically i like to program and create stuff in blender, everything is self learned trough google/youtube and ofcourse a question once a while on blenderartists.org.


    I had a thought,

    use render to texture, and a camera and 1 text object,
    every few frames add a letter to a word.

    we render the text to texture and then move the uv over,
    and repeat.

    this way there is only 1 word worth of triangles.....

    to clear just replace the image buffer w/a empty buffer
    #edit ok i didnt get it the first time, i understand what you mean, this can indeed be a nice option, i have to look into that, but i do not promise anything.
    #

    In this example you can still use just 1 text object, just add the 2 string together, Text = title '+' detail. And to be honest my knowledge of renderToTexture and scrolling uv is low, barely used it. But if someone likes to mess around with this example and creating fun things, you may share it within this thread (as long as it is use full for others).
    Last edited by Cotaks; 05-Jan-18 at 12:19.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  7. #7
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Added a cleaned up and improved version.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •