# HG changeset patch # User Wuzzy # Date 1525301644 -3600 # Node ID 9818052b6fcb9985fd84dfa5cd4fdfb794fbc32c # Parent e073a4197c60ed0ce46d2693031e979fbf44aae5 LuaLibraryTracker: reorg diff -r e073a4197c60 -r 9818052b6fcb LuaLibraryTracker.wiki --- a/LuaLibraryTracker.wiki Wed May 02 23:52:00 2018 +0100 +++ b/LuaLibraryTracker.wiki Wed May 02 23:54:04 2018 +0100 @@ -23,6 +23,8 @@ To see a commented example of `Tracker` in use by a script you can look at [https://hg.hedgewars.org/hedgewars/file/default/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua Random Weapons]. + + == Tracking functions == These functions must be called to start tracking stuff. *IMPORTANT:* The other functions will only work on tracked objects. So make sure you track the things you care about. @@ -32,15 +34,17 @@ === `trackDeletion(gear)` === Will stop keeping track of the gear (gears not tracked will be ignored). -=== `trackTeams()` === -Will start the tracking of teams, clans and hedgehogs (hogs can be tracked without this). You *must* call this function in `onGameStart` when you want to use any of the team or clan-related functions below. - === `trackHiding(gear)` === Will keep track of the given hedgehog gear when it becomes hidden (e.g. with `HideHog`). === `trackRestoring(gear)` === Will keep track of the given hedgehog gear when it becomes restored, i.e. no longer hidden (e.g. with `RestoreHog`). +=== `trackTeams()` === +Will start the tracking of teams, clans and hedgehogs (hogs can be tracked without this). You *must* call this function in `onGameStart` when you want to use any of the team or clan-related functions below. + + + == “`runOn`” functions == These functions are used to run a function on _tracked_ gears, teams and clans. @@ -62,10 +66,14 @@ === `runOnHogsInOtherClans(func, clan)` === Runs the function `func` on all tracked hedgehogs but those in the specified clan (`clan` = clan ID). + + == Helper functions == === `getFirstHogOfClan(clan)` === Returns the first hedgehog (alive or not) in the clan with clan ID `clan`. + + == Key-value storage == For tracked gears, teams and clans, you can assign an arbitrary number of values. Each tracked object has a simple key-value storage. This means, a tracked object has an arbitrary number of keys, each of which holds one arbitrary value. Any data type (besides `nil`) can be used for keys and values. Initially, all keys have the value `nil`.