Jump to content
  • Advertisement
Sign in to follow this  
delstar81

VB help requested

This topic is 4462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A friend of mine and I are in the process of making some tools for PnP RPG's, such as a character gen, monster/spell/whatever info viewer, dice roller, etc. Right now, we're running into a problem as to the best way to store information on monsters/spells/whatever. We're currently storing it to a plain text file, but there are several headaches cropping up there. I've tried researching into databases and XML as possible alternatives, but most information I find is too sketchy on details for me to be comfortable with it (database info turns out to be focused on the actual writting of the database, but not on how to access it with code, and XML info focuses on web stuff, which we're not doing, or tends to be a convuluted nightmare) So, to the question, does anyone know of any tutorials that show how to make a simple database and how to access it, or how to work with XML to the extent that I need it, without all the extra crap? Or would we be better off with just a plain text file?

Share this post


Link to post
Share on other sites
Advertisement
No takers? I thought I might find some useful info here. Ah well. Just in case, I'm using VB.NET 2005. Any opinions would be useful.

Share this post


Link to post
Share on other sites
This depends on what kind of data you want to store. You can store stuff about monsters and spells in files. Since you are working on .NET, this should be pretty easy. You can create a class that defines a specific type of monster, and then you can load in the data for a new monster from a file. You can use something like

MonsterType = "dog"
ImageFile = "dog.bmp"
AttackPower = "34"
...


You can easily parse this file and then use it in your game.

Share this post


Link to post
Share on other sites
I am currently working on a project very much like yours. A lot of it depends on how much data you have. For the typical stuff i would suggest XML, it works pretty well and can really store a lot of information and is pretty easy to access.

If you have tons of information, like all of the source books for Rifts then I would suggest going with mySQL.

If you need some help getting started let me know, I should be able to point you in the right direction.

theTroll

Share this post


Link to post
Share on other sites
Hope this helps...didn't test it, but I think it should help you out a bit...

Reading XML file:
Dim objDocument As Object
Dim objNode As Object
Dim objNodeList As Object
Dim strName As String, strHealth As Long, strStrength As Long
Dim objMonster As Monster
Dim objMonsters As New Collection

' Create DOM Document object.
Set objDocument = new ActiveXObject("Microsoft.DomDocument");

' Open the XML file.
objDocument.async = False
objDocument.validateOnParse = False
Call objDocument.Load(strFilename)

' Loop through each element of the root.
If objNode.parseError.errorCode = 0 Then
' Find the children of the "monsters" element.
Set objNode = objDocument.documentElement.selectSingleNode("monsters")
Set objNodeList = objNode.childNodes

' Loop through each single "monster" element and create monsters objects.
For Each objNode In objNodeList
Set objMonster = New Monster

Call objMonster.setName(objNode.selectSingleNode("name").nodeValue)
Call objMonster.setHealth(CLng(objNode.selectSingleNode("health").nodeValue))
Call objMonster.setStrength(CLng(objNode.selectSingleNode("strength").nodeValue))

Call objMonsters.Add(objMonster)
Next
Else
' Handle error here...
End If

' Dereference memory objects.
Set objDocument = Nothing
Set objNode = Nothing
Set objNodeList = Nothing
Set objMonster = Nothing



Writing XML file:
Dim objDocument As Object
Dim objMonsterNode As Object, objCurNode As Object

' Create DOM Document object.
Set objDocument = new ActiveXObject("Microsoft.DomDocument");

' Load filename you provide to function.
objDocument.async = False

Set objMonsterNode = objDocument.createElement("monsters")
Set objDocument.documentElement = objMonsterNode
For Each objMonster in objMonsters
Set objCurNode = objDocument.CreateElement("name")
objCurNode.nodeValue = objMonster.getName()
Call objMonsterNode.appendElement(objCurNode)

Set objCurNode = objDocument.CreateElement("health")
objCurNode.nodeValue = objMonster.getHealth()
Call objMonsterNode.appendElement(objCurNode)

Set objCurNode = objDocument.CreateElement("strength")
objCurNode.nodeValue = objMonster.getStrength()
Call objMonsterNode.appendElement(objCurNode)
Next

Call objDocument.Save(strFilename)

' Dereference memory objects.
Set objDocument = Nothing
Set objCurNode = Nothing
Set objMonsterNode = Nothing

Share this post


Link to post
Share on other sites
Here is an article on XML serialization with VB.Net. This lets you easily define how a class is stored in XML.

Although, depending on how complex the data is, a simple text file may be better. If you want to use databases you need to look for information on ADO.NET and SQL.

Share this post


Link to post
Share on other sites
Thanks for the replies. A couple things, though...

MattMan : Will the code you use to write to the XML file actually create the file and fields, or will I have to do that seperately?

Currently, this is being geared towards DnD 3rd Ed., and we have two monster manuals, a speel book, and several other things, so it'll probably be quite a bit of info. We already have the dice roller and character generator. Right now I'm working on a program to store the monster info into the files, so his wife can start data entry on that.

Ace Pilot : I would like to make a file like that, but have no idea how to parse something like that. Right now we're simply using the MyReader parsing, as referenced by MSDN.

Share this post


Link to post
Share on other sites
You can either enter the information into the XML by hand (something I seem to be fond of doing) or write a simple app to enter the information for you.

I would suggest you make a class that can enter and retrive information from the XML file. This class can be used to make an app to enter the information and it can also be used in your RGP app. It might also be a good idea to create in your RGP app a way to enter more information to the XML file. This will let you have a single program instead of two to keep up with more information.

theTroll

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!