Find every instance in an Array

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I have a 128 x 64 array, and I want to loop through and find the X & Y dimensions of every entry equal to a specific value. So for example if the array contained the number "7" at indexes (1,10), (1,25), (5,10) and (32,64), then those array positions would be recorded into like a rich edit box, let's say.

    So at the moment I have:
    * Button clicked
    > Start Loop "vertical" 64 times

    * On Loop "vertical"
    > Start Loop "horizontal" 128 times

    * On Loop "horizontal"
    + ValueAtXY( "Array", LoopIndex("horizontal"), LoopIndex("vertical") ) = 7
    [Rich Edit Object] > Str$(LoopIndex("horizontal")) + "," + Str$(LoopIndex("vertical")) + ","

    Trouble is, I'm not getting anything. If I remove the 2nd condition under "On Loop horizontal" then sure enough, it appends every single loop index to the text.
    So the comparison condition doesn't work.
    Anyone know a better way to do this?

    .: Nuclear Powered Games :.
    coming soon...

  • Your pseudocode should work, its how you would iterate over a 2d array and compare values. Without seeing your code, one possible culprit is how your array object is configured. Is it set to be a text array or number array? Base 0 or base 1? Does it have its x/y/z bounds set properly? If its a text array, it won't return values direct, but you could convert the string to a value

  • Thanks NaitorStudios and Pixelthief. You were right - my code was fine, it was a small oversight with the "type" of array the object was set to. Changed it from Text to Numbers and it worked right away.

    .: Nuclear Powered Games :.
    coming soon...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!