Can't get C2 to read an XML tag.

Get help using Construct 2

Post » Sun Oct 02, 2016 8:57 am

So I followed a little tutorial on how to make an RPG like text box, and it worked like a charm, no problem at all. It was a series of events that read some tags from an XML file in the form of <dialog><line></line></dialog>. Now, I wanted to have more than a single character for this (and I am going to have a lot more), so I made another set of tags, <character></character>, this way I can have more than one set of dialogues, but I can't seem to make it work. It's not writing anything and the text box just says ''Text''. I tripled checked the events sheet to make sure I haven't done any mistake, but I couldn't identify any. If anybody can notice a problem in the XML code and the C2 code then that would be great, because right now I am stuck in this phase.
Code: Select all
<MyGame>
<character id='1'>
   <dialog id='1' type="normal">
   
      <line id='1' >This is a mere prototype</line>
      
      <line id='2' >why u so mean.</line>
      
      <line id='3' >don't judge us.</line>
      
      <line id='4' >plz.</line>
      
      <nextdialog>2</nextdialog>
   </dialog>   
   
<dialog id='2' type="end">
   
   </dialog>
</character>
</MyGame>


And the c2 code used to extract the text (there are dozens of these, but they all have this form so I'll only post this one).
Code: Select all
XML.StringValue("/MyGame/character[@id=" & curCharacter & "]/dialog[@id=" & curDialog & "]/line[@id=" & curLine & "]/text()")


I also feel like pointing out that when you interact with that NPC, curCharacter's value is set to 1.
If there isn't any mistake here then I'll post the entire event sheet.
I will also post the tutorial I followed (which includes a capx).
I can't post the link so here is the video id: /watch?v=BntLd2YUg4c&ab_channel=ScirraVideos
B
3
Posts: 5
Reputation: 189

Post » Sun Oct 02, 2016 10:25 am

If I understand correctly ...
it seems to work...

Image

xmlCharacters.capx
Image
B
65
S
23
G
7
Posts: 1,503
Reputation: 10,892

Post » Sun Oct 02, 2016 5:24 pm

Message: Lunastras can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
korbaach wrote:If I understand correctly ...
it seems to work...

Image

https://app.box.com/s/zsvitvxpo6o43s77f9c65jz3v6e928su xmlCharacters.capx


Thank you for the reply!
You confirmed me that I wasn't looking deep enough at the capx. I started thinking out of the box, instead of "Why isn't it working now'' I started thinking ''Did it even work to begin with?''. When I ctrl z'd everything I've realised it wasn't working anymore. I don't have a clue when I broke it, but now it's working like a charm.
B
3
Posts: 5
Reputation: 189


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests