.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.1 changes

  • working in upbge
  • Altered unsave/outdated logic storage to globaldict storage

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:



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”

Works in BGE and UPBGE:
dialog system.zip (77.5 KB)

Have fun with it,
Cotaks

1 Like

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>’,’
') to create
(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

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.

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

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).

Added a cleaned up and improved version.

Fixed this resource page, It did not correctly come over from the old forum, and now it works again, Have fun with it!

1 Like

added new version 2.1