User Tag List

Results 1 to 4 of 4

Thread: Possible to search an array for all rows containing a specific string in an element?

  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
    Aug 2020
    Location
    Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Possible to search an array for all rows containing a specific string in an element?

    Hello

    I was hoping to see other ways people have accomplished something like this:

    Theoretical game requirement using Pokemon as an example

    - an array of enemies, with a value defining the type of each enemy

    Type, Name, Stat1, etc

    Grass, Venosaur, 10...
    Grass, Snivy, 5...
    Fire, Charizard, 10...
    Normal, Toucannon, 10...

    If I wanted to, during an encounter event, only allow the "spawned" Pokemon to be of Grass types, this is how I would do it:

    - ForEach loop checking rows in the array
    - an If event in the loop checking if the string in column 1 of the current row is "Grass"?

    That would be using a standard array or a magicDeque object.

    Or are there other objects that can accomplish it better?

    Coming from Powershell in my professional life, forEach is a superbly useful function, but I know it can slow down unless you narrow the scope a bit on a big operation. Since this isn't a big operation (in my project it would maybe have 100 rows to go through) then it shouldn't really pose any big performance issues should it? There may a couple of other similar loops for other things at the same time during loading of the frame.

    On a side note, I found after years using Powershell extensively, the object oriented experience in Clickteam really, uh, clicked with me.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleUniversal Windows Platform Export ModuleSWF Export Module

    Join Date
    Jun 2014
    Posts
    65
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    As per your Pokemon example, what I would do is group the pokemon in the array by type....i.e have all grass pokemon in array slots (assuming x = column & Y = row) Y : 0-19, fire type 20-39, normal type 40-59 etc (the numbers are arbitrary), so then you know that iterating through certain regions will return only those pokemon of that type. I don't know if that's going to be much use for your purposes but that's how I would approach it.

    100 rows isn't a lot, but the overhead is mostly going to come from the string comparisons. It might also be a good idea if you can somehow use numerics to represent all the different types of information while you're iterating through it. Numeric arrays are nominally faster than text/hybrid arrays & the options for comparing string/chars can get a little messy if you're doing it many times for multiple objects.

  3. #3
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    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)
    Phi's Avatar
    Join Date
    Jan 2010
    Location
    England
    Posts
    1,978
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Consider using ArrayX, which has search functionality.

    Otherwise, Ini/Ini++ might be more suitable for you to use; you can store multiple items per group, as a sort of tree but with named branches. It'll be far more readable.

  4. #4
    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
    Aug 2020
    Location
    Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey these are both great suggestions. Thank you!

Similar Threads

  1. Search inside array for specific value?
    By PandaExplosion in forum Fusion 2.5
    Replies: 2
    Last Post: 30th December 2019, 05:01 AM
  2. Deleting Rows in Dynamic Array
    By ayejes in forum Fusion 2.5
    Replies: 0
    Last Post: 3rd June 2018, 09:24 PM
  3. String Parser empty element?
    By crugh in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 13th February 2017, 02:01 AM
  4. How do I switch two rows of an array?
    By lootercuster in forum Fusion 2.5
    Replies: 10
    Last Post: 5th May 2015, 10:40 PM
  5. How to search a specific global value?
    By Decoamorim in forum Fusion 2.5
    Replies: 5
    Last Post: 30th August 2014, 03:25 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
  •