• 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.

[JASS] A nice and easy noob question :)

Status
Not open for further replies.
Level 6
Joined
Jan 2, 2007
Messages
189
Hey, I JUST started learning JASS (last night actually) and I am obviously a little confused. My main concern is how do I make JASS 'execute'.

Like this:

Code:
function variable_test takes nothing returns nothing
  local unit array A
set A[1] = GetTriggerUnit()
    call KillUnit(A[1])
set A[1] = null
endfunction

From what I understand, this should kill the triggering unit. But how do I:
a) Determine the triggering unit
b) Make this code "execute". (sorry if that isn't clear. I have used GUI for alsmost 4 years now and I dont have a better way of explaining it). Like if I wanted to kill a "unit" after 5 seconds. What makes the function run after 5 seconds?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
function zomg takes nothing returns nothing
local unit a = GetTriggerUnit()
call TriggerSleepAction(2)
call KillUnit(a)
endfunction

you call it like
call zomg()

if you put call zomg() to your actions it will kill triggering unit after 2 seconds for short but trigger will wait for 2 seconds so you need to put it bottom of trigger

Triggering units determine on trigger encounters
like a trigger that registered for spell cast gets executed
and GetTriggerUnit() becomes the caster

Some Other Information: functions executed inside functions affects the parent function like if you call zomg() in a function your parent function will wait too UNLESS you dont use ExecuteFunc("zomg")
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Some Other Information: functions executed inside functions affects the parent function like if you call zomg() in a function your parent function will wait too UNLESS you dont use ExecuteFunc("zomg")
In other words, if you call a function, the function will be executed in the same thread. On the other hand, if you execute a function using ExecuteFunc or TriggerExecute, a new thread will be created, and the function will be executed at the same time as the calling function...

Kind of hard to understand...
 
Level 3
Joined
Sep 4, 2007
Messages
49
Thread is basically a chain of executions, and when you make a "new" thread you create another chain of executions which has various effects depending on what you are doing (it can prevent bugs for example such as damage requirzion in damagedetect systems)
 
Status
Not open for further replies.
Top