Scripting
From TibiaAuto Wiki
Contents |
[edit]
Introduction
Tibia Auto Scripting framework lets you easily write custom scripts that automate Tibia. The Tibia Auto Scripting framework is available since Tibia Auto version 1.10.0.
All python scripts put in the tascript subdirectory will be automatically loaded upon startup of TA. In this directory one can also find two complete modules of TA rewritten to the scripting framework (antylogout and autofisher).
[edit]
Kernel functions
All functions are divided into the six packages:
- tareader - responsible for memory related opeartions
- tasender - responsible for sending packagets to the server and the inject dll
- tamap - responsible for the map related operations
- taregexp - responsible for the regular expression library
- taalice - responsible for communication with the A.L.I.C.E.
- taitem - responsible for reading item information (tibiaauto-item.xml)
- takernel - responsible for manipulation of active modules (starting, stopping, etc.)
- tacrstat - responsible for fetching data from the creature statistics database
[edit]
tareader package
| Function | Arguments | Description |
|---|---|---|
| setProcessId | processId : int | Sets ID of the Tibia client process. |
| readSelfCharacter | () | Returns information about the currently logged character. |
| readContainer | containerNr : int | Returns information about the container containerNr'. |
| readContainerItem | containerNr : int, itemNr : int | Returns information about item itemNr in container containerNr. |
| writeSelfLightPower | power : int | Sets power of light emited by the currently logged character. |
| writeSelfLightColor | color : int | Sets light color emited by the currently logged character. |
| readSelfLightPower | () | Returns power of light of the currently logged character. |
| readSelfLightColor | () | Returns color of light of the currently logged character. |
| cancelAttackCoords | () | Cancels tibia map 'goto' target. |
| writeGotoCoords | x : int, y : int, z : int | Orders character to go to the location (x,y,z) using Tibia Client map. |
| getLoggedCharNr | () | Returns slot number used by the currently logged character (might be used for further call to tareader.readVisibleCreature()). |
| getSelfEventFlags | () | Returns event flags for the logged character (attack sign, burning, mana shield, etc.). |
| writeVisibleCreatureName | creatureNr : int, name : string | Changes name of the creature creatureNr to name. Note: influences the following modules: auto attack, auto go/log, creature info, auto uh. |
| getTradeItemPartner | itemNr : int | Returns trade partner's item number itemNr. |
| getTradeItemSelf | itemNr : int | Returns self item number itemNr. |
| getTradeCountPartner | () | Returns number of items partner is trading. |
| getTradeCountSelf | () | Returns number of items myself is trading. |
| getAttackedCreature | () | Returns Tibia ID of the creature being attacked. |
| GetLoggedChar | processId : int | Returns logged character name from the Tibia client process ID processId |
| readBattleListMax | () | Returns the maximum number of all creatures being visible on the battle list. |
| readBattleListMin | () | Returns the minimum number of all creatures being visible on the battle list. |
| readVisibleCreature | nr : int | Returns information about creature number nr. |
| readItem | address : int | Reads item information from address address; used for e.g. reading items in hands. |
| getCharacterByTibiaId | tibiaId : int | Returns information about character with ID tibiaId. |
| mapGetPointItemsCount | x : int, y : int, z : int | Returns number of object laying on the map on position (x,y,z) relative to the player's. |
| mapGetPointItemId | x : int, y : int, z : int, pos : int | Returns tile id of the object laying on (x,y,z) on stack position pos. |
| mapSetPointItemsCount | x : int, y : int, z : int, count : int | Sets number of object laying on the map on position (x,y,z) relative to the player's to count. |
| mapSetPointItemId | x : int, y : int, z : int, pos : int, tileId : int | Sets tile id of object on position (x,y,z) stack position pos to tileId. |
| mapGetPointItemExtraInfo | x : int, y: int, z : int, pos : int offset : int | Returns extra tile information on position (x,y,z) stack position pos and offset offset (offset usually equals to 0, 4 or 8). |
| getCurrentTm | () | Returns current tibia timestampl. |
| setRemainingTilesToGo | tilesToGo : int | Sets remaining tiles to go on the tibia map to tilesToGo. |
| setMemIntValue | address : int, value : in | Sets value of memory on address address to value value. |
| getMemIntValue | address : int | Returns value of memory from address address. |
| writeEnableRevealCName | () | Activates showing creature name on different floors. |
| writeDisableRevealCName | () | Disables showing creature name on different floors. |
| getProcessId | () | Returns Tibia client process id. |
| getKernelMainVersion | () | Returns kernel main version. |
| getKernelPatchVersion | () | Returns kernel patch version. |
| writeCreatureLightPower | creatureNr : int, power : int | Sets light power of creature creatureNr to power power. |
| writeCreatureLightColor | creatureNr : int, color : int | Sets light color of creature creatureNr to color color. |
| readCreatureLightPower | creatureNr : int | Returns power of light of the creature creatureNr. |
| readCreatureLightColor | creatureNr : int | Returns color of light of the creature creatureNr. |
| getTibiaTile | tileId : int | Returns information about tile with ID tileId. |
| setGlobalVariable | name : string, value : string | Sets global variable name to value value. |
| getGlobalVariable | name : string | Returns global variable name value. |
| readMiniMap | mapNr : int | Returns information about loaded minimap with number mapNr. |
| readMiniMapPoint | mapNr : int, pointNr : int | Returns information about point pointNr on minimap mapNr. |
| setMainWindowText | text : string | Sets text (caption) on the main tibia client window. |
| setMainTrayText | text : string | Sets text (hint) on the tibia auto shell tray icon. |
| getPlayerModeAttackPlayers | () | Returns player mode of attacking players (attack, no attack). |
| getPlayerModeAttackType | () | Returns player attack mode (full def, balanced, full attack). |
| getPlayerModeFollow | () | Returns player follow mode (follow, no follow). |
| getOpenWindowName | () | Returns name of open window. |
| getConnectionState | () | Returns state of tcp/ip connection to the main/login server. |
| setXRayValues | (v1 : int, v2 : int) | Sets two XRay values. |
| getXRayValue1 | () | Returns value of xray/1. |
| getXRayValue2 | () | Returns value of xray/2. |
| writeCreatureDeltaXY | (creatureNr : int, deltaX : int, deltaY : int) | Sets graphical delta for creatureNr to (deltaX,deltaY) pixels. |
| setAttackedCreature | (tibiaId : int) | Sets in memory currently attacked creature (sets the red square around the character). |
| getCreatureDeltaX | (creatureNr : int) | Get graphical deltaX of the creatureNr.. |
| getCreatureDeltaY | (creatureNr : int) | Get graphical deltaY of the creatureNr.. |
[edit]
tasender package
| Function | Arguments | Description |
|---|---|---|
| moveObjectBetweenContainers | objectId : int, sourceContNr : int, sourcePos : int, targetContNr : int, targetPos : int, qty : int | Moves qty amount of items from container sourceContNr position sourcePos to container targetContNr' position targetPos |
| moveObjectFromFloorToContainer | objectId : int,sourceX : int,sourceY : int,sourceZ : int,targetContNr : int,targetPos : int,quantity : int | Move object from floor to container. |
| moveObjectFromContainerToFloor | objectId : int, contNr : int, pos : int, x : int, y : int, z : int,quantity : int | Move object from container to floor. |
| moveObjectFromFloorToFloor | objectId : int, srcX : int, srcY : int, srcZ : int, destX : int, destY : int, destZ : int, quantity : int | Move object from floor to floor. |
| useWithObjectFromContainerOnFloor | sourceObjectId : int, sourceContNr : int, sourcePos : int, targetObjectId : int,targetX : int, targetY : int, targetZ : int, method : int, extraInfo : int | Use object from containter on floor (e.g. fish fish). For 'method' use value '2'. 'sourceContNr' is universal container number which for backpacks is 0x40+backpack number. |
| castRuneAgainstCreature | contNr : int, itemPos : int, runeObjectId : int, creatureId : int, method : int | Cast rune against creature (using creature id location). For 'method' use value '2'. 'contNr' is 'univesal' container number which for backpacks is 0x40+backpack number. |
| castRuneAgainstHuman | contNr : int, itemPos : int, runeObjectId : int, targetX : int, targetY : int, targetZ : int, method : int | Cast rune against human (using x,y,z location). For 'method' put '2'. This method of casting runes is obsolete as humans can be now targeted using castRuneAgainstCreature() with better accuracy. |
| sendTAMessage | s : string | Sends (via loopback) information from user 'Tibia Auto' to myself. |
| useItemOnFloor | objectId : int, x : int, y : int, z : int | Use item laying on floor. |
| useItemInContainer | objectId : int, containerNr : int, pos : int | Uses object with id objectId from container containerNr on position pos. |
| openContainerFromFloor | objectId : int, x : int, y : int, z : int, targetContainer : int | Opens container with object id objectId laying on (absolute) position (x,y,z) as container targetContainer. |
| openContainerFromContainer | objectId : int, contNrFrom : int, contPosFrom : int, targetContainer : int | Opens container with object id objectId from container contNrFrom' position contPosFrom and put it as container targetContainer. |
| say | s : string | Says s. |
| sayWhisper | s : string | Whispers s. |
| sayYell | s : string | Yells s. |
| sayNPC | s : string | Says something on the NPC. |
| npcBuy | objectId : int, qty : int | Buys from NPC objectId in amount of qty. |
| npcSell | objectId : int, qty : int | Sell to NPC objectId in amount of qty. |
| tell | s : string, player : string | Tells s to player. |
| sayOnChan | s : string, chanId1 : int, chanId2 : int | Says s on channel with id chanId1 and chanId2. |
| logout | () | Logs out of Tibia. |
| walkOnTAMap | x : int, y : int, z : int | Walks on the tibia auto map to point (x,y,z). |
| closeContainer | nr : int | Closes container nr.. |
| attackMode | mode : int, follow : mode | Changes attack (full attack, balanced, full def) and follow (follow, no follow) modes. |
| attack | tibiaId : int | Attacks creature with ID tibiaId. |
| turnLeft | () | Turns face west. |
| turnRight | () | Turns face east. |
| turnUp | () | Turns face north. |
| turnDown | () | Turns face south. |
| sendCreatureInfo | name : string, line1 : string, line2 : string | Sets the first and the second line of information for a creature with name name. |
| look | x : int, y : int, z : int, objectId : int | Looks on (absolute) position (x,y,z) on object objectId. |
| ignoreLook | ts : int | Ignores 'You see...' messages until ts (in seconds since the Epoch). Used for preventing 'You see...' when the creature info is active. |
| sendAutoAimConfig | active : int, onlyCreatures : int, aimPlayersFromBattle :int | Sends configuration of auto aim to the inject dll. |
| sendClearCreatureInfo | () | Clears all currently stored creature info cache. |
| enableCName | enable : int | Enables/disables character name hack |
| sendAttackedCreatureToAutoAim | attackedCreature : int | Sends attacked creature ID to the inject dll (for auto aim purpose). |
[edit]
tamap package
| Function | Arguments | Description |
|---|---|---|
| removePointAvailable | x : int, y : int, z : int | Sets point (x,y,z) as not available for walking. |
| prohPointClear | () | Clears the 'prohibited' points list for a one-time goto lookup. |
| prohPointAdd | x : int, y : int, z : int | Sets point (x,y,z) as a prohibited for a one-time goto lookup. |
| getPointUpDown | x : int, y : int, z : int | Gets updown (hole, ropespot, etc.) information for point (x,y,z). |
| getPointUpDownNoProh | x : int, y : int, z : int | Gets updown (hole, ropespot, etc.) information for point (x,y,z); proh points are ignored. |
| setPointUpDown | x : int, y : int, z : int, updown : int | Sets updown information for point (x,y,z). |
| getPrevPointZ | x : int, y : int, z : int | Used during map goto algorithm to fetch Z coord for previous walk point. |
| getPrevPointY | x : int, y : int, z : int | Used during map goto algorithm to fetch Y coord for previous walk point. |
| getPrevPointX | x : int, y : int, z : int | Used during map goto algorithm to fetch X coord for previous walk point. |
| clearPrevPoint | () | Clears previous point list |
| setPrevPoint | x : int, y : int, z : int, prevX : int, prevY : int, prevZ : int | Used only during path finding algorithm. Sets point (prevX, prevY, prevZ) to be previous point to (x,y,z). |
| clear | () | Clears all map information. |
| setPointAsAvailable | x : int, y : int, z : int | Sets point (x,y,z) as available for walking. |
| isPointAvailable | x : int, y : int, z : int | Returns information whether point (x,y,z) is available for walking, with regard to the prohibited point list. |
| isPointAvailableNoProh | x : int, y : int, z : int | Returns information whether point (x,y,z) with NO regard to the prohibited point list. |
| size | () | Returns number of map points registered. |
[edit]
taregexp package
| Function | Arguments | Description |
|---|---|---|
| match | s : string, regexp : string | Checks whether s matches regexp. |
[edit]
taalice package
| Function | Arguments | Description |
|---|---|---|
| respond | message : string, id : string | Responde (using ALICE framework) to message message from character/channel (communication id) id. |
[edit]
taitem package
| Function | Arguments | Description |
|---|---|---|
| getName | objectId : int | Returns name of object objectId. |
| getObjectId | name : string | Returns id of object with name name. |
| getValueForConst | code : string | Returns value of constant with name const (from the -items.xml). |
| refreshItemLists | () | Refreshes cache of items from the xml file. |
| getCorpseIdByCreatureName | name : string | Returns ID of corpse (from the <corpses> section of the -items.xml). |
| getItemsItems | nr : int | Returns name of an item of number nr (for iteration over all available items). |
| getItemsItemsId | nr : int | Returns id of an item of number nr (for iteration over all available items). |
| getItemsItemsCount | () | Returns number of items in the -items.xml file. |
| getItemsFood | nr : int | Returns name of a food entry of number nr. |
| getItemsFoodId | nr : int | Returns ID of a food entry of number nr. |
| getItemsFoodCount | () | Returns amount of food entries in the -items.xml file. |
| getItemsCorpses | nr : int | Returns name of a corpse entry of number nr. |
| getItemsCorpsesId | nr: int | Returns ID of a corpse entry of number nr. |
| getItemsCorpsesCount | () | Returns amount of corpse entries in the -items.xml file. |
| getItemsLooted | nr : int | Returns name of a loot entry of number nr. |
| getItemsLootedId | nr : int | Returns ID of a loot entry of number nr. |
| getItemsLootedCount | () | Returns amount of looted entries in the -items.xml file. |
[edit]
takernel package
| Function | Arguments | Description |
|---|---|---|
| startModule | nr : int | Start module with number nr. |
| stopModule | nr : int | Stop module with number nr. |
| getModuleCount | () | Returns count of modules which are registered by TA kernel. |
| getModuleName | nr : int | Returns short name of module (name of dll). |
| getModuleDesc | nr : int | Returns description of module (call to getName() of the module). |
| isModuleStarted | nr : int | Returned information whether module nr is started or stopped. |
| getModuleVersion | nr : int | Returns version of module (call to getVersion() of the module). |
| startPythonModule | nr : int | Enables python script with number nr. |
| stopPythonModule | nr : int | Disables python script with number nr. |
| getPythonModuleCount | () | Returns count of python scripts which are registered by TA scripting. |
| getPythonModuleName | nr : int | Returns name (file name) of python script with number nr. |
| isPythonModuleStarted | nr : int | Returns information whether python script nr is started or stopped. |
| getPythonModuleDesc | nr : int | Returns description of python script nr (call to getName() of the script). |
| getPythonModuleVersion | nr : int | Returns version of python script nr (call to getVersion() of the script). |
[edit]
tacrstat package
| Function | Arguments | Description |
|---|---|---|
| findCreatureStatForLocationCount | x : int, y : int, z : int | Returns amount of creatre stat entries on tile (x,y,z). |
| findCreatureStatForLocationTibiaId | x : int, y : int, z : int, pos : int | Returns tibia id of the i'th creature stat entry from tile (x,y,z). |
| findCreatureStatForLocationName | x : int, y : int, z : int, pos : int | Returns name of the i'th creature stat entry from tile (x,y,z). |
| findCreatureStatInArea | x : int, y : int, z : int, rangeXY : int, rangeZ : int | Returns a distinct list of creature names which are in the area of (x+/-rangeXY,y+/-rangeXY,z+/-rangeZ). |
[edit]
Callback Function Types
| Type | Runtime parameters | Reg. parameters | Description |
|---|---|---|---|
| 0 | params | interval | Kernel calls the function every "interval" miliseconds |
| 1 | params,(type,channel,nick,message) | () | Kernel calls the function after message is received |
| 2 | params,message | () | Kernel calls the function after message starting from %ta is sent from the client |

