ID:168491
 
Hmm, not really sure how to make a command to check all your vars that are active without having to make multiple lines. Any Ideas?
What do you mean by "checking all your vars that are active"? Can you please explain it a little better?

~~>Dragon Lord
#define islist(L) (if(istype(/list,L)))

mob/verb/CheckVars()
var/t="<font size=+2>[src]:</font>"
for(var/a in vars)
if(islist(a))
t += "List: [a] = <br>"
for(var/b in vars[a]) t += " [b]<br>"
else
src << "[a] = [vars[a]]<br>"


I think that should work. References to atoms won't work out too well, but beyond that it is workable. The islist() define may be wrong, too. I can never get the order of arguments in istype() right...
In response to Jp
Swap the /list with L for the define.
In response to Jp
Won't work. Your macro will expand to have two if()s, and the arguments to istype() are the wrong way around. =)

Corrected version:

> #define islist(L) (istype(L,/list))
>
> mob/verb/CheckVars()
> var/t="<font size=+2>[src]:</font>"
> for(var/a in vars)
> if(islist(a))
> t += "List: [a] = <br>"
> for(var/b in vars[a]) t += " [b]<br>"
> else
> src << "[a] = [vars[a]]<br>"
>


You can get a lot more complex with this kind of thing; supporting atoms, nested lists, and all kinds of things. There are libraries that do all the work for you already; http://developer.byond.com/hub/Gazoot/var_dump, for example. (I've never used it - I have my own personal unreleased library that includes these kind of things - but Gazoot's looks pretty good.) Deadron also has one (http://developer.byond.com/hub/Deadron/Debug).