playMaker

Author Topic: TextAsset loaded from Resource folder  (Read 11697 times)

Xtopher

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 71
    • Well Played Games
TextAsset loaded from Resource folder
« on: October 21, 2011, 09:53:42 PM »
Has anyone done anything with this?  I would love to see action(s) to load a .txt file from the Resources folder, and also to read through lines, save as string, etc.  I poked at it a bit but was getting some errors using TextAsset, and haven't gotten back to it.

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Re: TextAsset loaded from Resource folder
« Reply #1 on: December 02, 2011, 03:08:27 PM »
vote +1

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: TextAsset loaded from Resource folder
« Reply #2 on: December 07, 2011, 05:08:54 AM »
Hi,

 I've done just that on another post using a modified version of arrayMaker (  update soon available), that basically takes a textasset, and split each lines into an array. Stress test: 58000+ lines, works like a charm!

http://hutonggames.com/playmakerforum/index.php?topic=891.msg3666#msg3666


I'll see if I have time this week to add a simple action to parse a textAsset into a fsm string var, but really I don't see much use of this to be fair, unless you can explain what you are after really, then I'll be in a better position to match your needs.

Stay tuned :) hopefully, I'll have time to make that arrayMaker update available before the end of this week. I also have at the back of my mind a xml parser and a .csv parser very much like arrayMaker that would allow you to work right within playmaker with xml and csv content, that would be so useful!

 Bye,

 Jean

Mark_T

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 72
Re: TextAsset loaded from Resource folder
« Reply #3 on: December 27, 2011, 11:43:11 AM »

+2

@jeanfabre
I think such an action it might be really useful.
I see it as a "TextFile2Vector3" action, where you can have the 3D coordinates in a text file and convert a line into a vector3.
Using a int variable, you can choose which line to convert, you can store loads of vector3 coordinates into a text file. Updating/managing this way a vector3 variable you can avoid a lot of manual work. For me, as a non coder, a simple text file is easy to read and understand (see the attachment). Three float values separated by one space/line = one vector3 variable value.
Or as a "TextFile2String" action. Convenient to manage big chunks of text?

I would love to have these 2 actions. :)
Anyway, thanks a lot for all your contribution here.

Take care.

P.S. - I`m still very happy for the "Get Animation Time" action. :)




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: TextAsset loaded from Resource folder
« Reply #4 on: December 28, 2011, 03:34:56 AM »
Hi Mark_T

 The thing is with that kind of queries is that you need to see it from a generic point of view. Today you want to parse text into a vector3, this is fine, tomorrow you'll want to parse vector2 and in a week you'll want to convert a combination of them.

 If I write an action that parse a textfile specifically for vector3 in that specific format, this is a lot of time spent in developing for a very narrow need.

 So from a generic point ( read reusable and more flexible) of view here is how I would tackle your need:

1: With the current state of arrayMaker and its new addition to parse lines into an array, you are then only one action away to get to your vector

2: I wrote few days ago an action that convert a vector 3 to string. Now we simply need to reverse this action and convert a string to a vector 3.
http://hutonggames.com/playmakerforum/index.php?topic=921.0

 This means that for your need, we really only write one specific action. I would even go further and maybe consider actually conforming to this above action, so that your text file is made of lines such as

Vector(-0.05288386,0.8564703,-0.5134802)

It is of course not mandatory, and depending on the number of lines, you might want to save the extra number of characters compare to just have space delimited numbers. Or we could enhance this actions by choosing amongst different format and why not have some regex possibilities :) but that would be already for quite advanced users, cause if you are not aquaincted with scripting, regex is a foreign language too...


Allow me few days to write something for your need ( unless someone lelse step in of course). Meanwhile you could try if you are willing to give it a go, try to reverse this vector3toString for fun.

 The big picture is of course to provide such things built the csv and xml parser and why not the arrayMaker. But one step at a time :)

 Bye,

 Jean

Mark_T

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 72
Re: TextAsset loaded from Resource folder
« Reply #5 on: December 28, 2011, 07:18:57 PM »
Hi Mark_T

 The thing is with that kind of queries is that you need to see it from a generic point of view. Today you want to parse text into a vector3, this is fine, tomorrow you'll want to parse vector2 and in a week you'll want to convert a combination of them.

 If I write an action that parse a textfile specifically for vector3 in that specific format, this is a lot of time spent in developing for a very narrow need.


Very true
The way I described it, it`s just according to my actual needs (and knowledge).
And of course, I can not guarantee, tomorrow my needs will be the same.  :)

