1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Join Texturing Contest #30 now in a legendary battle of mythological creatures!
    Dismiss Notice
  3. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice
  4. Melee Mapping Contest #3 - Results are out! Congratulate the winners and check plenty of new 4v4 melee maps designed for this competition!
    Dismiss Notice
  5. The winners of our cinematic soundtrack competition have been decided! Step by the Music Contest #11 - Results to check the entries and congratulate the winners!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice

[GUI-Friendly] Trigger Debugger System

Submitted by MyPad
This bundle is marked as pending. It has not been reviewed by a staff member yet.
Thanks to Darkfang for the idea of creating this system for GUI users.

Welcome to the Trigger Debugger System. This system enables one to debug quite a handful of triggers which he/she wishes to carefully examine. It offers the following features:

Trigger registration - A requirement in this system, this allows GUI and JASS users alike to register which triggers they want to register.

Commands - Includes commands such as display, allow, and discard. You can type the name of a certain trigger after those commands in order to influence that trigger only.



  • Code (vJASS):

    //! novjass
    Here are some available functions for JASSers:

    function DebugTrigger_SetTraceTrigger(trigger, boolean)
        If the trigger is in the system, this enables the tracing of the trigger in the evaluation
        of conditions.
     
        Also, if udg_DebugTrigger_Trace_DISABLE is true, the boolean flag determines the state of the
        trigger such that setting it to true would enable it, and the inverse is true.
     
    function DebugTrigger_SetWatchTrigger(trigger, boolean)
        If the trigger is in the system, this enables the watching of the trigger. This is enabled by
        default. When tracing is enabled, a trace message will be displayed.

    function DebugTrigger_WatchTrigger(trigger, string)
        If the trigger is in the system, an error will be displayed. Otherwise, if the name of the
        trigger, which the string represents, has already been cached, the system will display
        a notification, printing the new name of the trigger.

    The variable types enclosed in parentheses are the arguments of the function.
    //! endnovjass
     



  • Nearly all variables in the system are private. Here are some of the public variables, which you can tamper with:

    udg_DebugTrigger_ParamTrigger - The trigger which you want to affect.
    udg_DebugTrigger_ParamTriggerName - The assigned name of the trigger.
    udg_DebugTrigger_Instruction - The assigned instruction.

    You can assign the instruction variable into these values:

    0 - Makes the system watch the trigger above, with the assigned name.
    1 - Enables stack-tracing of the trigger. This will display info on every triggerevaluation.
    2 - Disables stack-tracing of the trigger. If udg_DebugTrigger_Trace_DISABLE is set to true,
    this also disables the trigger.

    There are helper variables specifically for that purpose. They are

    udg_DEBUGTRIGGER_REGISTER -> 0
    udg_DEBUGTRIGGER_TRACE -> 0
    udg_DEBUGTRIGGER_UNTRACE -> 0

    Once you have assigned the instruction and the parameter values, you can then execute the trigger
    <gen> Debug Trigger GUI.

  • Due to StringHash potentially causing collisions, the system might erroneously suffix a trigger name even when the name in question has only been introduced. Otherwise, the system is quite equipped to handle unusual test cases.

    When a certain trigger runs, the trigger conditions get fired first. All of the trigger conditions must return true in order for the trigger to proceed to the list of trigger actions. This system does not take into account the disparity between the number of executions and the number of evaluations.

  • Code (vJASS):

    //! novjass
    DebugTrigger_EnumPlayer
        An extra variable that has no other practical purpose after initialization.
        Consider this a free variable to use.

    DebugTrigger_ListenerCountKey = 0
        The key to the hashtable that stores the number of iterations a trigger
        has made.

    DebugTrigger_ListenerKey = 0
        The key to the hashtable that stores the flag that determines whether
        subsequent trigger iterations will be counted.

    DebugTrigger_ListenerTrace = 0
        The key to the hashtable that stores the flag that determines whether
        subsequent trigger iterations will display information.

    DebugTrigger_StringKey = 0
        The key ... that stores the indices of hashed strings.

    DebugTrigger_SubString[] = <Empty String>
        A string array variable that is used whenever <gen> Debug Trigger
        Core catches a player chat event. Indices used are 0, 1, and 2.

    DebugTrigger_TriggerHandle = 0
        The key ... that stores the triggers, bound to their indices.

    DebugTrigger_TriggerIndex = 0
        The key ... that stores the indices of the triggers, bound to their
        Handle id or Key of, in GUI.

    DebugTrigger_TriggerList = 0
        A static linked list that stores all the indices relevant to the system
        (e.g, indices generated by another system that are used to store
        registered triggers)

    DebugTrigger_TriggerKey = 0
        The key ... that acts as the allocator variable.

    DebugTrigger_TriggerNameKey = 0
        The key ... that stores the name of each and every trigger.

    DebugTrigger_TriggerNameCount = 0
        The key ... that stores the number of times the same trigger name
        has been used.
    //! novjass
     



    • v.1.0.0.0 - Introduction of the resource!
    • v.1.1.0.0 - Included some constants for readability purposes (mostly for GUI)
Contents

[GUI-Friendly] Trigger Debugger (Map)

  1. Darkfang

    Darkfang

    Joined:
    Jun 25, 2008
    Messages:
    1,681
    Resources:
    199
    Models:
    1
    Icons:
    182
    Skins:
    11
    Maps:
    3
    Tutorials:
    2
    Resources:
    199
    How Is it implemented? Do you have to manually add each trigger or it does it all?
     
    Last edited: Jun 28, 2018
  2. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,172
    Resources:
    3
    Models:
    1
    Icons:
    1
    JASS:
    1
    Resources:
    3
    The user has to manually add the triggers which he/she wants to watch. That's one of the two drawbacks of the system, the other which is StringHash.

    Other than that, the instructions for both GUI and JASS users are already there. (Maybe it's incomplete, I'll update it tomorrow :con:)
     
  3. nedio95

    nedio95

    Joined:
    Mar 24, 2011
    Messages:
    1,055
    Resources:
    1
    Spells:
    1
    Resources:
    1
    @Darkfang , oh, well lad, I guess you are sorter ;)

    It looks like you have to do the following for EACH trigger you want to look at:
    • Register trigger
      • Events
        • Map Initialization
      • Conditions
      • Actions
        • -------------------------------------- TRIGGER 1 ------------------------------------
        • --------- The trigger you want to track
        • Set DebugTrigger_ParamTrigger = SomeTrigger
        • --------- String name of trigger you want to track
        • Set DebugTrigger_ParamTriggerName = "Whatever's easier for you"
        • --------- Instruction for the tracking
        • Set DebugTrigger_Instruction = 0 / 1 / 2
        • --------- Run registration
        • Trigger - Run Debug Trigger GUI
        • -------------------------------------- TRIGGER 2 --------------------------------------
        • --------- The second trigger you want to track
        • Set DebugTrigger_ParamTrigger = SomeTrigger2
        • --------- String name of second trigger you want to track
        • Set DebugTrigger_ParamTriggerName = "Meh"
        • --------- Instruction for the tracking
        • Set DebugTrigger_Instruction = 0 / 1 / 2
        • --------- Run registration
        • Trigger - Run Debug Trigger GUI


    regards
    -Ned
     
  4. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,172
    Resources:
    3
    Models:
    1
    Icons:
    1
    JASS:
    1
    Resources:
    3
    Very well said, @nedio95.

    However, the other instructions, which are 1 and 2 do not need ParamTriggerName to be specified in order to work in GUI.

    I'll add enum variables specifically for the purpose of GUI usage.