playMaker

Author Topic: Calling from an external Excel file to Playmaker Arrays[SOLVED]  (Read 8331 times)

mweyna

  • Full Member
  • ***
  • Posts: 242
Calling from an external Excel file to Playmaker Arrays[SOLVED]
« on: September 24, 2013, 12:54:53 AM »
So I have an Excel document that looks like this -



Utilizing ArrayMaker, I'd love to find a way to automatically interpret those individual columns into specific arrays. So there would be a mission ID array, Mission Description, etc. However, the "SPLIT TEXT TO ARRAY" function seems to have difficulty switching between types "INT, FLOAT, STRING".

Anyone ever find a way to easy create this kind of excel to Array workflow, and if so how?
« Last Edit: October 01, 2013, 03:06:57 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #1 on: September 24, 2013, 05:45:19 AM »
Hi,

 I think I have everything you need to do just that :) It's right now all over the place on my various projects, but in short:

-- save your excel in .csv
-- convert that .csv in xml ( I have a too for that)
-- use XmlMaker then

I have no time this week unfortunatly, and I have other threads on this forum to complete first. Can you bump me toward the end of next week. I will then create a working example using that excel.

 Bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #2 on: September 24, 2013, 02:42:51 PM »
Where or what is XmlMaker?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #3 on: September 25, 2013, 02:06:55 AM »
Hi,

 xmlMaker is an util I created like ArrayMaker to allow PlayMaker users to work with xml.

https://hutonggames.fogbugz.com/default.asp?W1133


Bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #4 on: September 26, 2013, 12:43:29 AM »
What tool do you use to convert the CSV to XML?

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #5 on: September 26, 2013, 01:25:10 AM »
So I found a bunch of random free translators online, but looking at your XMLMaker plugin, I have a few questions -

If my XML were:

<?xml version="1.0" encoding="ISO-8859-1"?>

<MissionList>

<Mission category="01_00">
  <title lang="en">Humble Beginnings</title>
  <description>This is Mission 01</description>
  <reward>100</reward>
  <Level0MinionsRequired>0</Level0MinionsRequired>
  <Level1MinionsRequired>0</Level1MinionsRequired>
  <Level2MinionsRequired>1</Level1MinionsRequired>
</Mission>

<Mission category="02_00">
  <title lang="en">The Games Afoot!</title>
  <description>This is Mission 02</description>
  <reward>100</reward>
  <Level0MinionsRequired>0</Level0MinionsRequired>
  <Level1MinionsRequired>0</Level1MinionsRequired>
  <Level2MinionsRequired>2</Level1MinionsRequired>
</Mission>

<Mission category="03_00">
  <title lang="en">Something Troubling is Coming</title>
  <description>This is Mission 03</description>
  <reward>100</reward>
  <Level0MinionsRequired>0</Level0MinionsRequired>
  <Level1MinionsRequired>0</Level1MinionsRequired>
  <Level2MinionsRequired>3</Level1MinionsRequired>
</Mission>

</MissionList>

Within the "Get Books by Category" FSM, you have books[@category="_0_"] but what exactly is the variable _0_ and where is it being defined?

Do you need a blank GO with the XML Proxy and the asset linked, or can I do this on the object with the FSM? Does this need to be at the top-level of the scene or just somewhere within in?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #6 on: September 26, 2013, 01:30:25 AM »
Hi,

 I have my own tool :) That's what I need to dig in my previous projects :)

_0_ is your identifier to inject a value in the xpath.


so 'books[@category="_0_"]' is really something you want to be

books[@category="My own category"]

and so _0_ means that I will look at the first variable defined and replace _0_ with its value.

 does that make sense?

xml proxy doesn't beed to be blank and can be anywhere, but a top level gameobject is a good start, then you can complexify this aspect, right now only try to go straight to a result.

bye,

 Jean

bye,

Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #7 on: September 26, 2013, 03:04:11 AM »
If an XML Invalid error is returned on the XML Proxy, what would be causing that?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #8 on: September 26, 2013, 04:01:30 AM »
 hi,

 It's likely that your xml is not valid. Can you paste the xml you are using? I'll check locally.

bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #9 on: September 26, 2013, 04:25:59 AM »
So here is my test XML -

Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1"?>

<root>
<missionlist>

<mission category=00>
  <title lang="en">Mission 01: New Beginnings!</title>
  <description>ARRRRR</description>
  <reward>100</reward>
  <level_0_minionsrequired>0</level_0_minionsrequired>
  <level_1_minionsrequired>0</level_1_minionsrequired>
  <level_2_minionsrequired>1</level_2_minionsrequired>
  <level_3_minionsrequired>0</level_3_minionsrequired>
</mission>

<mission category=01>
  <title lang="en">Mission 02: Time To Make A Name!</title>
  <description>Test</description>
  <reward>1000</reward>
  <level_0_minionsrequired>0</level_0_minionsrequired>
  <level_1_minionsrequired>0</level_1_minionsrequired>
  <level_2_minionsrequired>1</level_2_minionsrequired>
  <level_3_minionsrequired>0</level_3_minionsrequired>
</mission>

<mission category=02>
  <title lang="en">Mission 03: Let's get em!</title>
  <description>BLAH</description>
  <reward>10000</reward>
  <level_0_minionsrequired>0</level_0_minionsrequired>
  <level_1_minionsrequired>0</level_1_minionsrequired>
  <level_2_minionsrequired>2</level_2_minionsrequired>
  <level_3_minionsrequired>0</level_3_minionsrequired>
</mission>

</missionlist>
</root>

I tried to mimic it off your included example. For some reason it worked, then I closed Unity and re-opened it and now it's INVALID again.

Additionally, I was trying to set up a simple method to extract the XML values when it was working, but I'm a bit confused as to the proper method. See the below screenshots with obvious missing FAIL states, but basically, it wasn't pulling out at data from my XML, and I wasnt sure why.



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #10 on: September 26, 2013, 07:08:51 AM »
Hi,

 your xml is not valid. Attribtues must be quoted like so:

 attribute="value"

 Use online validators to get more infos:

http://www.xmlvalidation.com/

I ran it using that validation site and it points to where the problem is.

bye,

Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #11 on: September 26, 2013, 03:28:12 PM »
Awesome link, definitely helped me catch the error!

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #12 on: September 26, 2013, 03:40:30 PM »
As for the part "mission[@category='_0_']", where mission is a string variable set to the exact name of <mission category="00">, it doesn't appear to be finding, and more importantly pulling any of the data in.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #13 on: September 27, 2013, 01:53:16 AM »
Hi,

 Your xpath query is wrong, you need:

missionlist/mission[@category="_0_"]

Because your mission node is within missionList node.

You can learn more about xpath here:

http://msdn.microsoft.com/en-us/library/ms256090.aspx

 Bye,

 Jean

 

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Calling from an external Excel file to Playmaker Arrays
« Reply #14 on: October 01, 2013, 02:43:15 AM »
That did the trick, thanks!