Quote
So from a generic point ( read reusable and more flexible) of view here is how I would tackle your need:

1: With the current state of arrayMaker and its new addition to parse lines into an array, you are then only one action away to get to your vector

2: I wrote few days ago an action that convert a vector 3 to string. Now we simply need to reverse this action and convert a string to a vector 3.
http://hutonggames.com/playmakerforum/index.php?topic=921.0

 This means that for your need, we really only write one specific action. I would even go further and maybe consider actually conforming to this above action, so that your text file is made of lines such as

Vector(-0.05288386,0.8564703,-0.5134802)

It is of course not mandatory, and depending on the number of lines, you might want to save the extra number of characters compare to just have space delimited numbers. Or we could enhance this actions by choosing amongst different format and why not have some regex possibilities :) but that would be already for quite advanced users, cause if you are not aquaincted with scripting, regex is a foreign language too...


Allow me few days to write something for your need ( unless someone lelse step in of course).

That will be brilliant.
Do you think it will be possible to chose which parsed line in array to convert to vector3 using a int variable?
Haha, I found your "Vector3toString" action and I laughed to myself saying that this one it`s pretty close, maybe a bit reversed? :)
Browsing the forum is one method to learn, and of course, to see what goodies I might find. :)

Quote
Meanwhile you could try if you are willing to give it a go, try to reverse this vector3toString for fun.

 The big picture is of course to provide such things built the csv and xml parser and why not the arrayMaker. But one step at a time :)

 Bye,

 Jean


Yep. And maybe ArrayMaker too.

Thanks a lot for your answer. I really appreciate it.

Take care.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: TextAsset loaded from Resource folder
« Reply #6 on: December 29, 2011, 12:59:57 AM »
Hi,

Quote
Do you think it will be possible to chose which parsed line in array to convert to vector3 using a int variable?
not sure what you mean. If not all your lines are vector3 then several options I can think off:


-- parse on demand action, when parsed once the vector3 is then stored in place of the string equivalent so that next time it is already a vector3 ( one action only for this)

-- create a csv file instead, were the first column is the variable type, and the second column is its string representation. Easy!

-- if you use lines with strings like "Vector3(1.0,1.0,1.0)" then you don't even need to say anything, a custom action can detect that and make it as a vector3. same with "12.0" or "2" or "Vector2(1.0,1.0)" etc etc

 Bye,

 Jean

Mark_T

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 72
Re: TextAsset loaded from Resource folder
« Reply #7 on: December 29, 2011, 01:49:33 AM »

I didn`t have time to look into ArrayMaker. I have the feeling that I`m missing something.
As I initially described, I want to have the control which line from the text file (in the format you mentioned, "Vector3(1.0,1.0,1.0)") I will use at a given time in the game.
I was thinking to store an integer into a variable, and that integer will point to the coresponding line in the text file. If the value of the int variable will be 7, than line nr. 7 will be converted into the vector 3. If the int variable will be updated to a different value, lets say 26, than line nr. 26 will be converted to vector3, and will replace/update the initial vector3 value(also stored into a variable).
I`m not sure, but I think is the last case you described.
Thanks.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: TextAsset loaded from Resource folder
« Reply #8 on: December 29, 2011, 05:23:41 AM »
Hi,

 ok, here we go: http://hutonggames.com/playmakerforum/index.php?topic=967.0

now you have everything to achieve what you want,

1: get arrayMaker
2: put your file content in an array
3: build an fsm that access one of its item ( be careful, the first item is 0, not 1)
4: parse the string using stringToVector3 ( WITH ANY FORMATING :) )
5: inject back the vector3 result into the same item

Done


When I say "any format", I do assume few things tho like the dot notation of floats and stuff. If you encounter problems, let me know and see if this is solvable.


 if you have any question or problems with this routine and process, let me know, I'll help you out.

 bye,

 Jean

Mark_T

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 72
Re: TextAsset loaded from Resource folder
« Reply #9 on: January 11, 2012, 11:44:41 AM »

Jean, I done it. :)
And is working brilliant. fast like helll!!  ;D
Again, many many thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: TextAsset loaded from Resource folder
« Reply #10 on: January 12, 2012, 02:31:45 AM »
Excellent news. I am glad you managed!

Bye,

 Jean