PHP Code:
function onCreated() {
temp.array = {"float", "string", "object"};
temp.object = new TStaticVar();
object.array = {"foo", "bar"};
object.float = 3.14;
object.integer = 7;
object.bool = true;
object.string = "baz";
temp.prefix = "temp.object.";
temp.dynamic = object.getDynamicVarNames();
temp.vars = filter(object.getVarNames(), dynamic);
temp.lines = {"<objecttype='"@ object.objecttype() @"'>"};
temp.i = 0;
for(temp.var : dynamic) {
i = 1;
if (makevar(prefix @ var).type() == 3) {
lines.add(addSpace("<array='"@ var @"'>", i));
i = 2;
temp.c = 0;
for(temp.var2 : makevar(prefix @ var)) {
lines.add(addSpace("<attr["@ c @"]="@ makevar(prefix @ var)[c] @">", i));
c ++;
}
lines.add(addSpace("</array>", 1));
}else{
temp.suffix = array[makevar(prefix @ var).type()];
if (suffix == "float") {
if (makevar(prefix @ var) == int(makevar(prefix @ var))) suffix = "integer";
}
lines.add(addSpace("<"@ suffix @"='"@ var @"'>" @ makevar(prefix @ var) @"</"@ suffix @">", i));
}
}
temp.lines.add("</objecttype>");
for(temp.line : lines) {
echo(line);
}
}
function filter(a, b) {
temp.out = a;
for(temp.i : b) {
temp.ind = a.index(i) > -1;
if (ind > -1) out.remove(i);
}
return out;
}
function addSpace(str, int) {
temp.i = 0, temp.out = "";;
while(i < int*2) {
out @= " ";
i += 2;
}
out @= str;
return out;
}
I have gotten Chompy to teach me alot, so I've been getting better
anyways, the output of the file above:
PHP Code:
<objecttype='TStaticVar'>
<array='array'>
<attr[0]=foo>
<attr[1]=bar>
</array>
<integer='bool'>1</integer>
<float='float'>3.14</float>
<integer='integer'>7</integer>
<string='string'>baz</string>
</objecttype>
NOW, it says:
NPC Code:
<integer='bool'>1</integer>
Is there a way I can check if it is a bool, because if I check with obj.type() it returns integer

(true = 1, false = 0)
Chompy is away for a week, and this has been on my mind, so I thought I could post it here to get the answer. So.., anyone know?