(info) This AI is still in early stages of development.

Object.uTardis()

Provides a way to attach multiple event listeners to a Warzone JS API Events & Timers.

 

Trivia

The TARDIS is from the UK Sci-Fi series "Dr Who". Aside from being able to time travel, the other unique feature of the TARDIS was that it's bigger on the inside than it is on the outside.

So, what does this mean for your script? If your script is just one big file written by you alone, uTardis() won't be much use. But as scripts become more complex and include libraries written by other people, the situation arises where more than one script wants to listen to the same event – that's where uTardis() comes in... it's bigger on the inside than it is on the outside! It lets you fit more event handlers on to the same event listener.

Early versions of uTardis had a "Parallel Universe" bug. The bug was cased by the ability in early releases to create a tardis within a tardis, which resulted in a recursive tardis loop, which had somewhat undesirable effects. Luckily the bug was fixed and you no longer have to worry about disintegrating the universe from within your Javascripts.

Syntax

uTardis(eventName);
 
// then define events in the usual way, only you can create multiple handlers for the event...
function eventName(params) { /* do stuff */ }
function eventName(params) { /* do other stuff */ }
function eventName(params) { /* do yet more stuff */ }
 
// the event handlers will be called in the order in which they were defined

Parameters

ParameterTypeMandatoryDescriptionUtil.js version
eventNameString(tick)

The name of the event as a string.

(warning) You must create the tardis before defining any event listeners.

(info) If you're using Vault.js, it will automatically create a load of tardis event handlers for you.

0.2

Improved in 0.3 and 0.4

Return value

Returns the object on which the tardis was created.

If in doubt, set the scope to global by using global.uTardis(eventName) as that's where Warzone expects it's event handlers to be. But you can create a tardis anywhere, eg. on your own objects to use it with your own custom events.

Example

Turn eventAttacked in to a tardis
uTardis("eventAttacked");
 
// then define handlers
function eventAttacked(victim,attacker) { /* do stuff */ }
// you can use any valid way of defining handlers, example:
global.eventAttacked = function(victim, attacker) { /* do more stuff */ }

Availability

This feature requires:

  • Util.js v0.4 and above
  • Can be accessed via global object/scope.

See also

Related articles:

  • Events & Timers – reference guide for all JS API events
  • global – reference to the global object/scope

Â