User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Question about strings

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module
    Angry_Dwarf's Avatar
    Join Date
    Dec 2013
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about strings

    Been scratching my head trying to figure out how to do this.

    Basically what i want to do is take a string and break it into individual letters, then assign the individual letters a value. kinda like this.

    Player inputs string "Jason"
    break the string into individual letters j a s o n
    assign numerical value to letters a=1 b=2 c=3 d=4 etc...
    so output displays "Jason" as a number.

    any help would be appreciated.

  2. #2
    Clicker Fusion 2.5 DeveloperSWF Export ModuleXNA Export Module
    Chloe's Avatar
    Join Date
    Sep 2012
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm curious as to why specifically you need to do that. Not saying that to be rude, just indicating that there may be an alternative solution given the end goal.
    The first part is relatively easy, getting a string. The second part can be achieved by using the Mid$("string"#,#) function (whereas you'd place the string int he string section, the first character (starting from 0) and how many subsequent characters, for instance Mid$("Jack" 2,1) would return the letter c).

    I would say you could grab them each with a fastloop, start the loop with the Len$("string") function as the number of loops (will return the length of the string). Then on each tick of the loop, with a single dimensional array, you'd store Mid$("string" loop index("loop"),1) at the array position of the loop index.
    Then you'll have each character stored in an array at a separate position. Once the loop has completed, you can start a second loop (again, the number of times based on the length of the string) that will convert the letters. On each tick of the loop (using the 'compare two general values' function in the system commands category) compare the letter at array position of the loop index to a letter, then either storing it in a second array, or recording over the current array, change it to the corresponding number. This is kind of tedious as you'll need to do a separate event for each letter. Then finally, you'll start the final loop (set to the length of the string, yet again) which will set a string to string+str$(value at loop index), so it will take the current number and just keep adding it until the loop finishes.

    I wrote this out as I was solving the issue in my head. There may be a better solution, but without actually loading up fusion and throwing it together, that's what I've got. If you had trouble following any of that, don't hesitate to scream at me.

    EDIT: Yep, just thought of another solution, give me a second and I'll type it out.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module
    Angry_Dwarf's Avatar
    Join Date
    Dec 2013
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks for the help Chloe.

    i'm trying to create a semi random seed generator for a game that i'm building. so that when a user inputs there world seed name it converts it to a number which i can then use to call the individual zones.

    Edit: just a quick example of how i will use it

    say there will be 26 zones. one for each letter of the alphabet.
    and they will be place in a 3x3 grid, so that say they use "myworldone" it would convert it to to a number say "812571281" (not exact just a example) then put that into a grid to have a semi random world created when the player first starts a game.

  4. #4
    Clicker Fusion 2.5 DeveloperSWF Export ModuleXNA Export Module
    Chloe's Avatar
    Join Date
    Sep 2012
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I have a better solution that uses just one loop and no arrays. Just a string and an edit box (or whatever you use to capture your text). Masked edit might be good to filter out using numbers, or to make it case sensitive.

    When you trigger the conversion (to test, you can just place down a button and say "when button clicked") Set the alterable string of the string to "". Then start a loop Len$("editboxtext") times.

    On each loop, do a compare two values event, and compare the Mid$("editboxtext" loopindex, 1) to a letter (for example "a"). If you wish to do the same number for specific cases, add an OR condition, then the same, loop then the Mid$, only this time the upper case version. In the actions, set the string to alterable string+desired number. Then just repeat for each letter. Simple.

    Hope this works well for you, and good luck on everything else.

    EDIT:
    Threw together a quick example for if you get lost.
    https://www.dropbox.com/s/gbmmy5ku2944e97/example.mfa

    In this one, I added a second string, mostly because I wasn't thinking about editing the string, when you click the button it basically just sets the edit box text to the other string, and I didn't feel like going back through all that code a second time.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module
    Angry_Dwarf's Avatar
    Join Date
    Dec 2013
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Chloe that was really helpful. I was trying to figure out how to do that all day.

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just wanted to pitch in seeing as that is quite a few events, if you wanted to do it in just two events it would look like this: https://dl.dropboxusercontent.com/u/...ingexample.mfa

    Basicly you just need to setup the alphabet in the Active as in example, then just find a string based on the name in the alphabet string to give you the index of it to make up the numbers...

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module
    Angry_Dwarf's Avatar
    Join Date
    Dec 2013
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll try that too Skyhunter, thank you both for helping.

    also i may be blind but i cant find any reference to these functions in the manual, is there a complete reference to all the functions that work in the expression editor?

  8. #8
    Clicker Fusion 2.5 DeveloperSWF Export ModuleXNA Export Module
    Chloe's Avatar
    Join Date
    Sep 2012
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's brilliant Skyhunter, I was not aware that existed. I've run into a few similar situations to that, so I'm glad to see there's a neater solution.

    As far as the manual goes, I'm not sure. I don't think I've ever actually read the manual, as I'm an old lady and I've been using this software since Klik&Play, so I couldn't tell you. Most of what I know is from then, playing around with stuff and looking at other's source code. On occasion I'll look at example files, but I only read the specific 'manual' on objects I'm having trouble working with. But, usually if I have an issue, I post here or on TDC.

  9. #9
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    England
    Posts
    3,513
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Nice work, Skyhunter.

    Quote Originally Posted by Angry_Dwarf View Post
    also i may be blind but i cant find any reference to these functions in the manual, is there a complete reference to all the functions that work in the expression editor?
    The expression is: string$( "String 2" ) + Str$(Find(Alphabet( "Active" ), Upper$(Mid$(Edittext$( "Edit Box" ), LoopIndex("gen" ), 1 ) ), 0 ) + 1 )

    The instructions for each expression are on a per-object basis:
    * string$ is listed as 'Alterable String' under "The String Object - Expressions" (\Help\String.chm)
    * Str$(), Find(), Upper$, Mid$ and LoopIndex() are listed under "The Special Object - Expressions" (\help\Special.chm). LoopIndex() is listed as 'Get loop index' under 'Fast loops'
    * Edittext$ is listed as 'Get Text' under "Edit Object - Expressions" (\Help\Edit.chm)
    * Alphabet( "Active" ) is the name given to that particular Active object's alterable string A, which has been configured to contain the alphabet, and is therefore an expression to retrieve that alterable string from that object. Retrieving alterable strings should perhaps be described under The Active Object - Expressions (Help\Active.chm) but it seems slightly outdated and only talks about alterable values.

    P.S. Rather than putting the alphabet as an alterable string of an Active object you could just write it in the expression directly, e.g. replace Alphabet( "Active" ) with "ABCDEFGHIJKLMNOPQRSTUVWXYZ". Doing it using a global string or alterable string makes it easier to change in the future if multiple expressions are using the alphabet and makes the expression less cluttered.
    .:::.Joshtek.:::.

  10. #10
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys for positive feedbacks
    Angry Dwarf, if you want i will explain the expression a bit more:

    1st run a loop length of name times

    -on loop
    First part is getting the next letter in the name: I am using Mid$( editbox , loopindex, 1) that means im extracting from editbox, loopindex just tells me the current index of the loop and tells the position of the next letter, and 1 it extracts just one letter from that position. Then i put Upper$() on all that, that just makes it an Uppercase letter.

    Then i use Find("Alphabet", "First part", 0)+1, That is Find string in string, that expression returns the index(position) of the found string in the string searched, searching in Alphabet using the letter i retrived with First part, and just add that returned index as a number to the generated string... also there is a +1 at the end of it, that is just to make A = 1 instead of 0 etc... The last 0 in Find expression you dont have to worry about, it just makes the search start from 0 = first charachter...

    Also all these expressions used are in the special object.

    Hope that helps a bit

Page 1 of 2 1 2 LastLast

Similar Threads

  1. question about alterable strings
    By Gustavo in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 25th February 2012, 11:27 PM
  2. question about writing strings
    By Gustavo in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 26th January 2012, 04:47 PM
  3. A very quick question about strings
    By pikzilla in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 7th December 2011, 11:44 PM
  4. Quick Global Values/Strings Question
    By CBSection31 in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 28th August 2010, 12:06 AM
  5. Strings Question (Now Sorted)
    By Atom in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 6th August 2009, 10:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •