- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Server Debug Aid


By Chem
Created: 2015/03/14 13:48:08 UTC-07:00 (9 years and 285 days ago)
Edited: 2015/03/14 13:48:08 UTC-07:00 (9 years and 285 days ago)
Likes: 1

Denizen Version: Version
Script Version: 1.0
Description:

Some debuggging that records the server errors from your scripts.
It creates folder that are named the file containing your script.
In those folders are files named the individual script that contains the error.

Each line in the file contains all the data that can be obtained about the script, queue, player, npc.
There is a lot of useless data that might be recorded about your script and if the error occurs frequently enough, the files will get big quickly. The bigger the file, the more work youll need to do to fix it.

There is the ability to determine the line that the error occured on and the ability for denizen to auto correct common mistakes, even provide the correct usage for the erroring command. If I get enough messages on the denizen irc. "!msg Chem "I want that debugging and autofixing you were talking about." Id be quicker about getting out a more advanced version of this.

Future ideas todo:
Build auto correct
Generate erroring loc in the text.
Store data in yaml format for easy data output / error finding
Auto submit denizen exceptions and auto record data / errors and output as a mcmonkey link.
Generate link for documentation for correct usage of dcommands.





Download script | View raw script
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
23100

#################################################################################################################################
#                                                                                                                               #
# A Set of debugging ideas that might be useful for others.                                                                     #
#                                                                                                                               #
#                                                                                                                               #
#################################################################################################################################


#todo: have the server flaged to output to a type of output.
#   log
#   console
#   to_ops
#   to_flagged
#   none
#todo: Create a yaml object representing the error for storage while the server runs
#todo the output feature will read a yaml object thats a culmulation of the error
#yaml object should contain
#   relative file name
#   The error message

#The error yaml file should be ordered by
#   error type: ex, invalid tag, exceptions, command errors.... 
#       script:
#           line of erroring code
#
#Possible to determine a failed ./ex command
# queue.id.split[_].contains[EXCOMMAND]
#
#        #loc/yaml_keys[<&lt>def[script]<&gt>].size|
#        #step/step[<&lt>player<&gt>]|
#        #assigned_to/get_npcs_assigned[<&lt>def[script]<&gt>]



ScriptDebug:
    type: world
    script_error_object_file: script_error_objects.yml
    events:
        on script generates error:
        - if !<server.has_flag[debug_output]> queue clear
#        - if <context.script||none> != none {
#            - yaml
#              load:<context.script.relative_filename>
#              id:<context.script.name>
#              
#            - run "Build Yaml Error Object"
#              def:<context.message>|<context.queue>|<context.script>
#            }
        - define player "
          <context.queue.player||
          <queue.player||
          <player||
          none>>>"
        
        - define npc "
          <context.queue.npc||
          <queue.npc||
          <player.selected_npc||
          none>>>"
        
        - define queue
          <context.queue||none>
        
        - define script
          <context.script||none>
        
        - inject "get debug data"
        
        #ignored printing data based off of whats generated in the script get debug data
        - define ignored_data
          li@none|ignored_data|loop_index|value|type|accessor|attribute|object|accessor_types|npc_accessors|player_accessors|queue_accessors|script_accessors
        
        - define ignored_data
          <def[ignored_data].include[player_list_flags]>
        
        - if <def[script].relative_filename||none> != none {
            - define file_location <def[script].relative_filename.split[<&dot>].get[1]>
            - define file_location /plugins/denizen<def[file_location]>
            - define file_name <def[script].name>_errors.log
            } else {
            - define file_location /plugins/denizen/scripts
            - define file_name general_errors.log
            }
        
        
        - define file <def[file_location]>_error_log/<def[file_name]>
        #- announce "file<&co> <def[file]>"
        #- define file /plugins/denizen/script_errors.log
        
        #output
        - announce "<red>[<def[script].name||NOSCRIPT>] <blue><context.message>"
        - log "=======<script.name>======="                                                                 type:warning file:<def[file]>
        - log "Script<&co> <&lb><def[script].name||Unknown Script><&rb> <--- Generated an error."           type:none file:<def[file]>
        - log "The message is as follows<&co>"                                                              type:none file:<def[file]>
        - log "<context.message>"                                                                           type:none file:<def[file]>
        - foreach <queue.definitions.alphanumeric> {
            - if <def[ignored_data].contains[<def[value]>]> 
              || <def[%value%]> == none {
                - foreach next
                }
            - log "<&lb><def[value]><&rb> <def[%value%]>"                                                   type:none file:<def[file]>
            }
        - log "=======Finished with Debug Data======="                                                      type:none file:<def[file]>
        
        
        on server generates exception:
        #- if !<server.has_flag[debug_output]> queue clear
        #- run "Notify Debug" def:<context.message>|<context.queue||none>|<context.script||none> instantly


