There are a few possibilities to track the state of the location. You could create a global list and add a location as soon as you detect that you are inside the location.
Something like this could work (assume global_locations is a list with all locations you are interested in, global_inside_locations is initially empty and contains the locations you are inside now):
-trigger Periodic Location Update
-action Script
Code: Select all
//initialize missing lists to prevent errors
if (global_locations==null)
{
global_locations = newList();
}
if (global_locations==null)
{
global_inside_locations = newList();
}
// entering location check
for (loc in global_locations)
{
if (distance(loc, location) < 1000)
{
if (containsElement(global_inside_locations, loc))
{
log("already inside {loc,locationformat,decimal}");
}
else
{
log("entered {loc,locationformat,decimal}");
addElement(global_inside_locations, loc);
}
}
}
// leaving location check
//copy the list since it's not allowed to modify the list when looping over this list
for (loc in copyList(global_inside_locations))
{
if (distance(loc, location) >= 1000)
{
log("exited {loc,locationformat,decimal}");
removeElementValue(global_inside_locations, loc);
}
}
Regards,
Martin