playMaker

Author Topic: Get String Left working infrequently[SOLVED]  (Read 4968 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Get String Left working infrequently[SOLVED]
« on: March 27, 2014, 06:36:42 PM »
I use the Get String* actions a lot.  For some reason this one action is no longer working consistently for me.  I am simply trying to get 1 character from the left side of my string, and the action returns nothing (sometimes).  Sometimes it works.  Most of the time nothing.  It's driving me crazy.

Here is the string I am trying to parse:
Code: [Select]
------------------------Y-------------------------------------------------------------------EW--
That's it.  Very simple, single, unbroken line stored in an array.  The action should just return the first "-". 

Please someone give me a hand!

« Last Edit: April 17, 2014, 02:21:45 PM by jeanfabre »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Get String Left working infrequently
« Reply #1 on: March 28, 2014, 12:23:39 AM »
Maybe the action isn't firing? Is there another action higher in the stack that exits the state before the action fires?

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Get String Left working infrequently
« Reply #2 on: March 28, 2014, 12:47:06 AM »
No there isn't.  The string is generated from a text file which is parsed through Jeans ArrayMaker addon.  I split up the actions into separate states for easier debugging and here is the State in full:



I select the level in another GUI which pushes the string to a Global var for easy access, which you can see as the first action. 
Right away you can see the second action fails to catch the first left character of the string and store it.

My thought was that this might be a bug.  Maybe those dashes aren't typical ascii/unicode? 

Done this hundreds of times so it's pretty confounding!  :)

EDIT - Oh, and for sanity's sake, I have checked there were no spaces or garbage characters in the original string.
« Last Edit: March 28, 2014, 12:48:39 AM by artician »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Get String Left working infrequently
« Reply #3 on: March 28, 2014, 12:57:11 AM »
Strange... I did a similar test here and everything works as expected.

Can you copy/paste the string that you're using?

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Get String Left working infrequently
« Reply #4 on: March 28, 2014, 01:06:57 AM »
It's pasted in my original post which was straight from the text file.  Did you mean something else? 

Here it is again, just in case.

------------------------Y-------------------------------------------------------------------EW--

I have triple checked for this already, but if you don't find an obvious issue on your end I'll just nuke it and start over, as it's a relatively simple setup so far.

EDIT - One more detail: I'm focusing on this string because it's a 100% failure rate, whereas I have other very similar strings that are 100% success examples, and others that will error halfway through their parsing.  Here are some of them:
Code: [Select]
------------Y----------------------------------W---------------------------W-------E------------
------------B----------------------------------W---------------------------W-------E---W--------
------------?----------------------------------W---------------------------W-------E------------
------------Y----W-----------------------------F-----------------------E----W-------------------
--W------W----W--FF--W----W--F---W-------F------R----------E------------------------------------
-----------------------------------F------------Y------W---E-----------------------F------------
R-------F-------------------F------E---------------------F----F---------------------------------
------U--------U----U----U--------U----U----U---------U-----------------B----------E------------
------------------------------------------------------------------------------------B---WEW-----
B-W--------E--W-------------------WW------------------------------------------------------------
Y----------T-----------T-----------T-----------TWWW-WWW-WWWT-----------T--------F--T------E----T
R--------------------------W--W--W---------------W--W--W--W----------------W--W--W-------------E
-W---W---W-----W---W---W-W---R---W-----W---W---W-W---W---W-----W---W---W-W---W---W-----W---W---E
Y---F-------------------------F-------W------------W----F-------------WW-----W-----E------W-----
« Last Edit: March 28, 2014, 01:10:50 AM by artician »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Get String Left working infrequently
« Reply #5 on: March 29, 2014, 12:32:55 AM »
A simple test with that string seems to work fine.

Is the FSM on a prefab instance?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get String Left working infrequently
« Reply #6 on: April 01, 2014, 08:16:58 AM »
Hi,

 Can you attach the file itself? maybe a character is getting int he way of the file itself ( hidden/unsupported return char or some windows/mac transfer mess).

bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Get String Left working infrequently
« Reply #7 on: April 14, 2014, 05:37:27 PM »
Hi guys, sorry for the late reply. 

I've attached the text file in question, but I've done a number of things and don't think the string itself is the problem.  Is there something I should know about getting the variable from Index0 in my array?  I seem to recall having issues with other arrays before, where getting the first value would mess up somehow.

Thank you for your help.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get String Left working infrequently
« Reply #8 on: April 15, 2014, 11:00:14 AM »
Hi,

 no, you should/must be able to get index 0 of an array.

 what can happen tho is that you are messing indexes up in your logic.

 can you explain the process you are trying to achieve? is it like going trhough all characters and building object based on the character?

bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Get String Left working infrequently
« Reply #9 on: April 15, 2014, 02:15:49 PM »
Yes that's exactly what I'm doing.  I have a text string where each character is a different map object, and parse each character one at a time while moving through the map.

The way I move through the array is by using Array List Count to get the total number of entries in the Array.  Then I use Array List Get Next to move from Index0 to Index<Array Count Result>.

This works with all the other levels (there are 15).  It's just the first one that gets borked somehow.

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Get String Left working infrequently
« Reply #10 on: April 15, 2014, 07:32:03 PM »
I have been troubleshooting this like mad.  As a test, I used Get String Right instead.  It causes the same problem.  For some reason the string appears blank when I try to get 1 character from the end of it.


artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Get String Left working infrequently
« Reply #11 on: April 15, 2014, 08:23:24 PM »
I think I have a lead here, so if one of you fine gentlemen would give me your opinion I'd appreciate it greatly.

Here's what seems like is happening:

Most of the characters in my text are the dashes (-).  When I look at the string both in the original text file, or when it's stored in a string variable within Unity/PM, it looks correct. 

This time, while paused at runtime I copied the string from the PM string variable and pasted it into Notepad++ to compare it to the original strings, and this is where I saw the difference.  Instead of the dash, the first character of the string is replaced with this odd character (I can't even copy and paste it outside of npp, hence the screenshot):


I don't even know what this character is, but it only appears when:
1) The string is pasted from Unity into Notepad++
and
2) Only if the string is the very first one in the text file.

My guess is that this is an irregularity caused by my npp using UTF-8 encoding.  Sure enough, when I converted the text file to ANSI, the level loads correctly. 

I hope all the pain I went through here might maybe help someone else avoid a bug?  ;)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Get String Left working infrequently[SOLVED]
« Reply #12 on: April 18, 2014, 11:26:14 AM »
*bump*

Was this a thing?  What did I do wrong?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get String Left working infrequently[SOLVED]
« Reply #13 on: April 21, 2014, 08:31:49 AM »
Hi,

 you need to use an advance text editor so that you can properly save your text file with the right encoding.

bye,

 Jean