User Tag List

Results 1 to 5 of 5

Thread: Count and display values from an array

  1. #1
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jun 2015
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Count and display values from an array

    I'm having troubles at counting and displaying values from an array, this is what I'm doing:

    Let's say this is the first row: (1 1 1 1 1 1 4 4 4 2 2 2 3 6 6 6 5 1 1 4)
    I want to display how many <n>s are in a row. In this case it would be:
    First we have 6 1s, so it should show: 6 1
    Then we have 3 4s, so it should show: 3 4
    After that, we have 3 2s, so it should show:3 2
    Then it would be 1 3, 3 6, 1 5, 2 1 and 1 4

    It doesn't matter where it displays this info, it could save it in another array with 2 columns, or display it in counters but I have no idea how to count it the way I want (the best I can do is to count how many of the same number are in the same row, but that's not what I'm looking for). Is there any tutorial/example to do this?

    Thanks in advance, and I'm sorry for my broken english (my first language is spanish).

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    If I understand correctly,
    it should count how many numbers are equal for each "group" of numbers, before another "group" comes in, right?

    I'd say looping the row and taking into account current number you're checking would work,
    let's say we display results in a list,
    it should look something like this:

    on triggering event initializing count
    >>> set value.currentX (a variable of your choice) to 0 (the X array row you will check. If you need to do this for all the array, you'll have to loop this process)
    >>> set value.currentN to valueat(currentX,0) (set this variable to the number stored in the first array position)
    >>> start loop "read_numbers"

    on loop "read_numbers"
    +valueat(loopindex("read_numbers")+1,currentX ) = currentN (following element equals number we're checking)
    >>> add 1 to numbercount (a variable holding count of equal numbers)

    on loop "read_numbers"
    +valueat(loopindex("read_numbers")+1,currentX ) <> currentN (following element different from preceeding)
    >>> add line (to the list) "number:" + str$(currentN) + " count:" + str$(numbercount)
    >>> set numbercount to 0 (reinitialize count)
    >>> set currentN to valueat(loopindex("read_numbers")+1,currentX ) (reinitialize current number we're checking)

    Penned it down without actually checking, easily there will be something to fix,
    but as a general idea this should work (I guess )

  3. #3
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jun 2015
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried something similar but fusion crashed I think I screwed up the loop and made it infinite. I will try this, thanks!

  4. #4
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jun 2015
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    UPDATE: It worked!

    I had to change a few things, but it worked just like I wanted it to. Thank you very much!

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module

    Join Date
    Nov 2011
    Location
    Melbourne, Australia
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could you post an example .mfa file? I started a new topic on arrays before reading this one.

Similar Threads

  1. Display object after count issue
    By koltzc in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 3rd January 2013, 02:13 PM
  2. Summing the values of an array
    By fawfulfan in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 18th July 2012, 08:14 PM
  3. Global Values Display
    By Boba Fonts in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 20th May 2012, 08:08 PM
  4. Alterable Values in Strings & best way to display
    By rubes in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 6th May 2012, 12:01 AM
  5. Display values on screen from Alterable Values
    By mikeh in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 13th May 2008, 02: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
  •