Be a Supporter!

Storing lots of external Dialouge

  • 242 Views
  • 6 Replies
New Topic Respond to this Topic
the1manwiththeplan
the1manwiththeplan
  • Member since: Jun. 10, 2008
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Storing lots of external Dialouge 2012-05-02 06:17:33 Reply

[AS3] Im am working on a kind of dynamic conversation system. When talking to a character you will be given a variety of different dialog options, accompanying each of these dialog options is a cost to say it, Dialog option one might require 10 charisma etc

The problem being I need a way to store a large numbers of these dialog options without cluttering up my code with a big list of strings and variables. Obviously the solution is to store the dialogue options and the requirements to say them externally.

I dont have much knowledge of setting up either external class as files or xml but I think both of these options could be a potential solution. I have a friend in class who made flash app with lots of information about the solar system all his data was stored externally in an xml file.

All I want to know is would this bulk dialouge and dialouge cost information be better stored in an external XML, AS Class or some other file type?"


...

PSvils
PSvils
  • Member since: Feb. 3, 2010
  • Offline.
Forum Stats
Member
Level 01
Game Developer
Response to Storing lots of external Dialouge 2012-05-02 06:34:59 Reply

At 5/2/12 06:17 AM, the1manwiththeplan wrote: All I want to know is would this bulk dialouge and dialouge cost information be better stored in an external XML, AS Class or some other file type?"

First off, an AS Class isn't external. Secondly, if you are considering making an AS class, then why don't you and skip the hassle of file loading?

That being said, use XML.

the1manwiththeplan
the1manwiththeplan
  • Member since: Jun. 10, 2008
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Storing lots of external Dialouge 2012-05-02 06:56:16 Reply

At 5/2/12 06:34 AM, PSvils wrote:
At 5/2/12 06:17 AM, the1manwiththeplan wrote: All I want to know is would this bulk dialouge and dialouge cost information be better stored in an external XML, AS Class or some other file type?"
First off, an AS Class isn't external. Secondly, if you are considering making an AS class, then why don't you and skip the hassle of file loading?

That being said, use XML.

Sorry if I described AS3 classes in a way that was inconsistent with the nature of what they are. I have literally never used external AS3 from the flash application, am new to AS3 and always coded on the main timeline that's why I had to ask which would be more appropriate for my situation.

But thanks for the advice Ill look into how I could use XML to store my data and how to reference it later in my code.
Any good resource suggestions on the best site to learn how to do this?


...

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Online!
Forum Stats
Supporter
Level 16
Game Developer
Response to Storing lots of external Dialouge 2012-05-02 12:35:24 Reply

At 5/2/12 06:56 AM, the1manwiththeplan wrote: Sorry if I described AS3 classes in a way that was inconsistent with the nature of what they are. I have literally never used external AS3 from the flash application, am new to AS3 and always coded on the main timeline that's why I had to ask which would be more appropriate for my situation.

But thanks for the advice Ill look into how I could use XML to store my data and how to reference it later in my code.
Any good resource suggestions on the best site to learn how to do this?

This is a start: http://www.republicofcode.com/tutorials/flash/as3xml/

There was another link I remember using, but I can't find it atm (just google it).

And BE SURE to include the doctype at the top of your XML file...I had so many errors before I realized that I forgot to put it

the1manwiththeplan
the1manwiththeplan
  • Member since: Jun. 10, 2008
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Storing lots of external Dialouge 2012-05-02 23:38:25 Reply

This is a start: http://www.republicofcode.com/tutorials/flash/as3xml/

There was another link I remember using, but I can't find it atm (just google it).

And BE SURE to include the doctype at the top of your XML file...I had so many errors before I realized that I forgot to put it

Thanks that resource was super helpful I had googled a site already but this one explained things much better.
When you say to include the doctype at the top of the file or it will throw an error are you referring to...

<?xml version="1.0" encoding="utf-8"?>

If so I remember the tutorial saying that this part was just good practice and optional.Why does it have to be included?

Also so far i understand that in the following xml

<IMAGE TITLE="shop">image3.jpg</IMAGE>

IMAGE is the name of the node and TITLE is an attribute with the value shop.

Is it possible to have more than one attribute? for example TITLE = "shop" SUBTITLE = "description"?


...

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Online!
Forum Stats
Supporter
Level 16
Game Developer
Response to Storing lots of external Dialouge 2012-05-02 23:52:42 Reply

At 5/2/12 11:38 PM, the1manwiththeplan wrote: <?xml version="1.0" encoding="utf-8"?>

Yes, but mine has more words, pretty sure it specifically has "DOCTYPE" in it. It has something to do with E4X not recognizing it's XML without it. I made that up; I honestly have no idea.

Is it possible to have more than one attribute? for example TITLE = "shop" SUBTITLE = "description"?

Yeah.

I made a dialogue prototype for later on that also uses XML. Attributes are useful, but one can't have multiple values, which kinda bugged me. Nodes within nodes are very helpful to do that: for instance I have

<a1>
   <text>I like pie and cake</text>
   <speaker>Joe</speaker>
   <next choice = "b1">b1</next>
   <next choice = "c1">c1</next>
</a1>

I can have multiple "next" nodes, which all correspond to the dialogue that can possibly follow.

nameistaken1
nameistaken1
  • Member since: May. 21, 2007
  • Offline.
Forum Stats
Member
Level 16
Game Developer
Response to Storing lots of external Dialouge 2012-05-03 00:08:22 Reply

Regularly, XML code requires the version number in the first line. It is declared as:

<?xml version="1.0"?>

This is pretty standard for most languages, so a program running the file knows what, interrupters/libraries to access in order to run the code.

The encoding declaration:

<?xml version="1.0" encoding="UTF-8"?>

is not mandatory for XML code, however it is good practice to improve the readability of your code. If it is used, it must appear right after the version number in the XML declaration, and must be a valid encoding.

When using AS3, (Flash), it is not required. Flash automatically understands that it is using version 1.0. Flash Builder does not, so it must be included, and I am unsure how Flash Develop works. However, it's generally a good idea to get used to including it, so when it is required - it's there. This will also allow greater modularity, reuse of your code, and improve it's readability.

DOCTYPE does not need to be declared, using that calls for specific mx libraries, and usually pertains to programming in Microsoft or Air/Flex platforms. You probably won't require it if using it for simple storage.


BBS Signature