Skip to content
User Avatar
#2481
Auto-translated
Could you write the script in an infinite loop?
function foo()
  while 1 do
    -- insert code here
    sleep(10);
  end
end

startThread(foo)
How can I make it so that one function is triggered the first time a region is visited, and another function is triggered the second time?
region_visit_counter = 0;

function foo()
  region_visit_counter = region_visit_counter + 1;
  if (region_visit_counter == 1) then
    -- first visit, call the appropriate function
  else
    -- all subsequent visits, call a different function
  end
end