A question on Trigger Creation

CaptainJack

New Member
Reaction score
2
I'm not particularly sure if what I am trying to do is legal within JASS, but the compiler and any syntax checker I am using is basically saying there is an error without describing it.

The basic questions is it possible to pass parameters for the Condition and Action portion of a trigger, and if so how is this achieved?


JASS:

function TestFunction1_Conditions takes nothing returns nothing

    // Some Condition

endfunction

function TestFunction1_Actions takes string a returns nothing

    call BJDebugMsg(a)

endfunction 
 
function TestFunction1 takes string a returns nothing
    local trigger test = CreateTrigger()
    
    call TriggerRegisterAnyUnitEventBJ(test, EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddCondition(test, Condition(function TestFunction1_Conditions))
    call TriggerAddAction(test, function TestFunction1_Actions(a))  

endfunction 
 
//==========
function CustomTrigger takes nothing returns nothing

    call TestFunction1("Testing")

endfunction
 
Not only, but you just wrote a instead of [ljass]"a"[/ljass].

There are ways to achieve faux-parameters in actions. Realistically, what are you trying to do?
 
Realistically it will end up as a custom system for my map, based around item recipes. And I have no desire to use any that are already on here.
 
what do you wanna pass to argument for the trigger action?

some example really help to show you others ways
 
I just gave you an example of what I wanted to do, create a trigger that will display the text of that function when an item is acquired. All I want to know is the syntactically correct way to pass that argument because the compiler doesn't give any useful feedback on the issue, and things like JASSCraft don't even see a problem with what is being done, other than that there is a syntax error.
 
Using Get***() still won't fix the fact that I want to pass parameters to the Action section of the trigger.
 
GetManipulatedItem()
GetTriggerUnit()
Can't help? I don't think these natives can't help you.

You are in wrong concept, anyway.
Try to look at people's code, you will learn from there.
 
Passing a parameter really isn't the wrong concept for what I want to do here. I want a trigger that is created based off those parameters.
 
Passing a parameter really isn't the wrong concept for what I want to do here.

The only way to do exactly this is to use a different programming language. If you want to simply achieve the same thing, you have to do it through attachment methods, not by parameters. Code values can not have parameters in JASS.

A good language that gives you more flexibility in this field is something like JavaScript.
 
JASS:
globals
    hashtable ht      //created in the GUI variable editor if you aren't using vJASS, or even substituted by Table by Vexorian if you do
endglobals

function TestFunction1_Conditions takes string a returns nothing
    local string a
    if GetUnitTypeId(GetTriggerUnit()) == 'hfoo' then               //some condition
        set a = LoadStr(ht, GetHandleId(GetTriggeringTrigger()), 0) //load data
        
        call BJDebugMsg(a)                                          //do smth with it
        
        //call DestroyTrigger(GetTriggeringTrigger())               //eventually clean-up
        //call FlushChildHashtable(ht, GetTriggeringTrigger())
    endif
    return false
endfunction
 
function TestFunction1 takes string a returns nothing
    local trigger test = CreateTrigger()
    
    call TriggerRegisterAnyUnitEventBJ(test, EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddCondition(test, Condition(function TestFunction1_Conditions))
    call SaveStr(ht, GetHandleId(GetTriggeringTrigger()), 0, a)
    
    set test = null
endfunction 
 
//==========
function CustomTrigger takes nothing returns nothing

    call TestFunction1("Testing")

endfunction


Dynamic triggers, as rumors say, mustn't have actions (I've used actions w/ em with no problems, but if you do, you gotta remove them plus the risk of everything crashing and burning). I can't imagine why this would be needed for an item recipe system, as instead of multiple dynamic triggers for i.e. every unit/player you can make one and do checks when the trigger fires.

PS. Freehanded
 
Thanks, all I needed to know is that it was not possible to pass a parameter via the TriggerAdd*() set of functions.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top