";
- foreach (key, value in locals)
- {
- string += format("%s = %s, ", key, this.getLocalString(value, _maxLen, _maxDepth, _advanced, false));
- }
+ localsString += format("%s = %s, ", key, this.getLocalString(value, _maxLen, _maxDepth, _advanced, false));
+ }
+ if (localsString != "")
+ {
+ string += "
Variables:
" + localsString;
string = string.slice(0, string.len() - 2) + "
";
}
}
@@ -42,17 +43,26 @@
function formatData( _data, _maxDepth = 1, _advanced = false, _maxLenMin = 1, _printClasses = true )
{
- if (["array", "table"].find(typeof _data) != null && _data.len() > _maxLenMin)
+ local len = 0;
+ local obj = _data;;
+ switch (typeof _data)
{
- _maxLenMin = _data.len();
- }
- else if (["class", "instance"].find(typeof _data) != null)
- {
- local len = 0;
- local classed = typeof _data == "instance" ? _data.getclass() : _data;
- foreach (key, value in classed) ++len;
- if (len > _maxLenMin) _maxLenMin = len;
+ case "table":
+ len = this.__safeLen(_data);
+ break;
+
+ case "instance":
+ obj = _data.getclass();
+ case "class":
+ foreach (k, v in obj) ++len;
+ break;
+
+ case "array":
+ len = _data.len();
+ break;
}
+
+ if (len > _maxLenMin) _maxLenMin = len;
return this.getLocalString(_data, _maxLenMin, _maxDepth, _advanced, _printClasses);
}
@@ -70,14 +80,16 @@
if (_value.len() != 0) ret = ret.slice(0, -2);
ret += "]";
}
- else if (typeof _value == "table" && _value.len() <= _maxLen && _depth > 0) // full table
+ else if (typeof _value == "table" && _depth > 0 && this.__safeLen(_table) <= _maxLen) // full table
{
ret += "{";
+ local len = 0;
foreach (key, value in _value)
{
ret += format("%s = %s, ", key.tostring(), this.getLocalString(value, _maxLen, _depth - 1, _advanced, _printClasses));
+ len++;
}
- if (_value.len() != 0) ret = ret.slice(0, -2);
+ if (len != 0) ret = ret.slice(0, -2);
ret += "}";
}
else if (["instance", "class"].find(typeof _value) != null && _depth > 0 && _printClasses) // full instance or class
@@ -111,4 +123,17 @@
}
return ret;
}
+
+ function __safeLen( _table )
+ {
+ if (_table.len == {}.len)
+ return _table.len();
+
+ local ret = 0;
+ foreach (k, v in _table)
+ {
+ ret++;
+ }
+ return ret;
+ }
}