Sign in to follow this  
Anexa85

Managing a lot of Text with C#

Recommended Posts

I'm working on a simple text-based SRPG and realized pretty quickly that I will probably need to load most of the story from text files. What do you suggest for this? A scripting language like lua? Does C# have a good way of handling this? Also... when you suggest a method do you mind pointing me to where I can learn how to set it up (if it uses something other than C#)?

Share this post


Link to post
Share on other sites
Well, I was looking to store the story line in text files instead of typing it directly into the compiler. For example, the introduction (explains the story and your location and everything) is fairly long, and I would prefer to load it from a text file.

Share this post


Link to post
Share on other sites
You can easily load a file into a string like this:


string introText = File.ReadAllText("introduction.txt");

Share this post


Link to post
Share on other sites
You might want to consider using a database too. If you feel up to it, it is valuable learning, and C# with .NET has everything you need to communicate with databases like access or sqlite

Share this post


Link to post
Share on other sites
Do you mean with LINQ? It would be great if I could start learning how to do that. I know a little bit about MySQL but have never used it or any other database software with C#...

Share this post


Link to post
Share on other sites
No I wasn't thinking about LINQ. I have never had the time to investigate LINQ myself even though the concept is very interesting. I was thinking about basic usage of a database instead of using files. Just plain SQL queries.

Share this post


Link to post
Share on other sites
Quote:
Original post by pulpfist
You might want to consider using a database too. If you feel up to it, it is valuable learning, and C# with .NET has everything you need to communicate with databases like access or sqlite


I wouldn't do that, imo it will just add lots of overhead and complexity.
What do you think would be the benefits of this approach?

Share this post


Link to post
Share on other sites
Quote:
Original post by m4rv4
Quote:
Original post by pulpfist
You might want to consider using a database too. If you feel up to it, it is valuable learning, and C# with .NET has everything you need to communicate with databases like access or sqlite


I wouldn't do that, imo it will just add lots of overhead and complexity.
What do you think would be the benefits of this approach?


A database has several advantages over flat files that can be used creatively in a game, like relations between data, search capabilities, backup strategies, save games, and a standarized way of handling and updating data. Also, I would think twice about using files to store considerable amounts of information as it IMO would require more maintenance than it is worth. For learning purposes, getting used to databases is likely to be of value, even for games.

That said, it was just a suggestion. Plain files may very well be a better choice in some cases.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this