SetTimer Shared function

From Gothic 2 Online: Wiki
Jump to navigation Jump to search

This function was added in version: 0.0.0

NOTE! Timers are responsible for performing specific code, after specified time.

Create a new timer.


int setTimer(function callback, int time, int repeatTimes [, element data])

Required Arguments

  • callback: The function, which will be called after timeout.
  • time: Time to wait as milliseconds.
  • repeatTimes: The number of timer execution. If value is 0, then repeat forever.

Optional Arguments

  • data: Any type of data, which will be parameter of callback function.


The id of the created timer.


local counter = 0;

local id = setTimer(function()
	print(++counter); // after every timer calling variable counter will be increased by 1
}, 1000, 0);

Related functions