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

  • 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.

  • 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

  • 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..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • ....and one very simple capx:

    http://s000.tinyupload.com/index.php?fi ... 7337387723

  • Nice one korbaach

  • Thanks LittleStain

  • 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/text()")? Can't I just use something simpler like "set Text to Xml.StringValue("Text Id=001")?

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

    <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    How do i read aXML.StringValue("/foo/line/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/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

  • 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/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...

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

    xml is language...

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

    "Thank You Very Much,Mr. Korbaach."... .... <img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing">

    ...........................................................................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

    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

  • Thank you very much, I did it! As always your help is fundamental.

    Thanks again!

    P.s.

    There's a thing I still can't understand:

    How can I use two xml files at the same time and read data from both of them without having to reload them each time?

    I understood thanks to your example how to load 2 xml files, but what if I need to continuously acquire data from both of them?

  • as I said, in a previous post...

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

    in Arrays example i load two xml files..but i also use two Arrays object...

    xml example: http://s000.tinyupload.com/index.php?fi ... 8605593142

  • as I said, in a previous post...

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

    in Arrays example i load two xml files..but i also use two Arrays object...

    xml example: http://s000.tinyupload.com/index.php?fi ... 8605593142

    This is beautiful!

    Thank you very much! You really helped me a lot!

  • Simple but amazing! Thank you guys!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)