diff --git a/src/dg_scripts.c b/src/dg_scripts.c index 978cf6d..88a4b6d 100644 --- a/src/dg_scripts.c +++ b/src/dg_scripts.c @@ -2486,7 +2486,6 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode) char cmd[MAX_INPUT_LENGTH], *p; struct script_data *sc = 0; struct cmdlist_element *temp; - unsigned long loops = 0; void *go = NULL; void obj_command_interpreter(obj_data *obj, char *argument); @@ -2578,8 +2577,8 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode) if (process_if(p + 6, go, sc, trig, type)) { temp->original = cl; } else { + cl->loops = 0; cl = temp; - loops = 0; } } else if (!strn_cmp("switch ", p, 7)) { cl = find_case(trig, cl, go, sc, type, p + 7); @@ -2599,9 +2598,10 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode) if (cl->original && process_if(orig_cmd + 6, go, sc, trig, type)) { cl = cl->original; - loops++; + cl->loops++; GET_TRIG_LOOPS(trig)++; - if (loops == 30) { + if (cl->loops == 30) { + cl->loops = 0; process_wait(go, trig, type, "wait 1", cl); depth--; return ret_val; diff --git a/src/dg_scripts.h b/src/dg_scripts.h index e860f02..34434b1 100644 --- a/src/dg_scripts.h +++ b/src/dg_scripts.h @@ -135,6 +135,7 @@ struct cmdlist_element { char *cmd; /* one line of a trigger */ struct cmdlist_element *original; struct cmdlist_element *next; + int loops; /* for counting number of runs in a while loop */ }; struct trig_var_data {