1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Mission Solved Order Tracking - Submission

Discussion in 'JASS Class' started by The_Spellweaver, Jun 25, 2017.

  1. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    This is my first submission, hopefully is all alright.

    Edit: Changed subscription to condition instead of action, as MyPad suggested

    Code (vJASS):

    scope OrderTracking initializer Init
        private function Action takes nothing returns boolean
            local unit u = GetTriggerUnit()
            local integer orderId = GetIssuedOrderId()
           
            local string unitName = GetUnitName(u)
            local string orderName = OrderId2String(orderId)
            local string targetName = GetObjectName(orderId)
            local string targetUnitName = GetUnitName(GetOrderTargetUnit())
           
            // If orderName is empty, replace it with tragetName
            if (orderName == "" and targetName != "Default string") then
                set orderName = targetName
            // If orderName is not empty, just append targetName
            elseif (targetName != "Default string") then
                set orderName = orderName + " " + GetObjectName(orderId)
            // If remaining string is "Default string" then do not print it
            elseif (orderName == "Default string") then
                set orderName = ""
            endif
           
            // Always add targetUnitName if it exists
            if (targetUnitName != "Default string") then
                set orderName = orderName + " " + targetUnitName
            endif
           
            call BJDebugMsg(unitName + " - (" + I2S(orderId) + ") " + orderName)
           
            set u = null
            return TRUE
        endfunction
       
        private function Init takes nothing returns nothing
            local trigger t = CreateTrigger()
           
            call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
            call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
            call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
            call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
           
            call TriggerAddCondition(t, Condition(function Action))
            set t = null
        endfunction
    endscope
     
     

    Attached Files:

    Last edited: Jun 26, 2017
  2. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,304
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7
    Hello. This seems like a nice submission, but I would suggest converting this..

    Code (vJASS):

        call TriggerAddAction(t, function Action)
     


    into this.
    Code (vJASS):

        call TriggerAddCondition(t, Condition(function Action))
     


    Aside from that, everything is fine. If you're wondering why I'm suggesting to convert that into a triggercondition, thinking that it wouldn't work, then it's because expressions that return nothing will somehow return something when converted into a filterfunc or conditionfunc.
     
  3. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    I read up on that, and it seems better for more reasons than just one, although it did work before as well.

    Thank you for pointing it out!
     
  4. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,179
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Good. ~Solved~
     
  5. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,304
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7
    wut?
     
  6. Cuore

    Cuore

    Joined:
    Mar 11, 2017
    Messages:
    583
    Resources:
    8
    Models:
    8
    Resources:
    8
    @RoflingAtU From the HelpMe section, have a look at the tutorial Converting GUI into Efficient JASS look for the intervention of Almia and the update of the final part of the tutorial that followed.
    That being said about the reason to merge AddAction to AddCondition, I have little defined concept of what a thread concretely is beside being a queue of related actions. Also unclear to me is if a thread is an entity handled by a processor, a virtual machine, or an OS, or none of those or even all of them in some way. Surely others can explain properly.
     
  7. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,304
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7
    With the submission being solved, I would just suggest changing the return function of the conditionfunc from boolean to nothing, removing the return value of the function. It will silently return a true statement.

    From what I know and recall, a thread is something that is handled by the JASS VM. It has a limit of 300 000 operations.
    A TriggerCondition retains the thread (perhaps refreshing the operation count) while a TriggerAction creates a new thread (allowing for TriggerSleepActions).
     
  8. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,179
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    @RoflingAtU , do you know if there will be still an attempt for a condition evaluation, even if none exists? I thought that this was a (pseude) reason, too.
     
  9. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,179
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    It won't be called, but there might be other operations that might be executed when a trigger runs. I'm curious if same amount of operations run in background when a condition runs, or when an action runs. Maybe we still call some redundancy, when we execute the action -- at least that's my question. But again, as said, this is/was a pseudo reason.
     
  10. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,179
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    So out of curiosity now:

    -- conditionCounter_Check()
    -- -- (if true) -> conditions_loop()
    -- actionCounter_Check()
    -- -- (if true) -> actions_loop()

    and in case condition_loop Returns false, then no actionCounter_Check() does run at all, I guess?
    So potentialy we save one action_Counter check for now when we use conditions? Is there maybe more checks? just in case you know.