-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.hws
67 lines (55 loc) · 1.24 KB
/
debug.hws
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Function MyDebug(...)
Local Function PrettyPrint(item, name, indent)
ConsolePrintNR(RepeatStr(" ", indent))
If GetType(item) = #TABLE
If StrLen(name) <> 0
ConsolePrintNR(name, " : ")
EndIf
Else
If StrLen(name) = 0
ConsolePrintNR(item, " ")
Else
ConsolePrintNR(name, " : ", item)
EndIf
EndIf
Switch GetType(item)
Case #NUMBER
ConsolePrint("")
Case #STRING
ConsolePrint("")
Case #TABLE
ConsolePrint("{")
If HaveItem(item, 0)
; Normal numéric index based array
For k,v In IPairs(item)
PrettyPrint(v, k, indent + 2)
Next
Else
; Associative array
For k,v In Pairs(item)
PrettyPrint(v, k, indent + 2)
Next
EndIf
ConsolePrintNR(RepeatStr(" ", indent) .. "}")
If StrLen(name) <> 0
ConsolePrint(" // ", name)
Else
ConsolePrint("")
EndIf
Case #FUNCTION
ConsolePrint(" (function)")
Case #USERDATA
ConsolePrint(" (userdata)")
Case #LIGHTUSERDATA
ConsolePrint(" (lightuserdata)")
Case #THREAD
ConsolePrint(" (thread)")
Case #NIL
ConsolePrint(" (nil)")
EndSwitch
EndFunction
For k, v In IPairs(arg)
PrettyPrint(v, "param" .. k+1, 0)
ConsolePrint("")
Next
EndFunction