Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 May 2007
Offline Last Active Jan 06 2014 05:46 PM

Posts I've Made

In Topic: XML Script Parser in AS3

30 December 2013 - 12:45 PM

I've resolved the issue I was having. I replaced the for statement with a while statement which looks to ensure a pause variable is false. The pause variable is triggered to true when the text or choices command is triggered. It is working exceptionally well, I am slowly implementing more commands. I will post the full script when complete. Thanks again for the help.

In Topic: XML Script Parser in AS3

27 December 2013 - 09:32 PM

So I have been trying your code but seem to have an issue with the automated portion. It's working, however I am having issues with it processing too much. Take the first portion of the NPCAction code from above. It should display the text and then wait for a user input before moving onto the qstchk nodes. However, with the for statement, it's processing it all at once.
Not sure how to resolve this for the purposes I am looking for.

In Topic: XML Script Parser in AS3

21 December 2013 - 04:11 PM

Should be okay...you'll note that neither handleQuestText or handleQuestChoices call processNPCNode, which is the function that actually makes actions happen. I was working on the assumption that all immediate children need to be parsed while subsequent child nodes (children of children) are dependent on their parents -- so most of the time they're not automatically processed.


So, for example, in the top level nodes that you list above, the "text" node will be processed, as will "qstchk". The text node won't do anything except update text, so nothing will happen after parsing that particular node. The qstchk one, on the other hand, I understood to be a conditional statement, so child nodes are processed subsequently depending on the quest status you supply (if status >= 0, TRUE is processed, otherwise FALSE it processed). I'm assuming that all of your relevant actions are at the same level in the XML data (siblings), so other than "qstchk", no other nodes will continue processing child nodes. This also means hat if you have many "qstchk" nodes as children, processing can potentially happen all the way to the inner-most one.


But preventing automated processing requires you to simply remove the processNPCNode calls from the handler. For example:


public function handleQuestCheck(currentNode:XML, currentStatus:int):void {
   var actionID:int=int(currentNode.@ID);
   var status:int=int(currentNode.@status);
   var comparator:String=String(currentNode.@oper);
   var resultXML:XML=this.getResultNode(currentStatus, status, comparator, currentNode);


One thing I didn't detail is the _currentNPCAction variable -- this stores a reference to the current node being processed in the XML object. You can force the code to proces any instruction by simply feeding the appropriate node to the processNPCNode method. I'm automatically moving this reference further inside the XML tree based on the logic, but there's nothing to prevent you from feeding it arbitrary entry points either. Additionally, if you have any more actions you want to process, you can simply add them to the "switch" statement. Strictly speaking, you don't need to create a handler method for each and every action, but I find it helps to keep things more manageable and easy to understand.

Thanks again for helping out with this. I will definitely try it out and see how it works. In the example above of my XML, the items which require user input and that should halt the processing of the parser is the text and choices. So basically until there is user input nothing should be continued and then once things continue it can be parsed further and automatically until the next instance of text or choices. If this means the qstchk will traverse multiple nodes (as in the example above), thats ok. I hope this makes sense. I will use the code and see how it works. Thanks again.

Also, in your script you posted, each function has a currentstatus:int associated with that. Where does that get fed from?

In Topic: XML Script Parser in AS3

21 December 2013 - 08:20 AM

Wow. That looks great. I will definitely take a look at it and use it as a baseline. My only concern is that the for loop might cause all commands to be run at once without the proper stops and waiting for user input. Basically every <text> or <choices> command needs to pause execution and await a user rrsponse before continuing.

In Topic: XML Script Parser in AS3

20 December 2013 - 10:59 AM

I'm not sure I understand the issue with putting status in the xml file. Maybe I should explain the snippet I posted in OP. Basically its the conversation that will be tied to a specific NPC. Everytime there is a <text> or a <choices> tag a message window will display which awaits for user input to continue. So in the case of the snippet, basically the NPC greets the player and after player input (generally Enter button) the NPC will then check to see if a specific quest is at a certain progression (used for quests with multiple stages), depending on the progression of the quest, two pathways can occur, the TRUE condition which is where either the player has finished the quest or has the required items to finish the quest and then the NPC will complete the quest, or the FALSE condition where the NPC asks if the player would like to start the quest.

I'm thinking what I can do is to parse the XML file into nodes and store these into an array and then iterate through the array (as each node will be a seperate process).