• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Natives and Local variables ...

Status
Not open for further replies.
Level 29
Joined
Mar 10, 2009
Messages
5,016
What's the ExecuteFunc() native for? Why not just use call [function name]? According to Jasshelper manual,the ExecuteFunc() is used to initialize libraries; can it be done by calling the initializer too?

I'm not reading Jass manual yet but I think ExecuteFunc() can call funtions 'immediately' even with waits...

And another thing is,are functions from scope added to map header like functions from libraries so they can be used elsewhere?

I dont dont think you can use it elsewhere coz scopes are blockers...well
of course I maybe wrong...

*Pls dont be offended but I think you're asking the wrong guy here, Im still learning :)...
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Avoid using ExecuteFunc(), try to use TriggerEvaluate(a boolexprtrigger) instead (just pass the function thru a Condition(function) call ) because Vex's optimizer breaks it. It doesn't break TriggerEvaluate though.

I think the functions in a scope are unreliable as the scopes are compiled together and having one scope calling another will probably bug the compiling. That's what the "require" keyword within libraries are for, putting the library in top of the other so it will be 100% safe to use that function and no syntax errors.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
native TriggerEvaluate takes trigger whichTrigger returns boolean
This is the function he referd to (Correct).
try to use TriggerEvaluate(a boolexpr)
This is what he asks (WRONG).

baassee, please do more research or atleast some checking up before posting as mistakes like that really confuse people.

You need to attach a boolexpr to a trigger and pass the TriggerEvaluate function the trigger inorder to run code with it.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
Are these the same?, and which is better?...does it leak?...
Also, do we have to use "\\"???...

JASS:
function sfxtest takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local effect e
  set e = AddSpecialEffect("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl", GetUnitX(u), GetUnitY(u)) 
  call DestroyEffect(e)
  set u = null
  set e = null
endfunction
//===========================================================================
function InitTrig_sfx takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( t, function sfxtest )
    set t = null
endfunction

OR...

JASS:
function sfxtest takes nothing returns nothing
  local unit u = GetTriggerUnit()
  call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl", GetUnitX(u), GetUnitY(u)))
  set u = null
endfunction
//===========================================================================
function InitTrig_sfx takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( t, function sfxtest )
    set t = null
endfunction
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
Second one is better. And yes, you have to use double back-slashes. "\" denotes an escape sequence. See string literals for more information.

thank you, now my other question, when we code in JASS, usually we have this...

AddSpecialEffect(string model name, real x, realy)

so does anyone have a clue on where we can find the pattern for coding it, I mean for example, real x, how do you know that it's GetUnitX(blahhh)...I mean the FORMAT on how to do it?...

ex...widgets???...
 
thank you, now my other question, when we code in JASS, usually we have this...

AddSpecialEffect(string model name, real x, realy)

so does anyone have a clue on where we can find the pattern for coding it, I mean for example, real x, how do you know that it's GetUnitX(blahhh)...I mean the FORMAT on how to do it?...

ex...widgets???...

You mean the native list? You can either use JassCraft/vim/jEdit or something similar, or you can just use the TESH that is built in with JNGP. Also, if you need to know what to use, you can always make a trigger and add some GUI code and convert it to custom text. Then you just look up the BJ in any of those programs and it will show you what to do to inline it.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
No, I mean the FORMAT of coding like...

1. effecttype t in AdSpellEffect
2. You must put this one \\ instead of this one \
3. You must do like this "I2S (i)", NOT this "I2S ("i")

And alike...

And there are something called widget(or something like that), what are those?...

hmm...vim/JEdit?, I didnt know that...

EDIT:

Nvm, I got it...

you can always make a trigger and add some GUI code and convert it to custom text.

thanks Purge!
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Usually you don't use hashtables for making spells in vJASS, we got structs.

Structs aren't used for attaching data, hashtables are. Structs group data together, hashtables don't.
 
Optionally, you can use a unit indexer to give every unit an ID with a value between 1 and 8191. Then you can use this value as an index inside other arrays to store data there.
This is ofcourse only for attaching stuff to units, not other objects (and it can sometimes be a bit overkill to add an indexing library of 700 lines unless there is great need for it).
 
Status
Not open for further replies.
Top