User Tag List

Results 1 to 7 of 7

Thread: How do I count how many actives meet a condition?

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Feb 2007
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I count how many actives meet a condition?

    Hi,

    I'm trying to count the number of actives that have Variable B set to 1.
    I could change it to a flag being true of whatever, that's not important.

    The thing I'm having trouble with is that I want to be able to count how many of these actives meet the condition I set.

    The aim is to show how many conditions have been met to give a score, this score will increase or decrease showing how many actives meet the condition. So the player must get ALL the actives to meet the condition to win.

    Any idea how to go about that?

    I was hoping I could do something simple like add each instance of Variable B together to get a value.

  2. #2
    Clicker Multimedia Fusion 2

    Join Date
    Jun 2007
    Location
    United States
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I count how many actives meet a condition?

    That will work perfectly. Depending on how many actives you have, increase their variable B by one when they meet the condition. Then in a global value have it always set to variable B + variable B + ... It should total to the amount of actives you have if you use the number 0 as false and 1 as true.

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Feb 2007
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I count how many actives meet a condition?

    I can't really use that.
    I need it to be able to add all the variables up automatically.
    I can't manually input each and every active object.

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Nov 2008
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I count how many actives meet a condition?

    Stick them all in a qualifier then, and program just once.

  5. #5
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Feb 2007
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I count how many actives meet a condition?



    Ok. I've got something working, but it's totaly broken as well.
    It can count up to about 4, depending on the order it seems.

    I want it to keep a real-time count of the smiley faces on screen.
    So if you manage to have 4 on screen at once it says 4, if that drops to 3 it says 3, if it increases to 6 it says 6.

    Can anyone help? I feel like I'm bashing my head against a wall here.

    View MFA

  6. #6
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Feb 2007
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I count how many actives meet a condition?

    I've managed to get it all working, but I have to manually add each variable from each object. e.g.
    Set Global A = Object1 Variable A+ Object2 Variable A+ and so on.

    Is there a way for it to...

    Set Global Variable A to (Variable B Object A through to Z)
    Where the total number of objects is unknown or expandable/shrinkable.

    I want it to be able to automatically count/add up the total number of objects that meet my criteria. So I could add more objects etc and it would still be able to get correct totals.

  7. #7
    Clicker Multimedia Fusion 2Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2010
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I count how many actives meet a condition?

    1) Add all objects to a single qualifier (if they're all the same object, just differnet instances of it, you can skip this)
    2) Add the event: [The condition upon which you want to update the count, or "Always" if you want it always up to date] --> Set [Variable] to 0 | Spread Value 0 in Alterable Value * of [Object/Qualifier] | Run loop "[LoopName]" Number of [Object/Qualifier] times
    3) Add the event: On loop "[LoopName]" | Alterable Value * of [Qualifier/Object] = Loop Index of "[LoopName]" | [insert the condition(s) you want to test the objects for here] --> Add 1 to [Variable]
    4) [Variable] now contains the number of objects that meet the condition

    Alterable Value * can be any alterable value of the object. Just make sure it's never modified by anything else.
    [LoopName] can be anything, something like "UpdateCount"
    [Variable] is the value you want the object count stored in. It can be a global value, an alterable value, a counter, even the player's lives/score if you really want.

    Basically, how this works is the Spread Value assigns a different ID number to each object, starting from 0, then the fastloop quickly runs through all applicable objects, testing each one individually for the conditions (it eliminates all but one in each iteration, by finding the one with the ID number that matches the number of loops so far performed, thus the actual checks are only performed on that single one).

    Thanks to fastloops, this will all be performed immediately.

Similar Threads

  1. Checking that all instances meet a condition
    By Keith in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 22nd August 2011, 01:07 PM
  2. Newgrounds count vs. mochi count
    By Tuna in forum SWF/Flash Export Module Version 2.0
    Replies: 9
    Last Post: 20th September 2010, 08:37 PM
  3. Count objects meeting a condition
    By Zoglu in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 26th August 2009, 04:35 PM
  4. [BUG] ODBC - Condition Get Rows Count
    By byo in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 10th January 2008, 09:15 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
  •