syntax error

koeienboei

Member
Reaction score
4
I wrote this code:

Code:
TimerStart(t,0.01,false, 
function SetUnitPositionLocFacingLocBJ( 
	GetTriggerUnit(), 
	PolarProjectionBJ(
		GetUnitLoc(GetTriggerUnit()), 
		50, 
		AngleBetweenPoints(
			GetUnitLoc(GetTriggerUnit()), 
			Location(GetMouseTerrainX(), GetMouseTerrainY())
		)
	), 
	Location(GetMouseTerrainX(), GetMouseTerrainY()) 
)

In my code its actually all on one line

This is what should go in:
Code:
native TimerStart takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing

It starts a non-repeating timer t for 0.01 seconds and calls a function which moves a unit towards the mous location.

But this gives a syntax error... Im quite sure bout the ():rolleyes:
 

Romek

Super Moderator
Reaction score
964
You cannot pass values to a function called from a timer callback. You'll need to attach that data to the timer, and then retrieve it from within the callback function.
 

tooltiperror

Super Moderator
Reaction score
231
This is ZINC, isn't it? I think it supports anonymous functions now ...
 

Romek

Super Moderator
Reaction score
964
> this is not "C", this is JASS, you must use JASS syntax.
Thank you, Captain Obvious.

> This is ZINC, isn't it? I think it supports anonymous functions now ...
That's not an anonymous function. He's passing arguments via the TimerStart function.

> Are you using JASS? Because, I don't think that compiles in JASS? o.o
Hence the thread title.

> Why pass it on to the timer? The timer cannot be passed either right?
You can use [ljass]GetExpiredTimer()[/ljass] to retrieve the timer that expired, and hence anything you attached to it too. You can use TimerUtils too attach structs to timers (the system also provides dynamic timer recycling, which you should use). If you're using a high-frequency timer, I'd highly recommend using Timer32.
 
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