System CommandParser

Discussion in 'Systems and Snippets' started by quraji, Nov 21, 2009.

  1. quraji

    quraji zap

    Ratings:
    +143 / 0 / -0
    Not sure why you'd need that. But, the Args struct is public so you could make your own if you like the interface.

    [ ljass] [ /ljass] without the spaces.
     
  2. quraji

    quraji zap

    Ratings:
    +143 / 0 / -0
    I'm thinking of changing the way to use this from:
    JASS:
    // uses eval
    function onCmd takes Args args returns nothing
        // do stuff
    endfunction
    
    // to :
    
    // uses exec
    function onCmd takes nothing returns nothing
        local Args args = GetCommandArgs() // or something
        // stuff
        call DestroyArgs(args) // call args.destroy()
    endfunction
    
    // I haven't actually looked at this system since it got approved so 
    // there might be a reason why it's not like this, but probably not.


    Not sure why I did the first to begin with, it's kinda weird (as far as the takes Args args thing).

    Anyone actually use this yet? (or try it?) :p
     
  3. Jesus4Lyf

    Jesus4Lyf Good Idea™

    Ratings:
    +394 / 0 / -0
    Alternative is:
    JASS:
    struct MyCommandStruct extends Args
        implement Command
        private method onCommand takes nothing returns nothing
            // do things with "this", which is your args.
            // it is possible, like this, to fire it with execute AND destroy args when the method
            // finishes firing, even if it uses TriggerSleepAction.
        endmethod
        private static method onInit takes nothing returns nothing
            set this.triggerString="give"
        endmethod
    endstruct

    Up to you. I don't like the idea of manually destroying.
     
  4. quraji

    quraji zap

    Ratings:
    +143 / 0 / -0
    If anyone at all is using or has used this I'd like some feedback on the interface...I'm kind of torn about whether to change it or not.
     
  5. tooltiperror

    tooltiperror Super Moderator Staff Member

    Ratings:
    +233 / 0 / -0
    This is such an awesome system, I love it. Even though I plan on remaking it in Vanilla JASS :thup:
     

Share This Page