public void LoadScript(JagexBuffer b) { int count = b.ReadUByte(); byte[] compare_type = null; int[] compare_value = null; if (count > 0) { compare_type = new byte[count]; compare_value = new int[count]; for (int i = 0; i < count; i++) { compare_type[i] = (byte)b.ReadByte(); compare_value[i] = b.ReadUShort(); } } count = b.ReadUByte(); if (count > 0) { Script = new WidgetScript[count]; for (var i = 0; i < count; i++) { var s = new WidgetScript(b, i); if (compare_type != null && i < compare_type.Length) { s.compareType = compare_type[i]; s.compareValue = compare_value[i]; } Script[i] = s; } } }
private bool LineUpdateRequired() { string text = null; if (IsEnabled()) { text = Config.MessageEnabled; } else { text = Config.MessageDisabled; } if (text == null) { return(false); } var segments = text.Split(new string[] { "\\n" }, StringSplitOptions.None); if (segments.Length != lines.Count) { return(true); } for (int i = 0; i < lines.Count; i++) { var segment = segments[i]; if (segment.IndexOf('%') != -1) { for (int j = 1; j < 5; j++) { do { int k = segment.IndexOf("%" + j); if (k == -1) { break; } int value = -2; if (Config.Script != null && j - 1 < Config.Script.Length) { WidgetScript scr = Config.Script[j - 1]; if (scr != null) { value = scr.Execute(); } } segment = segment.Substring(0, k) + (value > 999999999 ? '*' : value) + segment.Substring(k + 2); } while (true); } } if (!segment.Equals(lines[i].Text)) { return(true); } } return(false); }