public override void OnEnter() { GlobalVariables.Save(saveName); }
public override void OnEnter() { GlobalVariables.Load(saveName); Continue(); }
void ProcessText(string text) { // Split text into lines. Add a newline at end to ensure last command is always parsed string[] lines = Regex.Split(text + "\n", "(?<=\n)"); string blockBuffer = ""; ParseMode mode = ParseMode.Idle; string blockTag = ""; for (int i = 0; i < lines.Length; ++i) { string line = lines[i]; bool newBlock = line.StartsWith("$"); if (mode == ParseMode.Idle && !newBlock) { // Ignore any text not preceded by a label tag continue; } string newBlockTag = ""; if (newBlock) { newBlockTag = line.Replace("\n", ""); } bool endOfFile = (i == lines.Length - 1); bool storeBlock = false; if (newBlock) { storeBlock = true; } else if (mode == ParseMode.Text && endOfFile) { storeBlock = true; if (!line.StartsWith("#")) { blockBuffer += line; } } else { if (!line.StartsWith("#")) { blockBuffer += line; } } if (storeBlock) { if (blockTag.Length > 0 && blockBuffer.Length > 0) { // Trim off last newline blockBuffer = blockBuffer.TrimEnd('\r', '\n', ' ', '\t'); GlobalVariables.SetString(blockTag, blockBuffer); } // Prepare to parse next block mode = ParseMode.Idle; if (newBlock) { mode = ParseMode.Text; blockTag = newBlockTag; } blockBuffer = ""; } } }