(Resolved) Load XML values and add them to a Glabal Variable

Get help using Construct 2

Post » Thu Aug 28, 2014 5:29 am

mardoch wrote:Still don't work. I designed my xml as you recommended IndieKiwi, but it doesn't change anything :(


The xpath is working for me. Its the other part of your logic that is broken, I've hardcoded Stage = 1, and used the first xpath from my other comment set to a new textfield named "test". It sets the value to "The First Stage" when its run.

Changing Stage=2 would be The Second Stage etc.
You do not have the required permissions to view the files attached to this post.
B
32
S
6
G
2
Posts: 317
Reputation: 2,801

Post » Thu Aug 28, 2014 10:21 am

Hello IndieKiwi,

Thanks to your help, I finally make it!

In fact I just remove the Functionand replace it by a "On Every trick" event. Now it properly display the correct node from the XML and also replace the chosen global variable by the XML datas!

I attached the new file here as an exemple if anyone have the same issue!

By the way, I get back to the original XML design because it didn't work with your design:

Code: Select all
<stages>
<stage id="1">
<name>The First Stage</name>
<Level1>5</Level1>
<Level2>500</Level2>
<Level3>5000</Level3>
</stage>
</stages>


That could be maybe easier to code but it's working like this, so it's fine.
You do not have the required permissions to view the files attached to this post.
B
5
S
1
Posts: 29
Reputation: 433

Post » Thu Aug 28, 2014 10:31 am

That is great! but i recommend not using on every tick as it could be constantly assigning the same text and drawing the text onto the canvas, which will have performance issues on something that is essentially static. Use something like a "do once", "for loop", on "layout load" etc could perform better.

I haven't explored ajax or xml in construct 2 yet so i learnt something new too :)
B
32
S
6
G
2
Posts: 317
Reputation: 2,801

Post » Fri Aug 29, 2014 12:36 pm

This is a great example. It's nice to read from xml files. But what about saving back to xml file ? Is there a way to create a xml file, and save them into it? (For windows, node-webkit projects) .
B
7
S
1
G
1
Posts: 76
Reputation: 904

Previous

Return to How do I....?

Who is online

Users browsing this forum: apalm1341, blissfulwizard and 18 guests