How do I put all of the game text in XML file/s

Just started using Construct 2? Post your questions here

Post » Sun Apr 19, 2015 3:16 pm

I tried reading guides but since I'm a total noob I didn't understand a thing... please be patient with me...
I'm trying to put my game's text in an XML file giving an ID to each text, so that I can do stuff like saying: "in this text box put Text_ID_001, in this other text box put Text_ID_002" etc etc.
This way the game will be far easier to translate, right? (I would only need to translate the xml file and the game would automatically load all the correct texts in the right places)

The problem is that I don't have the palest Idea on how to do that, even if I'm pretty sure it's possible to do it.

I couldn't even find step by step guides for noobs, everything refers to complex stuff like AJAX or Expressions and considers everything as given...

Thank you in advance for you help, and please forgive my ignorance on the subject.
B
8
S
1
Posts: 20
Reputation: 490

Post » Sun Apr 19, 2015 3:38 pm

You'd want to use project files.

https://www.scirra.com/manual/141/files

short tutorial:

https://www.scirra.com/tutorials/328/us ... onstruct-2

When the file is in the xml object:

https://www.scirra.com/manual/139/xml

And here's a tutorial on how to parse the information:

https://www.scirra.com/tutorials/354/xml-parsing
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Apr 19, 2015 3:42 pm

There is no way to get around the complex stuff like Ajax or Expressions..

But in the short tutorial it is explained clearly how to load an xml projectfile into the xml-object inside C2
and the tutorial on how to parse the information explains how to use everything within the xml-object in your project..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Apr 19, 2015 3:58 pm

Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Sun Apr 19, 2015 4:01 pm

Nice one @korbaach
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Apr 20, 2015 5:32 am

Thanks @LittleStain :)
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Mon Apr 20, 2015 7:23 pm

Thank you guys, as always you're the best.

@korbaach:
You're very good as usual! I have a few question for you, if you have time:
-How did you make the sentences loop? I can only find an event that says "on clicked, add 1 to varLineID" but there's no event that says something like "when varLineID>4, set varLineID to 0"
-Mind helping me with the expression to discern the lines in the xml? How do i read aXML.StringValue("/foo/line[@id="&varLineID&"]/text()")? Can't I just use something simpler like "set Text to Xml.StringValue("Text Id=001")?
B
8
S
1
Posts: 20
Reputation: 490

Post » Mon Apr 20, 2015 8:01 pm

WadaKatsu wrote:... but there's no event that says something like "when varLineID>4, set varLineID to 0


Image

:D

WadaKatsu wrote: How do i read aXML.StringValue("/foo/line[@id="&varLineID&"]/text()")? Can't I just use something simpler like "set Text to Xml.StringValue("Text Id=001")?


For simple text you can use something like

set text to...............XML.StringValue("//line[@id=3]/text()")
OR even
set text to.............XML.StringValue("//line[3]")

OR ( if you have several Text instances)

set text to.............XML.StringValue("//line["&Text.IID+1&"]")

only if you want dynamically change text ..you need to use variable



http://www.w3schools.com/xml/xml_whatis.asp
http://www.w3schools.com/xpath/default.asp
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Tue Apr 21, 2015 7:08 pm

You're the best!
But it only reads text from the root, If I write an xml file with childs/subchilds it doesn't read the text in them... Do I have to change the formatting of the line?
If XML.StringValue("//line[3]") is enough to individuate the needed text, what's the final part of XML.StringValue("//line[@id=3]/text()") for?

Also, can I load several different XML files? The command "load XML document from string AJAX.LastData" seems to only refer to the last of the loaded xml files...
B
8
S
1
Posts: 20
Reputation: 490

Post » Tue Apr 21, 2015 10:07 pm

WadaKatsu wrote: If XML.StringValue("//line[3]") is enough to individuate the needed text, what's the final part of XML.StringValue("//line[@id=3]/text()") for?


xml is language...
..and like in any language...you can say something like:

"Thank You Very Much,Mr. Korbaach."... .... :lol:
...........................................................................OR you can say;
"Thanks Dude"
.....................................it is the same, but not the same.....

...test this capx in Chrome,Firefox,IE,Opera.........

capx:
http://s000.tinyupload.com/index.php?fi ... 2943172178


WadaKatsu wrote:Also, can I load several different XML files? The command "load XML document from string AJAX.LastData" seems to only refer to the last of the loaded xml files...


yes.. you can..
.one xml file for each hml object ...at the same time....

This is an example with Arrays...but I think you get it...

http://s000.tinyupload.com/index.php?fi ... 2330141496
Last edited by korbaach on Wed Jun 10, 2015 10:47 pm, edited 1 time in total.
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests