Warcraft III resources & community, 2003–2006 · archived

JASS Tutorial

66 posts
#31
It removes the unit itself cleanly, but you still need to clear the variables pointing at that unit.

~Daelin
#32
ugh after reading the first few examples in your tut my mind is perma-boggled. you did that on purpose!
damn thats dash cunning of you...
:shock:

-maybe i deserve it :( -

but it is the most descriptive tut for jass ever...
#33
and how to carry local variables between local triggers or is it possibe?
#34
Yes it is, using Kattana's handlers system. Check my Defensive Matrix spell since it give an example about how they can be used. I will try to get some time to add that chapter too!

~Daelin
#35
Confusing only because I don't already know all of the terms, and I think that's the case for others who are confused. I finally figured out how to use multi-instancing after reading your tutorial twice and did it once on my own. :idea: Thanks a bunch.
#36
Finaly got around to asking theyse:

Lets say i had a trigger:


function A_001 takes nothing returns nothing
if (A > 1)
call DoNothing( )
else
set A = 1
endif
endfunction

function A_001_TEST takes nothing returns nothing
local real A = 1
call A_001()
endfunction

//================

function IniTrig_Amp_001 takes nothing returns nothing
local trigger t
set t = CreateTrigger( )
call TriggerAddAction( t, function Trig_ A_001_TEST)
endfunction


Probably doesnt work. But what im asking is, does that local variable still exist, or do i need to transfer it via: "takes var"?

And i notice, in the trigger editor, there is the name of the map, and when you click it, theres a box where comments usualy go that says:

Enter map-specific custom script code below. This text will be included in the map script after variables are declared and before any trigger code.

-Does this mean that you can call functions from it, rather than putting them into the script that calls it (Just so long as the call isint being made from this location)?

Btw great tutorial. ^,^ (Still working on your campaign?)
#37
No it doesn't work!

You must use HandleVars which use the blizzard bug(maybe it wasn't a real bug,maybe blizzard wanted that, nobody knows)

function H2I takes handle h returns integer
return h
return 0
endfunction

and

function I2H takes integer i returns handle
return i
return null
endfunction

or

if you instantly want to use them again
(maybe call triggerExecute(WhichTrigger) or ExecuteFunc("functionname"))
you can use blizzard globas as
bj_cineFadeContinueBlue
bj_forLoopBIndex
bj_lastCreatedGroup
bj_lastCreatedItem
bj_lastCreatedUnit
..
..
and more and more and more

Hope you understand
#38
I dont get what theyse I2H H2I do. How do they pass locals?

function H2I takes handle h returns integer
return h
return 0
endfuncion


This gives me a bunch of errors. And again, how is it used?

same for I2H. And im guessing theres a trick for real to handle ect. But i dont get how they work. You didint really explain it :P
#39
With H2I you can discribe a unit, a unit grou, and all other handles as integers and these Integers can be stored in a gamecache. If you load them, just reconvert them with I2H.

(You can't use I2H directly in you triggers, you must create extra functions which return the handle EXTENSIONS:

function GiveMeInt_GetUnit takes integer i returns unit
return I2H(GetStoredInteger(YourCacheHere,cathegory,..))
endfunction

)
#40
Ah ic, thank you very much ^,^.
#41
PM me if you have more problems with H2I and I2H or any jassish things, triggers.

Makes me "proud", I could help you.
:D
#42
Ok - Heres a question, you didint say much about multi-instacing spells. But to multi-instance a spell, all you need to do is make every variable a local, because locals are created per use right?

But, i got to thinking, if a local is created per use, couldent you use a local trigger, and then just use globals (So long as you set the value directly before the query)? So if you really didint want to use the handler system, you could just use a local trigger with global variables right?

(I dont see why you would, but it would be nice to know you could)

Also, for local arrays, how do you give them a set array amount? Like if i wanted a real array with 7 defualt slots:


local real array Alpha = 7


How do i set it correctly? (Also is this a cap of the array, or just its defaulty created amount?)

:P Lots of questions, ...Lots of time to :P.

Well thanks for the help in advanced, and thank you again bert.
#43
To set a array you must do following.

local integer array i //your given array 
local integer n=0 //you need this var as a counter
local integer d=7 //your defaultvalue
local integer c 
//how many values you want to
//adjust(beginning from 0)

loop
   exitwhen n>=c
   set [n]=d //your number 
   set n=n+1
endloop


Q1: Yes, locals are created per use.
Q2: Yes, but your global must be an array, and yoou must count the array index, so you'll need another global. That's lame.(I didn't actually get what you want to know. :?: )
Q3: look at the top, there is no other way to give locals default values. Blame Blizzard for that.

Hope I could help you. :roll:
#44
Err...

My question was that if you used a local trigger, could you make every other variable global, so you could pass them without a game cache?

And, you said every global is an array? >.>. Of course you could always make an array for one of every variable... But thats sooo confusing.

This was a dumb question anways... O_o
#45
Q1: Yes, you can. BUT only if you want to use it IMMEDIATLY, if not, the global can be overwritten by another of your triggers(maybe you use the var multiple times).

Q2: To prvent things like that, you must make your globals arrays and you need a counter for the array index. That was what you missunderstood.

Clear?