In need of a text string wizard .. building up a string of data that can be read back later.
I'm trying to figure out the best way to save the steps from a pathfinding search into a single string. I want to save it in a single string, to reduce the number of cells I'll be sending to my server. (See here for what I'm trying to do).
i.e
The string needs to be built up using some grid numbers i.e.
12,24,36,37,38,39,40,52,64,76,75,73
I know we have lots of text functions available now.
So my thinking is:
get the first step,
put into a table cell
get the next step
add it to the table cell by using
Change Table Value and adding to the value by concatenating using two dots '..'
(I assume I can use two dots to build up the string with each pass).
But then when I want to read the data back later I'm falling a little short on the best way to proceed.
Perhaps I should be adding a symbol in between each step that is added to the saved path cell. i.e. a12a24a36a37a etc..
Can I then use one of the functions to search for the first 'a', save any numbers found before the second 'a' to a table cell. Then search for numbers between the 2nd and 3rd 'a' and repeat until no more a's can be found.
... Anyone done something similar.
If it's not possible, way too complex or slows down the game too much. That's fine and I'll just have to have a lot of columns to store each step (and make sure I have enough columns).
Cheers
Jon
Comments
PM sent
I had to solve a problem like this very recently, but coming from the opposite direction - I had string with spaces in them and needed to change all characters except the spaces (and couldn't just use a replace function so had to pull the characters out of the string and put them into a new one). The end result was that it wasn't too difficult to read over the string and pull out the non-space characters, concatenating them into a new string (.. does work). So what you're seeking to do should be very much possible and I saw no noticeable processing time working with up to about 70 characters.
I'd imagine it would be easier to work from the end of the string to the beginning, though, trimming it down each time. You'd not really even need any special characters if you're looking at always pairs of numbers. If you can get your head around working in reverse with the string it should be pretty each. (Of course you can always do it from the beginning but it'll be more wasteful.)
If you are seeking the 50th pair of numbers, you just need to get characters 100 and 101, so depending on exactly what you need to do when reading them back you'd probably not even need to do that much.
To be honest I'm exhausted and not really sure what you're wanting to do, but I am sure it's very much possible with the awesome new text functions we have.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I would use a symbol and search for its location each iteration of a loop. I'll see if I can make you a demo.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks @Armelline
Thanks @tatiang
@Fajlajp has come to the rescue.
Once I get my head clearly around a couple of the text functions all should be fine.
Here's the doc I can never find when I need it. which describes some of the potential uses of the new text functions.
http://gsdc.gamesalad.com/2014/01/30/17/19/52/28/NewFeatures_JS_v5.pdf
If you haven´t checked out the new text behaviors, do that. Without them I would never been able to help StormyStudio. I just love them. Great job gsteam adding them
This is a working demo but it's not as generalized as I'd like. For example, it currently only works for value lengths of 2 (2-digit numbers). It's possible and not terribly difficult to add another textFind() function to the existing functions in order to allow for values of any length but I didn't go through that process.
http://forums.gamesalad.com/discussion/comment/476966/#Comment_476966
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang
Sent you a pm
@Armelline @Fajlajp My method is certainly not the best one out there... if you have another way to do this you might want to post a demo here.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Just a very rough example, but this one shows an easy way to take any string and print it to the log in whatever substring lengths you desire, and can work with only two attributes - the one holding the string to be split and one to iterate the loop (though the code would need adjusting to remove the length attribute currently being used).
Edit: Oh, and you don't click to parse the string any more, it happens on load.
Edit edit: Oh and I suck badly at maths so a maths wizz is encouraged to trim down the function, I'm sure it's possible
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Hmm.. does anyone know of a way to search a text string and return the number of a particular pattern or character that appear within it?
i.e.
how many "!" appear in 1!2!3!45!67!99!100304!
Does it need to be counted before you retrive the data from the string?
You could probably use textFind() in a FastForLoop to do it.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
@colander yeah I thought about the loop, but that would kinda lose the tiny speed increase I was looking for.
@Fajlajp
I was kinda hoping there might have been an expression I could'nt find.
It would be handy to know the number of ! straight away, so I know how many steps there are going to be instantly. It's not that bad as it is.. but just thought if there was a speedy expression I was missing out on it would make it all the sleeker.
Since you only use numbers, remove the numbers 0-9 with textReplaceAll in 10 consecutive steps, then use the textLength to see what is left over.
That will give you the answer in one game cycle.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
I use a loop to tell how many of a certain vowels there are in particular hidden puzzle in my word game. Every time it hits a predetermined vowel, it adds 1 to. An attribute. Usually there are just one or two vowels that I need to find, so the loop doesn't even go for half a second. Way less, in fact.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
If you want a demo, let me know
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
On a side note, it would be incredibly helpful if we had some option to tell how many of x are in a table row or column. It'd be just like tableSearch, and would return an integer value. I could think of lots of uses for this.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Cheers @Hopscotch I might give that a whirl.
@Braydon_SFX thanks for the offer mate. Should be good now.