playMaker

Author Topic: [SOLVED]How to pull a numerical value from an XML file to be used as an int?  (Read 2280 times)

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
AS the title said, I want to pull a numerical value from the xml file I'm using for my games dialogue system, with the numerical value representing the id for different character sprites that would be shown during dialogue, the way my xml files are set up is with three values
 <script>
     <dialogue>
         <text name="NameofCharacter" sprite="29(theSpriteValue)" id="Content of the dialogue"></text>
     </dialogue>
 </script>
Though when I try to pull the value for sprite it doesnt translate properly, and the int value remains the same, is there a specific way I need to format numerical values in xml format or is it just not possible to do such a thing through an xml file. (Below is thew way my fsm is set up)
« Last Edit: April 17, 2018, 03:37:39 AM by spicyasian128 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #1 on: April 14, 2018, 03:13:10 PM »
Hi, you might want to use Datamaker(XmlMaker)
You can find it on the Ecosystem

And you can find some tutorials here :
http://hutonggames.com/playmakerforum/index.php?topic=11711.0

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #2 on: April 14, 2018, 10:42:24 PM »
I already am using datamaker for this, but when I try to retrieve a numerical value, it doesn't update the int value I assign it to, so I was wondering if there was some specific method to retrieving a numerical value, and not a text based one.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #3 on: April 16, 2018, 04:46:48 AM »
Hi,

 can you explain what you are doing? it seems you want to write back to the xml right? not just read from it. or mabe if you just want to read, then your xpath might be wrong and you are not reading the right value.

is '29(theSpriteValue)' your actual content?!

 Bye,

 Jean

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #4 on: April 16, 2018, 11:18:34 PM »
What I ultimately want, is just to be able to pull a number from my xml, and have it be used as an integer value in a different fsm, as such, "29" is the value i want to assign to my integer (the sprite value bit was just me trying to explain what it was used for that isn't in my xml anywhere), I only need to pull the number itself as a value, but when I try to do that, the int remains the same, and doesn't change its value.

If I could try to explain how I wanted it to happen, it'd be something like, the information is pulled from my xml, and my fsm moves into a state that displays the text that was pulled, clicking down on the mouse will cycle back through the xml to get the next string of text, and it keeps doing that until it reaches the conversations end

What I want to have happen additionally, is for my fsm to also pull an int value so from
 <text name="Eric" sprite="29" id="something something batteries"></text>
"Eric" would be displayed as a string, as would "something something batteries" and both would be converted onto a piece of gui text. I want to also take "29" and have it be pulled as an integer to be used in an integer compare, so that it checks, and when it confirms that the new int value 29 is being assigned to is, 29, it moves into a new state that displays the character's sprite.

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #5 on: April 16, 2018, 11:20:18 PM »
also just to clarify, I was wondering if I needed to not have 29 in quotes like that, or if there was just a different means I needed to use to have it be pulled as a number.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #6 on: April 17, 2018, 02:14:49 AM »
Hi,

 in xml, EVERYTHING is a string, so you need to put 29 in between quote yes, else it will not validate.

 to check validation, use https://www.xmlvalidation.com and paste your xml, it will tell you if it's ok or not and where the issue is if there is a problem.

what is your xpath to get to this value? I suspect this is the problem.


 Bye,

 Jean

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #7 on: April 17, 2018, 03:04:59 AM »
First, thanks so much for that site link, I didnt even know that existed before o I'm sure it'll help me a lot.

My xpath is just 'dialogue/text' which never gave me any problems when I was just displaying text, for reference this is the full set up of my state machine.

The one labelled sfx is just playing a sound

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #8 on: April 17, 2018, 03:07:26 AM »
Hi,

 yeah, all sounds good to me from the screenshots..

do you have more than one of these nodes in your xml? maybe it's your initial selection of the node that select the first one and not the one you want.

 store your reference, and check it with the new datamaker reference viewer, to make sure the content is the one you expect ( add a dummy attribute and check it's there for example)

 Bye,

 Jean

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
Re: How to pull a numerical value from an XML file to be used as an int?
« Reply #9 on: April 17, 2018, 03:37:18 AM »
Doing as you said jean I went in and made sure all my references were working, and in the process found that I had forgotten to check on every frame for my int compare, which ended up being the problem. Thanks so much for your help in this, and I hope you'll excuse me as I bury my head in sand.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 no worries at all!

 Bye,

 Jean