• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

easy funtion question

Status
Not open for further replies.
Level 21
Joined
Mar 27, 2012
Messages
3,232
You mean in the headers? (The blue script icon) if not, the explain more cuz i don't see where, if yes, i said i don't want it in the headers since it is for a spell that i will upload here, so i can't add it to the headers

No not the header.

In the game script the trigger JASS is written in the exact same order as your triggers.

So if you have:
Trigger1
Trigger2
Trigger3

Then each one can use the functions from previous ones.
 
Remember that how Jass indexes trigger is based on how old it is.

Making a function on a trigger then use it on another trigger is very simple, but the main issue as always on running the custom functions you made.

You need to disable EVERY trigger that was made before that function. So that Jass Form of the Map will reindex everything [and thus, the function is on the head after header's function]. This result that the custom function of your can be called form any trigger aside header.

In VJass, we can use private library [function?] instead of normal [aka global] function.

EDIT :

DSG's suggestion might coming handy as well.
 
Level 4
Joined
Oct 28, 2012
Messages
82
only GUI, isn't it?

So create a trigger contain that function. Then turn on, off it in other trigger you want to.
(how a GUI user know about function ?? )
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
There are 2 ways to write custom function with no vJASS (my knowledge so far).

1. Header
2. Trigger

To gain further knowledge on how you can write your own custom function in GUI Trigger (not in Header) - see this coding: http://www.hiveworkshop.com/forums/...6/?prev=search=damage%20detection&d=list&r=20

The use of function functionName takes value returns value is how you would write the function.
Then you need to create the trigger, I usually create it as a local trigger t

You can take a look at this test map on how to create custom function via GUI.

I created a custom function named Party that takes unit as its argument.
Then, the function is called to kill the unit - because I set it so.
 

Attachments

  • Custom GUI Function Test.w3x
    12.6 KB · Views: 47
Level 4
Joined
Oct 28, 2012
Messages
82
^ defskull

  • Initialize
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("CustomFunction")
      • Custom script: endfunction
      • Custom script: function Party takes unit u returns nothing
      • Custom script: call KillUnit(u)
      • Custom script: endfunction
      • Custom script: function CustomFunction takes nothing returns nothing
      • Custom script: local trigger t = CreateTrigger()
      • Custom script: call TriggerAddAction(t, function Party)
      • Custom script: set t = null
And another one

  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: call Party(GetTriggerUnit())
And it work. I was like "oh my f**king God".
But this is Jass, right? Then I think Jad ( who create thread) wont be happy.:grin:

-- edit --
I understand it know. Cause in Jass it have //=== to separate upper thing and below. Well. Great work.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
EVERYTHING in Trigger Editor, is in JASS.
It's just GUI made writing looks neater, while the actual script is actually in JASS.

He doesn't want it in vJASS - it's an add-on.
It's an injection to your Warcraft III World Editor that has many more features and performance.

Tell you what, why don't you write a simple trigger and Convert to Custom Text under Edit tab ?
You will see the JASS script, here's an example;

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game - Display to (All players) the text: HELLO WORLD
JASS:
function Trig_Melee_Initialization_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_001" )
endfunction

//===========================================================================
function InitTrig_Melee_Initialization takes nothing returns nothing
    set gg_trg_Melee_Initialization = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Melee_Initialization, function Trig_Melee_Initialization_Actions )
endfunction

Game - Display to (All players) the text: HELLO WORLD is equivalent to call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_001" )

The "TRGSTR_001" has taken HELLO WORLD as its argument therefore it is simplified there.
 
Level 4
Joined
Oct 28, 2012
Messages
82
^

I like Jass ( vJass more). Cause I'm stuck with a full vJass map.
But then I know vJ. It's really amazing.
------
I see your map, since you have to Custom Script all of that thing. Just vJass, and everything're done
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Is that for vJass? If yes, sorry but that's not ehat i am searching for
No... What makes you think that a native has anything to do with vJASS?

vJASS uses the trigger evaluation method to implement dynamic calls. The reason is, if I recall, that the native I showed is slower than trigger evaluation, specifically using conditions to run the function only. However that native I provided was used ages before vJASS and works very well for situations where you do not want the trigger overhead. It was even improved in one of the last patches so it no longer crashes Warcraft III process if an invalid function name is passed to it.
 
Level 15
Joined
Oct 18, 2008
Messages
1,591
  • Initialize
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("CustomFunction")
      • Custom script: endfunction
      • Custom script: function Party takes unit u returns nothing
      • Custom script: call KillUnit(u)
      • Custom script: endfunction
      • Custom script: function CustomFunction takes nothing returns nothing
      • Custom script: local trigger t = CreateTrigger()
      • Custom script: call TriggerAddAction(t, function Party)
      • Custom script: set t = null
And another one

  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: call Party(GetTriggerUnit())
And it work. I was like "oh my f**king God".
But this is Jass, right? Then I think Jad ( who create thread) wont be happy.:grin:

-- edit --
I understand it know. Cause in Jass it have //=== to separate upper thing and below. Well. Great work.

Mate, this is just like raping GUI :p
 
Level 5
Joined
Aug 9, 2012
Messages
119
by the way if

trigger 1
if condition true
called trigger 2,

then trigger 2
after all process
can it makes the trigger 1 skip the remaining action? before trigger 2 ends and back to trigger 1
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
by the way if

trigger 1
if condition true
called trigger 2,

then trigger 2
after all process
can it makes the trigger 1 skip the remaining action? before trigger 2 ends and back to trigger 1

You mean like this ?
  • Trigger 1
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game - Display to (All players) the text: hey
      • Trigger - Run Trigger 2 <gen> (ignoring conditions)
      • Skip remaining actions
      • Game - Display to (All players) the text: delilah
  • Trigger 2
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: there
Trigger above will only display "hey" and "there" - "delilah" won't be shown because it has been skipped ?

I can't quite understand what you are trying to ask.
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
@Mikagami, here is how what you want should work:

  • Untitled Trigger 001
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set temp_boolean = false
      • Game - Display to (All players) the text: TEST 1
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Whatever) Equal to True
        • Then - Actions
          • Trigger - Run Untitled Trigger 002 <gen> (checking conditions)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (temp_boolean) Equal to True
        • Then - Actions
          • -------- Continue the process HERE --------
          • Game - Display to (All players) the text: TEST Complete
        • Else - Actions
  • Untitled Trigger 002
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: TEST 2
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 10) Less than 5
        • Then - Actions
          • Set temp_boolean = true
        • Else - Actions

^ This will if the random number is lower than 5, make the trigger 1 continue the process where the comment is and if it is higher than 5, nothing will happen
 
Level 5
Joined
Aug 9, 2012
Messages
119
@defskull no... thts not what I mean, I mean run trigger 2 from trigger 1 then within trigger 2.... its make the rest of trigger 1 skip remaining action.... so if trigger 1 dont activated trigger 2, then its still have trigger/line to go....

@jad aaah thts it, I can passed condition, create var value and when the function back to trigger 1 I can set the condition to make it skip or not...

GOt it, thx
 
Status
Not open for further replies.
Top