I am creating a script that is required to check if the the X or Y position of sprite minus the absolute value of anything in a list is is less than a particular value (The x or y for one of the clones, stored in a list) for calculating distance. the equation could be represented like this:
|x|-|o|<d where x is the current x/y position of the main sprite, o is the position of any of the clones, and d is whatever distance I set. So, for the equation |50|-|45|<10, it would return true. I know what the equation needs to be but am unsure how to represent it with the current list blocks (perhaps (list) contains ()?)
I tried using the (list) block but that block does not work for my purposes as that is not what it does. I have failed to use the (list) contains () block, although that may be what I need to use.
If I understand correctly, you have the clone X and Y positions stored in lists, and you want to use the list values to check if the sprite is within a certain distance of any of the clones.
I believe what you want is the scratch equivalent of a for loop. You can use a "repeat until" loop and a dedicated variable for the loop counter. Something like this:
Here, the index variable will go from 1 to the length of the position lists. For each index, it checks if the abs of the difference between sprite's position and the coordinates at that index in the lists are lower than the distance you specify.
This is also assuming you're doing something like this to keep track of the clone indexes:
The "clone id" variable here is "for this sprite only", so you have to increase it by 1 each time before you make a clone, not after. That way each clone will remember its own ID.