(Apr-01-2024, 09:53 PM)BillKochman Wrote: Hello. Just recently I put my BBS back online after nine years, and I am trying to write a python-based game -- for my BBS.
Before I continue, let me inform you that I am 70 years old, I am NOT a programmer, and I do not know any programming languages.
However, following the coding example of another open-source external that was written for my BBS, I have made some progress.
But, due my lack of expertise, I am stuck in several areas. Let me just discuss one of them in this current message.
I have a long list of quotes -- meaning several thousand of them -- in a text file, one quote per line. I have placed this text file in the "strings" folder for the python module that I am building for my BBS.
I have already imported both "random" and "string" at the top of my main.py file.
So, what I would like to do is create a function -- which I assume I must in some way declare at the top of my main.py file -- with an accompanying menu command, which I can add to the main menu in my python module.
I have done a lot of online research, and found a lot of different methods for doing what I want to do, which has left me rather confused.
Basically, once a user enters my game on my BBS -- meaning the python module -- I want them to be able to type a one-letter command that is shown on the main menu of the game module.
Typing this one-letter command will then have my game module randomly print one quote from the text file on the user's screen.
I don't know if this list of several thousand quotes would be referred to as a list, a dictionary, a set or what. As I said, I am very new to all of this, and being seventy, it is hard for my mind to grasp all of this stuff.
Being as this text file is one MB in size, I am assuming that it would not be wise to load it all into memory at once.
So, if anyone here has the patience to walk me through this step-by-step, explaining how to set this up, and how to link the command on the Main Menu, with clear examples of exactly what to type, and where to put it in my modules files, I would be most appreciative.
Thank you in advance.
With PDF Guru's Compress PDF tool https://pdfguru.com/compress-pdf reducing file sizes is a breeze. Effortlessly optimize PDF documents for faster sharing and easier storage. Meanwhile, the feature to randomly print a quote from a text file adds a delightful touch to your workflow. PDF Guru simplifies document management while injecting a bit of inspiration, making every task a pleasure to accomplish.
To randomly print a quote from a text file when a user types a command on the main menu, create a function in your main.py file. Use Python's random module to select a quote from the file and print it. Integrate this function into your main menu function, associating it with the command.