questions with gamecache

Togrias

New Member
Reaction score
0
Hi, I've just recently started learning JASS and just wanna ask a question regarding gamecache

I read that gamecache can be used to link data and stuff to a handle. I'm trying to link two functions together. I'm refering to the tutorial JASS: Advanced Tips by Daelin.
http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=28217
JASS:
function Knockback takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = GetHandleUnit(t,caster)
local unit target = GetHandleUnit(t,target)
local real x1 = GetUnitX(caster)
local real y1 = GetUnitY(caster)
local real x2 = GetUnitX(target)
local real y2 = GetUnitY(target)
call SetUnitPosition(target, PolarProjectionX(x1, GetDistanceBetweenPoints(x1,y1,x2,y2)+10.00, GetAngleBetweenPoints(x1,y1,x2,y2)), PolarProjectionY(y1, GetDistanceBetweenPoints(x1,y1,x2,y2)+10.00, GetAngleBetweenPoints(x1,y1,x2,y2)))

set t = null
set caster = null
set target = null
endfunction

function Execute_Knockback takes nothing returns nothing
local timer t = CreateTimer()
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
call SetHandleHandle(t,caster, caster)
call SetHandleHandle(t,target, target)
call TimerStart(t, 0.035, true, function Knockback)
call TriggerSleepAction(0.5)
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
set caster = null
set target = null
endfunction


Here, the handle used to link the two functions together is a timer. However, I am intending to link two functions together to run concurrently, i.e. with no delay in between. What handle should I use for such a linkage? I'm not sure a Timer would accept a duration of 0.00 seconds and it seems rather counter-intuitive to me.

For example if I mimic the above code:


JASS:

function Sample takes nothing returns nothing
local timer t = CreateTimer()
local unit caster = GetTriggerUnit()
call SetHandleInt(t,"Caster",caster)
call TimerStart(t,0,false,null)
endfunction



Then when the timer expires I can (hypothetically) create a separate trigger and retrieve the handle using GetExpiredTimer()... But is there a simpler way? Again as I said the use of a timer with zero duration here is very counter-intuitive to me and I'm not even sure if it works... Thus my question is: what handle should I use and what should the script look like?
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Do you need the other function to run in another thread? If not you can just call the function and send the needed values as arguments.

If you need the function to run in another thread then I suggest that you use a trigger and use TriggerExecute. You don't have to create a new trigger each time but can use the same one. You can pass all needed values with globals or gamecache, I would suggest globals.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180

Cohadar

master of fugue
Reaction score
209
Hi, I've just recently started learning JASS and just wanna ask a question regarding gamecache

I read that gamecache can be used to link data and stuff to a handle. I'm trying to link two functions together.

Then when the timer expires I can (hypothetically) create a separate trigger and retrieve the handle using GetExpiredTimer()

He said gamecache, I automatically reply ABC
He said linking functions, I automatically reply ABC
He said retrieve GetExpiredTimer(), I automatically reply ABC.

ABC is not the answer to every question, but seems to be the answer to 80% of starting jass questions around here.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>ABC is not the answer to every question, but seems to be the answer to 80% of starting jass questions around here.
Sorry to interrupt. I have a small small question here.
Did he mentioned anything about vJass?
 

Cohadar

master of fugue
Reaction score
209
No, but the sooner he learns the better for him.
You know you don't have to know jass to be able to start learning vjass.

Besides even if he does not choose to use vJASS and/or ABC it is always good to learn that alternatives exist.

And I am not a vJASS fashist, I help people with non vJass code as well.

As a curiosity I can say that there is a version of ABC for plain jass,
witch I made for Mac users who cannot use NewGen,
but that version is not published (nor will be) because I decided it is more important for people to learn vJass than to use ABC.
 

Togrias

New Member
Reaction score
0
Thanks guys I used a global unit as my solution. As for VJass WorldEdit simply refuses to compile any of the VJass functions and I find it much of a hassle. I guess there are plenty of workarounds though.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top