You define the run_choice() function, but never actually call it. That's what is causing the script to loop during the repeat, when you encounter a choice adventure.
Another problem is that, inside the run_choice() function, the "sewers" variable should be "page_text".
If you remove run_choice() from the repeat{} structure, and place it at the top level instead (anywhere in the script that isn't inside another function), you need to call it in the repeat{} just like you call run_combat().
The result of visit_url() should also be stored in the sewers variable, since you need to check for the string "combat" in the most recent page you visited, not in the first page you visited. This is what the repeat{} should look like:
This should make the script run stop looping, at least.
Another problem is that, inside the run_choice() function, the "sewers" variable should be "page_text".
If you remove run_choice() from the repeat{} structure, and place it at the top level instead (anywhere in the script that isn't inside another function), you need to call it in the repeat{} just like you call run_combat().
The result of visit_url() should also be stored in the sewers variable, since you need to check for the string "combat" in the most recent page you visited, not in the first page you visited. This is what the repeat{} should look like:
PHP:
repeat
{
// adventure in sewers
sewers = visit_url("adventure.php?snarfblat=166") ;
// if it's a combat adventure, obey the custom combat script
if (contains_text( sewers , "combat"))
run_combat();
// handles choice adventures
sewers = run_choice( sewers );
}
until (contains_text( sewers ,"onward and... downward!")) ;
This should make the script run stop looping, at least.