|
|
Line 1: |
Line 1: |
| This is a flavour of the [[0x001f|Set to Next (0x001F) primitive]]. | | This is a flavour of the [[0x001f|Set to Next (0x001F) primitive]]. |
| | | |
− | This particular enumeration works a little differently from the others. | + | This particular enumeration works a little differently from the others because it will [[Set to Next never returning False|never return false]]. |
− | | + | |
− | With most 'Set to Next' enumerations, we can keep calling 'Set to Next' in a loop until it returns false and we know that we have been returned each of the things that match the criteria we are using. With this one however, it is not able to return false to tell you that you have seen everything. It will loop round forever (but for the "Too Many iterations" error which will save you). This means you should remember the starting point before calling this flavour of 'Set to Next' and after each return True, check to see whether you have got back to your starting point and if so act accordingly, as if it had returned False.
| + | |
− | | + | |
− | [[Image:SetToNext-ObjOnSameTile.JPG|frame|Example BHAV code using Set To Next with obj on same tile]]
| + | |
− | <br clear="all"/>
| + | |
− | | + | |
− | I believe the reason for the above is due to the fact that there is only one variable used for this flavour of 'Set to Next' instead of two. You would imagine that you need a variable to contain
| + | |
− | * the thing that you want to find other things on the same tile as
| + | |
− | * the place to store the returned thing that has been found on the same tile.
| + | |
− | | + | |
− | However, there is only one variable, so it gets updated each time to the newly found thing and thus the starting point is forgotten.
| + | |
Revision as of 19:38, 14 November 2009
This is a flavour of the Set to Next (0x001F) primitive.
This particular enumeration works a little differently from the others because it will never return false.