LuaLibraryTracker.wiki
changeset 1369 9818052b6fcb
parent 1368 e073a4197c60
child 1370 12e73b288cf0
equal deleted inserted replaced
1368:e073a4197c60 1369:9818052b6fcb
    21 This will kill all hogs if a target is destroyed.
    21 This will kill all hogs if a target is destroyed.
    22 
    22 
    23 To see a commented example of `Tracker` in use by a script you can look at
    23 To see a commented example of `Tracker` in use by a script you can look at
    24 [https://hg.hedgewars.org/hedgewars/file/default/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua Random Weapons].
    24 [https://hg.hedgewars.org/hedgewars/file/default/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua Random Weapons].
    25 
    25 
       
    26 
       
    27 
    26 == Tracking functions ==
    28 == Tracking functions ==
    27 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.
    29 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.
    28 
    30 
    29 === `trackGear(gear)` ===
    31 === `trackGear(gear)` ===
    30 Will keep track of the gear.
    32 Will keep track of the gear.
    31 
    33 
    32 === `trackDeletion(gear)` ===
    34 === `trackDeletion(gear)` ===
    33 Will stop keeping track of the gear (gears not tracked will be ignored).
    35 Will stop keeping track of the gear (gears not tracked will be ignored).
    34 
    36 
    35 === `trackTeams()` ===
       
    36 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.
       
    37 
       
    38 === `trackHiding(gear)` ===
    37 === `trackHiding(gear)` ===
    39 Will keep track of the given hedgehog gear when it becomes hidden (e.g. with `HideHog`).
    38 Will keep track of the given hedgehog gear when it becomes hidden (e.g. with `HideHog`).
    40 
    39 
    41 === `trackRestoring(gear)` ===
    40 === `trackRestoring(gear)` ===
    42 Will keep track of the given hedgehog gear when it becomes restored, i.e. no longer hidden (e.g. with `RestoreHog`).
    41 Will keep track of the given hedgehog gear when it becomes restored, i.e. no longer hidden (e.g. with `RestoreHog`).
       
    42 
       
    43 === `trackTeams()` ===
       
    44 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.
       
    45 
       
    46 
    43 
    47 
    44 == “`runOn`” functions ==
    48 == “`runOn`” functions ==
    45 These functions are used to run a function on _tracked_ gears, teams and clans.
    49 These functions are used to run a function on _tracked_ gears, teams and clans.
    46 
    50 
    47 === `runOnGears(func)` ===
    51 === `runOnGears(func)` ===
    60 Runs the function `func` on all tracked hedgehogs in the specified clan (`clan` = clan ID).
    64 Runs the function `func` on all tracked hedgehogs in the specified clan (`clan` = clan ID).
    61 
    65 
    62 === `runOnHogsInOtherClans(func, clan)` ===
    66 === `runOnHogsInOtherClans(func, clan)` ===
    63 Runs the function `func` on all tracked hedgehogs but those in the specified clan (`clan` = clan ID).
    67 Runs the function `func` on all tracked hedgehogs but those in the specified clan (`clan` = clan ID).
    64 
    68 
       
    69 
       
    70 
    65 == Helper functions ==
    71 == Helper functions ==
    66 === `getFirstHogOfClan(clan)` ===
    72 === `getFirstHogOfClan(clan)` ===
    67 Returns the first hedgehog (alive or not) in the clan with clan ID `clan`.
    73 Returns the first hedgehog (alive or not) in the clan with clan ID `clan`.
       
    74 
       
    75 
    68 
    76 
    69 == Key-value storage ==
    77 == Key-value storage ==
    70 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`.
    78 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`.
    71 
    79 
    72 === `getGearValue(gear, key)` ===
    80 === `getGearValue(gear, key)` ===