Managing a lot of Text with C#

Started by
8 comments, last by pulpfist 14 years, 10 months ago
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#)?
Advertisement
Could you give us some more details on what would actually be stored in those text files?
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.
You can easily load a file into a string like this:

string introText = File.ReadAllText("introduction.txt");
Thanks! That was a lot easier than I thought it was going to be...
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
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#...
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.
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?
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.

This topic is closed to new replies.

Advertisement