Sign in to follow this  
fusion1

reading data file c#

Recommended Posts

Hello everybody, i am trying to write a basic text based rpg in the vein of zork and other rpgs from the late 70s and early 80s. However, i have come across a problem. I am trying to create a more open ended way of creating monsters for the game by the game reading .txt files. However, i have no idea how to do this. This may come across quite stupid but i cant really find a tutorial that covers what i am working on. Can you please provide a website url that you believe may help me with this or explain it in a reply.

Thank you for your time,

fusion1

p.s.: im writing this to raise money for a charity, so hasty responses are very useful as i am working on a limited time scale

Share this post


Link to post
Share on other sites
Using lists to read, write, and search text files:
[url="http://stackoverflow.com/questions/4483529/c-sharp-using-lists-to-read-write-and-search-text-file-lines"]http://stackoverflow.com/questions/4483529/c-sharp-using-lists-to-read-write-and-search-text-file-lines[/url]

How To: Reading and Writing Text Files:
[url="http://www.csharp-station.com/HowTo/ReadWriteTextFile.aspx"]http://www.csharp-station.com/HowTo/ReadWriteTextFile.aspx[/url]

An example file I found while looking this stuff up - this should help you to see how it can be set up:
[url="http://zeboyd.com/wp-content/uploads/2011/05/BoDVII-Monster-Stats-Abilities.txt"]Breath of Death VII Monster Stats & Abilities[/url]

Share this post


Link to post
Share on other sites
[quote name='fusion1' timestamp='1341146807' post='4954523']
However, i have come across a problem. I am trying to create a more open ended way of creating monsters for the game by the game reading .txt files.
[/quote]

You could look into something like JSON, there are a couple of libraries available, such as [url="http://json.codeplex.com/"]http://json.codeplex.com/[/url]. There are also built-in libraries for XML parsing in .NET, but XML is a bit more complicated and probably overkill (IMO).

Share this post


Link to post
Share on other sites
i am still having a bit of trouble assigning the values from the .txt file to actual variables within the code, and i cannot find a very good tutorial to show me how, the reading and writing part i have well, its just assigning the values

thank you for your time

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