Get Debug Data:
    #
    # INJECTED SCRIPT
    # This script defines data based on the definitions within
    #
    #this requires definitions to be already defined,
    # - define player <player>
    # - define player <queue.player>
    # - define queue <context.queue>
    # - define script <s@testing_sorta>
    # - define npc <player.selected_npc>
    type: task
    script:
    - define queue_accessors "
        id/id|
        size/size|
        state/state|
        script/script|
        determination/determination|
        type/type|
        speed/speed|
        commands/commands|
        debug/script.debug|
        definitions/definitions"
    
    - define script_accessors "
        container_type/container_type|
        cooled_down/cooled_down|
        filename/filename|
        relative_filename/relative_filename|
        name/name|
        debug/debug|
        prefix/prefix|
        object_type/object_type"
        #loc/yaml_keys[<&lt>def[script]<&gt>].size|
        #step/step[<&lt>player<&gt>]|
        #assigned_to/get_npcs_assigned[<&lt>def[script]<&gt>]
    
    - define npc_accessors "
        id/id|
        spawned/spawned|
        owner/owner|
        name/name|
        nickname/nickname|
        protected/is_protected|
        lookclose/lookclose|
        previous_location/.location.previous_location.simple|
        location/location.simple|
        nav_target/navigator.target_location|
        teleport_on_stuck/teleport_on_stuck|
        navigating/navigator.is_navigating|
        base_speed/navigator.base_speed|
        range/navigator.range|
        attack_range/navigator.attack_range|
        stratagey/navigator.attack_stratagey|
        speed_modifier/navigator.speed_modifier|
        speed/navigator.base_speed|
        avoid_water/navigator.avoid_water|
        base_speed/navigator|
        has_assignment/has_script|
        script/script|
        flags/list_flags|
        engaged/is_engaged|
        anchors/anchor.list|
        inventory/inventory.list_contents|
        traits/traits|
        nearby_npcs/location.find.npcs.within[25]"
    
    - define player_accessors "
        name/name|
        display_name/name.display|
        list_name/name.list|
        entity_id/eid|
        save_name/save_name|
        prefix/prefix|
        selected_npc/selected_npc|
        is_op/is_op|
        location/location.simple|
        chat_history/chat_history_list|
        target/target|
        open_inventory/open_inventory|
        is_op/is_op|
        location/location.simple|
        chat_history/chat_history_list|
        target/target|
        open_inventory/open_inventory|
        item_on_cursor/item_on_cursor|
        money/money|
        list_flags/list_flags.alphabetical|
        fall_distance/fall_distance|
        debug/debug"
    
    #this requires definitions to be already defined,
    # - define player <player||none>
    # - define player <queue.player||none>
    # - define queue <context.queue||none>
    # - define script <s@testing_sorta||none>
    # - define npc <player.selected_npc||none>
    
    #todo: maybe I might want to add to a list of attributes instead of creating definitions
    #by reason of possibility of overwriting other definitions within a script
    #thats why the definition created is %type%_%attribute%  or npc_location instead of just location
    - define accessor_types li@queue|script|player|npc
    - foreach <def[accessor_types]> {
        #store the type so its not overwritten later
        - define type %value%
        #get the calling scripts value
        - define object <def[%value%]||none>
        #if there was a failed or no definition at all
        - if <def[object]> == none foreach next
        #foreach local definitions, queue_accessors, etc...
        - foreach <def[%type%_accessors].as_list> {
            #split the name from the accessor value
            - define attribute <def[value].split[/].get[1]>
            - define accessor <def[value].split[/].get[2]>
            ##access the attributes on the calling scripts object. eg player.name, queue.size, etc...
            - define %type%_%attribute% <def[object].%accessor%||none>
            }
        }
    





View History