-- table storing region names and visit flags
region_table =
{
{name = 'NAME_OF_THE_FIRST_REGION', visited = 0},
{name = 'NAME_OF_THE_SECOND_REGION', visited = 0},
...
};
-- initialization function
function RegionInit()
for i, region in region_table do
Trigger(REGION_ENTER_AND_STOP_TRIGGER, region.name, 'RegionVisit');
end
end
-- unified visit function
function RegionVisit(hero)
-- check which region we are in
for i, region in region_table do
if(IsObjectInRegion(hero, region.name)) then
Trigger(REGION_ENTER_AND_STOP_TRIGGER, region.name, nil);
region.visited = 1;
-- here you can do what you need, depending on the region number (variable i is the number in the region_table table)
end
end
end
-- returns true if the region with the name name has been visited
function IsRegionVisited(name)
for i, region in region_table do
if((region.name == name) and (region.visited == 1)) then
return true
end
end
return nil
end
Auto-translated
Abyssal Knight, using additional flags. I used to do similar things like this (the code isn't complete, but it illustrates the principle):