User Tag List

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

Thread: Retrieving info from list

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Oct 2021
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Retrieving info from list

    I can not figure this out, no matter how hard I try.

    How do I retrieve the coordinates left of the comma, from a line in a list: 3,127

    I want to return only the 3 with an expression, but I always get syntax error, or too many closed brackets, or mixed strings and numbers.
    I figured I should use Left$, and find string within string, but I simply cannot get it to work! Not even ChatGPT can answer, I hope you can.

    Thank you for the help!

  2. #2
    Clicker Install 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)Firefly 3D Module (Steam)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    613
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    1. Use find to get the position of comma
    2. Use left to get 3 base on previous return
    3. Use val to convert 3 to number

    Nest them to return by one expression.

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Oct 2021
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Quote Originally Posted by defisym View Post
    1. Use find to get the position of comma
    2. Use left to get 3 base on previous return
    3. Use val to convert 3 to number

    Nest them to return by one expression.
    what is 3 base?

    Also, could you write it out? I tried so many combinations and nothing worked.

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Oct 2021
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Left$(List Line Text$( "Pathfind - Frontier list", 1 ), FindString(List Line Text$( "Pathfind - Frontier list", 1 ), ",") - 1)

    this returns syntax error

    also, if i reverse the findstring and comma (",") search, i get too many closed brackets.

  5. #5
    Clicker Fusion 2.5 DeveloperHTML5 Export Module

    Join Date
    Jun 2006
    Posts
    1,523
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)

    Do it in pieces.

    Your expression is long and complex. Try doing it in pieces. The put pieces together to get final results.

    I have had to do this with some of my programming.

  6. #6
    Clicker Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Oct 2021
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Turns out this was a bug, it had nothing to do with my expression. HOW FRUSTRATING! If you don't have the object as a "current object" in the expression editor, you can not use their values when writing syntax!

    For anyone looking to do pathfinding using Breadth First Search algorithm. Here is the way you input your coordinates into an array from a list that stores coordinates in the form (x,y). This code removes the comma, and splits the x and y into their respective counterparts in the array system. This will always pull from the first line, which is what you want, so you can then delete it, and keep iterating through your queue.

    ValueAtXY( "Pathfind - World Array", Val(Left$(List Line Text$( "Pathfind - Frontier List", 1 ), Find(List Line Text$( "Pathfind - Frontier List", 1 ), ",", -1))), Val(Right$(List Line Text$( "Pathfind - Frontier List", 1 ), Len(List Line Text$("Pathfind - Frontier List", 1)) - Find(List Line Text$("Pathfind - Frontier List", 1), ",", -1) - 1) )

    The BFS algorithm is great for building mazes that have guaranteed entrances and exits, RTS or point-n-click movement, and so on.

    Here is an example of how you add things to your frontier list, that you then pull from when starting to execute the algorithm.
    Str$(Current Tile X( "Player" ))+","+Str$(Current Tile Y( "Player" ))

    Use number of lines in list >0, to keep the algorithm going.


    *EDIT, CODE IS NOW CORRECT*

  7. #7
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)iOS Export Module (Steam)
    Linky's Avatar
    Join Date
    Mar 2020
    Location
    Egypt
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, the solution to this problem is actually way simpler than it first looks, the wordy expressions just make it look scarier than it should.
    First, to achieve what you want, you will only make use of two main expressions. Left$ and Find, if you do not already know, please note that need to type anything yourself, these expressions are always available from the special object (the gear icon) in the Expression editor Window and can be retrieved by just selecting them via your mouse (Special Object > Strings)
    I do not recommend typing expressions yourself unless you are really used to them, because you can get a syntax error very easily and not know what to do
    Left.png
    Also, if you don't already know: Expressions return something to you, and some expressions require more info so they can return something to you, these are called parameters, you can cycle between parameters by pressing tab.

    The main idea is to retrieve a specific amount from the left side of the string, in this case, that's what the Left$ (Extract left sub-string) Expression is for:
    • extracts a sub-string from the given string, starting on the left. Example, LEFT$("Hello", 3) will return "Hel".

    It takes two parameters, 1: the string that you are going to retrieve a part from, 2: the number of characters to retrieve.
    Left$.gif

    So for example, Left$("3,127", 1) will return "3"
    But here is the thing, what if you dont know how many characters to retrieve before the comma? well, simple really, we just Find the index of the of the comma.

    Thats what the Find (Find String in String) Expression is for:
    • returns the 0-based index of a sub-string in the string. Parameters = string to look into, sub-string to look for and index of the first character to start the search from. Returns -1 if the sub-string is not found in the string.


    So for example, Find("3,127", ",", 0) will return 1 (NOT 2, because its 0-based index)
    When combined with the Left$ expression, the full calculation: Left$("3,127", Find("3,127", ",", 0)):
    Expression.jpg
    Now, this should work, the whole calculation will return "3", for Left$("32,127", Find("32,127", ",", 0)) will return"32" etc...
    But this probably looks a bit unreadable and confusing already, and it will only get more complex when you replace the hardcoded string with the one retrieved from a list line, which is done by another wordy expression that will make it even bigger, less readable, and overall, more complicated than it actually is.
    One way to fight that, is by splitting your event int step, and storing each step in a values, like this:
    Values.png
    Steps.png

    In your case, you would just set IN variable to the specified line data instead of "3,127"
    Hope this helps clear it up for you

  8. #8
    Clicker Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Oct 2021
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, thank you so much! I'm going to have to look into that last part, once I'm done with this BFS, I'm all for automating things with values. Thanks a lot for the lengthy response!

  9. #9
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)iOS Export Module (Steam)
    Linky's Avatar
    Join Date
    Mar 2020
    Location
    Egypt
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, and btw, one of the gifs are broken, because for some reason the forum converted it to jpg...
    This is what should have displayed:
    FullExpression.jpg

    Edit: Its still broken...
    Check this instead: https://drive.google.com/file/d/1Fo1...usp=share_link

  10. #10
    Clicker Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Oct 2021
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Made an error earlier when I explained the BFS string stuff. It's fixed now.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Retrieving a random value
    By wererabbit in forum Fusion 2.5
    Replies: 4
    Last Post: 27th October 2017, 10:14 PM
  2. [Info] New extension list XNA specific
    By Fanotherpg in forum XNA Export Module Version 2.0
    Replies: 4
    Last Post: 26th January 2012, 10:17 PM
  3. [Info] New extension list iOS specific
    By Fanotherpg in forum iOS Export Module Version 2.0
    Replies: 2
    Last Post: 8th July 2011, 10:16 PM
  4. [Info] New extension list Android specific
    By Fanotherpg in forum Android Export Module Version 2.0
    Replies: 2
    Last Post: 8th July 2011, 10:16 PM
  5. Retrieving line info
    By Spottiswoad in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 12th June 2011, 11:59 PM

Posting Permissions

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