Ok,mi è venuta l'ispirazione per l'IF annidato,provato e funziona
.
Praticamente ho cambiato la sintassi dell'IF mettendoci alla fine il numero di righe che comprende.Ho passato le righe relative all'if usando la ricorsività e adesso funzionano anche gli if annidati
.
codice:
private static void Interpreter(List<string> currentScript,int currIndex, string callerObject, ref Hashtable gameObject, ref Hashtable scriptList, ref Hashtable scriptVarList, ref Hashtable scriptVars,GameTime gameTime)
{
bool jumpLine = false;
bool result = false;
bool wasIf = false;
for (int i = currIndex; i < currentScript.Count; i++)
{
if (currentScript[i].Trim().StartsWith("IF"))
{
int count = Convert.ToInt32(currentScript[i].Trim().Split('$')[1]);
wasIf = true;
string s1 = currentScript[i].Remove(0, 3);
string s2="";
if (count < 10)
s2 = s1.Remove(s1.Length - 3, 3);
else
s2 = s1.Remove(s1.Length - 4, 4);
if (result = Execute(s2, callerObject, ref gameObject, ref scriptList, ref scriptVarList, ref scriptVars, gameTime))
{
List<string> ToPass = new List<string>();
for(int j=i+1;j<=i+count;j++)
ToPass.Add(currentScript[j]);
i += count;
Interpreter(ToPass,0,callerObject,ref gameObject,ref scriptList,ref scriptVarList,ref scriptVars,gameTime);
}
else
{
jumpLine = true;
}
if (jumpLine)
{
i += count;
}
}
else
{
result = Execute(currentScript[i], callerObject, ref gameObject, ref scriptList, ref scriptVarList, ref scriptVars, gameTime);
}
if (!result&&!wasIf)
{
StaticVar.GameComponent.DebugList.Add(currentScript[i].Trim());
}
}
}
Adesso faccio il for e poi dovrei aver finito.
Grazie.