HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

<Jass new gen> --method Timers?

04-01-2007, 11:13 AM#1
Blackroot
Hey- I'm wondering if there's a way to do this using structs:

Code:
struct Bleh
 private unit u
 private method Whoknowstimer takes nothing returns nothing
  call SetUnitFlyHeight(.u, GetUnitFlyHeight(.u) + 4)
 endmethod
 method Whoknows takes nothing returns nothing
  local timer t
  if(.u != null)
   call CreateTimer()
   call TimerStart(t, something, meh, bleh, method .Whoknowstimer)
  else
   set t = null
  endif
 endmethod
endstruct

Wondering if this works, and if it does how to you work it? :P
04-01-2007, 01:32 PM#2
Vexorian
yes and no.

You can do it with an static method

Collapse JASS:
struct Bleh
 private unit u
static  private method Whoknowstimer takes nothing returns nothing
  call SetUnitFlyHeight(.u, GetUnitFlyHeight(.u) + 4)
 endmethod
 method Whoknows takes nothing returns nothing
  local timer t
  if(.u != null)
   call CreateTimer()
   call TimerStart(t, something, meh, bleh, method Bleh.Whoknowstimer)
  else
   set t = null
  endif
 endmethod
endstruct

But since it is not an instance method, you would not pass the object's attributes to the timer and thus it will suck.


To solve this issue, I made TimeLib

http://www.wc3campaigns.net/pastebin...11353b4a512610

You can use timers in an object oriented way thanks to the TimeLib