Trying to parse external files to drive content
So I wanted to make a simple application. I like ot play fighting games (Mortal Kombat, Street Fighter, etc). I have found web pages and printables with movelists of how to do various moves for each character, so I decided to consolidate all of these into an app I could put on a phone or tablet so when i play the games, i can click on a game, click on a character, and be given their moves right before me. I was planning on it being a simple app. I have symbols for each of the inputs (directions, punches, kicks, etc.), and had made a scene that was a horizontal bar with a text label on it. My plan was to populate a scene with these bars, use the label to label the move, and then add sprites for each of the inputs (for example, in mortal kombat, Scorpion's harpoon would have a text label with the text "Harpoon", followed by a "back" sprite, a "back" sprite, and a "punch_low" sprite. I was planning on creating XMl files for each game, which would include inside of them the list of characters, and each character would have a list of moves, and each move would have a list of inputs. I am trying to get the XMLParser to work and canNOT figure it out, at all. Google searches are pointless, and the most help I've gotten is a generic reply that got me to use the .read() command after the .open() command, so now i can get to my root node, but can't get to anything inside. Here is an XML snippet to begin to show what I was thinking of creating to accompany this:
<?xml version="1.0" encoding="UTF-8"?> <chars> <char> <name>Liu Kang</name> <moves> <move> <name>Fireball</name> <inputs> <input> <type>Sprite</type> <label>fwd</label> </input <input> <type>Sprite</type> <label>fwd</label> </input <input> <type>Sprite</type> <label>punch_high</label> </input </inputs> </move> </moves> </char> </chars>
Using this code, i can get it to read the name "chars"
var data = XMLParser.new() data.open("res://assets/xmls/mk1.xml") data.read() data.skip_section() print(data.get_node_name())
and that's all i can do. I have tried reading the node_data, seeing if i could get attributes, etc. and nothing. Is there a better way than XML? I have looked at json parsing, but am not familiar with json so figured it would be even more difficult. Can i do this in a plain text file and read it?
Sigh... this will be such an easy thing to develop once i get this part figured out. Its just a bunch of data entry and loading the right file, then i have to add either a sprite or a label to show what the inputs are. Any help at all is appreciated. Thanks so much guys!