Python Functions
From TibiaAuto
Recently completed
NOTE: all indexing for both Tibia and TA start from 0.
Also, any functions that send information to Tibia deal with absolute values for position and containers
Absolute position will range in the 10,000's for the x and y values.
Absolute container indices start at 0x40. 0x00 - 0x10 are your inventory slots such as arrow, right hand, etc.
If there is any confusion about what to put as parameters, test the function out in TA's IDLE environment or try and find examples of their use in other scripts.
Contents |
tibiaauto
| Function Name | Parameters | Description |
|---|---|---|
| registerPlugin | (classobj classPointer) | Adds the class of classPointer to the list of python scripts available in TA. The class must satisfy criteria detailed in the Conventions section |
tareader
| Function Name | Parameters | Description |
|---|---|---|
| setProcessId | (int processId) | Changes the process TA recognizes as the Tibia client to processId |
| readSelfCharacter | () | Returns all known information about the currently logged in character |
| readContainer | (int containerNr) | Returns information for the container containerNr(which ranges from 0-14) |
| readContainerItem | (int containerNr,int pos) | Returns information for the item in containerNr(which ranges from 0-14) at pos |
| writeSelfLightPower | (int value) | Sets the brightness to value |
| writeSelfLightColor | (int value) | Sets the colour to value and accepts colours 0-255 used in Enable_Light |
| readSelfLightPower | () | Returns current light brightness |
| readSelfLightColor | () | Returns current light colour |
| cancelAttackCoords | () | Stops character movement and sets the goto coordinates to 0 |
| writeGotoCoords | (int x,int y,int z) | Sets the goto coordinates to x,y,z |
| getLoggedCharNr | () | Returns the creature number of the currently logged in character |
| getSelfEventFlags | () | Returns the condition flags for the character(fire,poison,logout block) |
| writeVisibleCreatureName | (int chNr,string name) | Sets the in-game name of the creature chNr to name |
| getTradeItemPartner | (int nr) | Returns information for the item at pos in the partner trade container |
| getTradeItemSelf | (int nr) | Returns information for the item at pos in your own trade container |
| getTradeCountPartner | () | Returns the number of items in the partner trade container |
| getTradeCountSelf | () | Returns the number of items in your own trade container |
| getAttackedCreature | () | Returns the tibiaId of the currently attacked creature |
| setAttackedCreature | (int tibiaId) | Tells the client to put a red box around creature tibiaId. Doesn't do much else and does not attack. Look in the Taender section for that. |
| getFollowedCreature | () | Returns the tibiaId of the currently followed creature |
| setFollowedCreature | (int tibiaId) | Tells the client to put a green box around creature tibiaId. Doesn't do much else. |
| GetLoggedChar | (int processId) | Returns the name of the currently logged in character |
| readBattleListMax | () | Returns the highest creature number of a creature in the battle list(used for efficient iteration over creatures) |
| readBattleListMin | () | Returns the lowest creature number of a creature in the battle list(used for efficient iteration over creatures) |
| readVisibleCreature | (int nr) | Returns information for the creature nr |
| readItem | (int locationAddress) | Returns information for an item at memory address locationAddress |
| getCharacterByTibiaId | (int tibiaId) | Searches and returns the info for the creature matching tibiaId |
| mapGetPointItemsCount | (int x, int y, int z) | Returns the number of items at the relative coordinate x,y,z |
| mapGetPointItemId | (int x, int y, int z, int stackNr) | Returns info for the item at position stackNr on relative coordinate x,y,z |
| mapSetPointItemsCount | (int x, int y, int z,int count) | Sets the number of items at the relative coordinate x,y,z to count |
| mapSetPointItemId | (int x, int y, int z, int stackNr, int tileId) | Sets the item id at position stackNr on relative coordinate x,y,z to tileId |
| mapGetPointItemExtraInfo | (int x, int y, int z, int stackNr,int extraPos) | Returns an extra integer for item at position stackNr on relative coordinate x,y,z extraPos*4 bytes past item end(0 is itemId, 1 is quantity/charId, 2 is usually 0) |
| mapGetPointStackIndex | (int x, int y, int z, int stackNr) | Returns the visual index of an item as seen in the Tibia client at internal position stackNr(usually in order of what you would drag off first staring with items, then players, then immovable tiles) |
| getCurrentTm | () | Gets the time of Tibia's internal client clock measured in miliseconds since the client was started |
| setRemainingTilesToGo | (int val) | When walking by clicking on a point, sets the number of steps it thinks it needs to take before sending another walk packet to val(max is 15) |
| setMemIntValue | (int address,int value) | Changes the 4-byte value of the number at address to value (0x01020304 saves as 04 03 02 01 which is appropriate for integers but not text) |
| getMemIntValue | (int address) | Retrieves the 4-byte value at address (FF 5D 01 00 is seen as 0x00015DFF which is appropriate for integers but not text) |
| writeEnableRevealCName | () | Edits Tibia's memory to reveal the creature names on different floors |
| writeDisableRevealCName | () | Edits Tibia's memory to hide the creature names on different floors |
| getProcessId | () | Returns the process id TA is using for the Tibia client |
| getKernelMainVersion | () | Returns TA's kernel version |
| getKernelPatchVersion | () | Returns TA's Patch version |
| writeCreatureLightPower | (int creatureNr,int value) | Sets the brightness for creatureNr to value |
| writeCreatureLightColor | (int creatureNr,int value) | Sets the colour for creatureNr to value and accepts colours 0-255 used in Enable_Light |
| readCreatureLightPower | (int creatureNr) | Returns current light brightness for creatureNr |
| readCreatureLightColor | (int creatureNr) | Returns current light colour for creatureNr |
| getTibiaTile | (int tileNr) | Returns all tibiaauto-items.xml information for tileNr |
| setGlobalVariable | (string name,string value) | Sets a global variable within TA to a certain string (internal values include "caveboot_halfsleep" and "caveboot_fullsleep" which can be set to "true" or "false") |
| getGlobalVariable | (string name) | Returns the string associated with the global TA variable |
| readMiniMap | (int nr) | Tibia keeps 10 *.map files in memory, this returns the map coordinates for the map store in slot nr along with the number of labels on the minimap |
| readMiniMapPoint | (int mapNr,int pointNr) | Returns an absolute coordinate and name of a label marked on minimap mapNr at index pointNr |
| setMainWindowText | (string text) | Changes the title of the Tibia client window to text |
| setMainTrayText | (string text) | Changes the text in the tool tip of the TA tray icon to text |
| getPlayerModeAttackPlayers | () | Returns a value of 1 if the unmarked character safety is on and 0 if the safety is off |
| getPlayerModeAttackType | () | Returns a value if 1 for full attack, 2 for balanced and 3 for full defense |
| getPlayerModeFollow | () | Returns 0 if follow is off and 1 if follow is on |
| getOpenWindowName | () | Returns the title of a subwindow within Tibia (such as "Quest log") |
| getConnectionState | () | Returns a value between 0 and 8 where 8 is connected, and 0 is disconnected. Other values signify a connection is in progress. |
| setXRayValues | (int v1,int v2) | Default is (7,2). Sets the above-ground floor index to 'v1' and the underground floor index to 'v2' |
| getXRayValue1 | () | Returns the delta index of the floor while the character is above-ground (8 is one higher) |
| getXRayValue2 | () | Returns the delta index of the floor while the character is underground (3 is one higher) |
| writeCreatureDeltaXY | (int creatureNr, int deltaX, int deltaY) | Sets the intermediate walking state of creatureNr to deltaX pixels right and deltaY pixels down |
| getCreatureDeltaX | (int creatureNr) | Gets the intermediate walking state of creatureNr |
| getCreatureDeltaY | (int creatureNr) | Gets the intermediate walking state of creatureNr |
| readVIPEntry | (int vipNr) | Gets information about the VIP entry at vipNr. A nonexistent VIP has a blank name. |
| mapGetPointTopPos | (int x, int y, int z) | Returns the index of the item that is visibly on top of the relative position x,y,z in the Tibia client(the index of the item that would move if you dragged sometihng off the tile |
tasender
| Function Name | Parameters | Description |
|---|---|---|
| useWithObjectFromFloorOnFloor | (int sourceObjectId,int sourceX,int sourceY,int sourceZ,int targetObjectId,int targetX,int targetY,int targetZ, int method=2) | This uses item sourceObjectId on ground tile sourceX,sourceY,sourceZ on another object targetObjectId on targetX,targetY,tragetZ. (Like using a fishing rod placed underneath you on water) |
| useWithObjectFromFloorInContainer | (int sourceObjectId,int sourceX,int sourceY,int sourceZ,int targetObjectId,int targetContNr,int targetPos, int method=2) | This uses item sourceObjectId on ground tile sourceX,sourceY,sourceZ on another object targetObjectId in targetContainerNr at targetPos. (Not used very often) |
| useWithObjectFromContainerInContainer | (int sourceObjectId,int sourceContNr,int sourcePos,int targetObjectId,int targetContNr,int targetPos, int method=2) | This uses item sourceObjectId in sourceContainerNr at sourcePos on another object targetObjectId in targetContainerNr at targetPos. (For carving ice cubes) |
| useWithObjectFromContainerOnFloor | (int sourceObjectId,int sourceContNr,int sourcePos,int targetObjectId,int targetX,int targetY,int targetZ, int method=2) | This uses item sourceObjectId in sourceContainerNr at sourcePos on another object targetObjectId on targetX,targetY,tragetZ. (Like using a fishing rod on water) |
| useWithObjectOnFloor | (int sourceObjectId,int targetObjectId,int targetX,int targetY,int targetZ, int method=2) | This uses item sourceObjectId on another object targetObjectId on targetX,targetY,tragetZ from a closed backpack. (Like using a rune on a tile) |
| useWithObjectInContainer | (int sourceObjectId,int targetObjectId,int contNr,int itemPos, int method=2) | This uses item sourceObjectId on another object targetObjectId in targetContainerNr at targetPos from a closed backpack. |
| moveObjectFromFloorToFloor | (int objectId, int srcX, int srcY, int srcZ, int destX, int destY, int destZ,int quantity) | Moves quantity items objectId from location srcX,srcY,srcZ to location destX,destY,destZ |
| moveObjectFromFloorToContainer | (int objectId,int sourceX,int sourceY,int sourceZ,int targetContNr,int targetPos,int quantity) | Drags quantity items objectId from location srcX,srcY,srcZ to targetContNr at targetPos(Item automatically goes to first slot or gets put into a subcontainer) |
| moveObjectBetweenContainers | (int objectId,int sourceContNr,int sourcePos,int targetContNr,int targetPos, int qty) | Drags quantity items objectId from sourceContNr at sourcePos to targetContNr at targetPos(Item automatically goes to first slot or gets put into a subcontainer) |
| moveObjectFromContainerToFloor | (int objectId, int contNr, int pos, int x,int y, int z, int quantity) | Drags quantity items objectId from sourceContNr at sourcePos to location x,y,z(Item automatically goes to first slot or gets put into a subcontainer) |
| castRuneAgainstCreature | (int contNr, int itemPos, int runeObjectId, int creatureId, int method) | Uses any item runeObjectId from contNr at itemPos on creatureId |
| castRuneAgainstHuman | (int contNr, int itemPos, int runeObjectId, int targetX, int targetY, int targetZ, int method) | Uses any item runeObjectId from contNr at itemPos to tile targetX,targetY,targetZ |
| useItemOnCreature | (int objectId, int creatureId) | Uses item objectId from a closed backpack on creatureId |
| useItemFromContainerOnCreature | (int objectId, int contNr, int itemPos, int creatureId) | Uses item objectId from contNr at itemPos on creatureId |
| useItemFromFloorOnCreature | (int objectId, int x, int y, int z, int creatureId) | Uses item objectId from location x,y,z on creatureId |
| sendTAMessage | (string msg) | Loops an internal text message msg to your client that only you can see |
| useItem | (int objectId) | Uses an item objectId from a closed backpack |
| useItemOnFloor | (int objectId, int x, int y, int z) | Uses an item objectId at location x,y,z |
| useItemInContainer | (int objectId, int contNr, int pos) | Uses an item objectId from contNr at itemPos |
| openAutoContainerFromFloor | (int objectId,int x,int y,int z) | Opens a container objectId at location x,y,z and also returns the container number it opens in |
| openContainerFromFloor | (int objectId,int x,int y,int z, int targetBag) | Opens a container objectId at location x,y,z as container number targetBag |
| openAutoContainerFromContainer | (int objectId, int contNrFrom, int contPosFrom) | Opens a container objectId from contNrFrom at contPosFrom and also returns the container number it opens in. Use this to manage backpack the way Tibia manages them |
| openContainerFromContainer | (int objectId, int contNrFrom, int contPosFrom, int targetBag) | Opens a container objectId from contNrFrom at contPosFrom as container number targetBag. Try to use the Auto version of this function as opening backpacks to minimize detectability |
| say | (string buf) | Say a message buf to players through default chat |
| sayWhisper | (string buf) | Whisper a message buf to players through default chat |
| sayYell | (string buf) | Yell a message buf to players through default chat |
| sayNPC | (string msg) | Say a message buf through NPC chat to NPCs |
| npcBuy | (int objectId,int qty, int ignoreCap, int withBackpack) | Purchace qty items of objectId using parameters ignoreCap and withBackpack. Only useful after saying "hi" to an NPC, "trade" is not necessary. |
| npcSell | (int objectId,int qty) | Sell qty items of objectId. Only useful after saying "hi" to an NPC, "trade" is not necessary. |
| tell | (string msg,string playerName) | Send playerName a message msg through private chat |
| sayOnChan | (string msg, int channelId1,int channelId2) | Say msg by means of speech type channelId1(say,yell,channel) with subtype channelId2 (Summary here) |
| logout | () | Send a logout command to the server |
| walkOnTAMap | (int x, int y, int z, int rad=0) | Walk to within rad sqm of a position x,y,z at any distance that is researched in TA. If rad not given, radius=0. |
| closeContainer | (int contNr) | Close the container contNr. The number of the backpacks you want to close should be kept track of when you open them |
| attackMode | (int mode,int follow) | Sends new attack style mode and run style follow to the Tibia server. Buttons will not change but you will act differently. |
| attack | (int tibiaCharId) | Sends an command to attack tibiaCharId |
| follow | (int tibiaCharId) | Sends an command to follow tibiaCharId |
| turnLeft | () | Sends a command to turn char left |
| turnRight | () | Sends a command to turn char right |
| turnUp | () | Sends a command to turn char up |
| turnDown | () | Sends a command to turn char down |
| sendCreatureInfo | (string name,string info1,string info2) | Changes the client-sided name line, info line 1 and info line 2 (3 lines total) to name, info1, info2 respectively |
| look | (int x,int y, int z,int objectId) | Sends a requests to look at objectId at location x,y,z but this only works for the top item |
| ignoreLook | (int ignoreLookEnd) | Will prevent any green text from displaying up until ignoreLookEnd < tareader.getCurrentTm() |
| sendAutoAimConfig | (int active, int onlyCreatures, int aimPlayersFromBattle) | (Deprecated) Does nothing, but is there :P |
| sendClearCreatureInfo | () | Will reset the information of creatures that are not currently onscreen ie(last location, last hp%, tibiaId) |
| enableCName | (int enable) | Will set the visibility of creature names on lower floors to enable |
| sendAttackedCreatureToAutoAim | (int attackedCreature) | (Deprecated) Does nothing, but is also there :P |
| stopAll | () | Simulates the pressing of the ESC key in Tibia |
| printText | (int x, int y, int r, int g, int b, string text) | After having pressed Alt+F8, will display text at location (x, y) in pixels relative to the top left of the window with red colour component r, green g and blue b where r,g and b range from 0-255. |
tamap
| Function Name | Parameters | Description |
|---|---|---|
| removePointAvailable | (int x,int y,int z) | Sets the TA map location as unexplored/blocking |
| prohPointClear | () | Clears the temporary list of points blocked by players and creatures |
| prohPointAdd | (int x, int y, int z) | Makes location x,y,z a blocked point(used as a temporary indicator for creatures and players) |
| getPointUpDown | (int x,int y,int z) | Returns the code for the type of level change tile (Summary here) |
| getPointUpDownNoProh | (int x,int y,int z) | Returns the code for the type of level change tile while ignoring prohibited points(Summary here) |
| setPointUpDown | (int x,int y,int z,int updown) | Sets the location as a floor change tile indicate by updown |
| getPrevPointZ | (int x,int y, int z) | Returns the z coordinate 1 square prior to x,y,z along the previously computed path |
| getPrevPointY | (int x,int y, int z) | Returns the y coordinate 1 square prior to x,y,z along the previously computed path |
| getPrevPointX | (int x,int y, int z) | Returns the x coordinate 1 square prior to x,y,z along the previously computed path |
| clearPrevPoint | () | Removes the coordinate 1 square prior to x,y,z along the previously computed path |
| setPrevPoint | (int x,int y,int z,int prevX, int prevY, int prevZ) | Sets the coordinate 1 square prior to x,y,z along the path you wish to keep track of |
| clear | () | Resets all prohibited points, available tiles, and previously computer paths to a blank state |
| setPointAsAvailable | (int x,int y,int z) | Sets the TA map location as walkable |
| isPointAvailable | (int x,int y,int z) | Returns whether the TA map at location is walkable |
| isPointAvailableNoProh | (int x,int y,int z) | Returns whether the TA map at location is walkable and is not in the prohibited point list |
| size | () | Returns the current number of points being kept track of in the TA map |
taregex
| Function Name | Parameters | Description |
|---|---|---|
| match | (int x,int y,int z) | Sets the TA map location as unexplored/blocking |
taalice
| Function Name | Parameters | Description |
|---|---|---|
| respond | (string text,string id) | Will send a artificially created message to player with name id in response to text |
tacrstat
| Function Name | Parameters | Description |
|---|---|---|
| findCreatureStatForLocationTibiaId | (int x, int y, int z, int pos) | Crashes TA |
| findCreatureStatForLocationCount | (int x, int y, int z) | Crashes TA |
| findCreatureStatForLocationName | (int x, int y, int z, int pos) | Crashes TA |
| findCreatureStatInArea | (int x, int y, int z, int rangeXY, int rangeZ) | Crashes TA |
taitem
| Function Name | Parameters | Description |
|---|---|---|
| getItemName | (int objectId) | Returns the name found for the item objectId within the items.xml |
| getItemId | (char *name) | Returns the item ID for the item named name within the items.xml |
| getItemIndex | (int objectId) | Returns the index of item objectId within the item list |
| getFoodIndex | (int objectId) | Returns the index of item objectId within the food list |
| getLootItemIndex | (int objectId) | Returns the index of item objectId within the loot list |
| getItemIdAtIndex | (int ind) | Returns the ID of the item at index ind |
| getFoodIdAtIndex | (int ind) | Returns the ID of the food at index ind |
| getLootItemIdAtIndex | (int ind) | Returns the ID of the loot item at index ind |
| getItemNameAtIndex | (int ind) | Returns the name of the item at index ind |
| getFoodNameAtIndex | (int ind) | Returns the name of the food at index ind |
| getLootItemNameAtIndex | (int ind) | Returns the name of the loot item at index ind |
| getFoodTimeAtIndex | (int ind) | Returns the eating time of the food at index ind |
| addItem | (char *name, int objectId) | NOTE: Added for backward compatibility. Temporarily adds an item with parameters name and objectId to the items list if it does not already exist until it is refreshed from the items.xml |
| addFood | (char *name, int objectId, int extraInfo) | Adds the food with parameters name, objectId, and time extraInfo to the items list if it does not already exist |
| addLootItem | (char *name, int objectId) | NOTE: Added for backward compatibility. Temporarily adds an loot item with parameters name and objectId to the loot list if it does not already exist until it is refreshed from the items.xml |
| removeItem | (int ind) | NOTE: Added for backward compatibility. Temporarily removes the item at index ind from the items list until it is refreshed from the items.xml |
| removeFood | (int ind) | Removes the food at index ind from the food list |
| removeLootItem | (int ind) | NOTE: Added for backward compatibility. Temporarily removes the loot item at index ind from the loot list until it is refreshed from the items.xml |
| clearFoodList | () | Removes all items from the food list |
| getItemCount | () | Returns the number of items within the items list |
| getFoodCount | () | Returns the number of items within the food list |
| getLootItemCount | () | Returns the number of items within the loot list |
| getValueForConst | (char *code) | Returns an integer value for the constant named code within the items.xml. This is NOT case sensitive |
| refreshItemLists | () | Retreives all the changes to all item lists after editing the items.xml |
| saveItemLists | () | NOTE: Loot and item lists are never saved. Only their corresponding tree structure is saved. Saves food list and Item tree changes |
takernel
| Function Name | Parameters | Description |
|---|---|---|
| startModule | (int nr) | Starts TA module number nr |
| stopModule | (int nr) | Stops TA module number nr |
| getModuleCount | () | Returns the number of TA modules |
| getModuleName | (int nr) | Returns the name of TA module number nr |
| getModuleDesc | (int nr) | Returns the description within TA module number nr |
| isModuleStarted | (int nr) | Returns whether or not TA module number nr is started |
| getModuleVersion | (int nr) | Returns the version within TA module number nr |
| startPythonModule | (int nr) | Starts Python module number nr |
| stopPythonModule | (int nr) | Stops Python module number nr |
| getPythonModuleCount | () | Returns the number of Python modules |
| getPythonModuleName | (int nr) | Returns the name of Python module number nr |
| isPythonModuleStarted | (int nr) | Returns the description within Python module number nr |
| getPythonModuleDesc | (int nr) | Returns whether or not Python module number nr is started |
| getPythonModuleVersion | (int nr) | Returns the version within Python module number nr |
Conventions
Functions the python class needs in order to interface with TA
#Must return a string of the class name to be displayed in TA eg. "Most Awesome Script" getName(self)
#Must return a string of the version number to be displayed in TA eg. "1.1.1" or "primo facto versio, oolala" getVersion(self)
#Must return a Function Type tuple described below eg. (0,1000,self.foo) or (1,0,self.funfoo) or (2,0,self.foofoo) #nr starts at 0 and increments sequentially until the empty tuple () is returned getFunDef(self,nr)
#Must return a Parameter Type tuple described below eg. ("variable_string_name", "Description and important info about the variable")
#nr starts at 0 and increments sequentially until the empty tuple () is returned
getConfigParam(self,nr)
Function Type tuple Tuple contains 3 parameters, (<function type>,<period>,<function pointer>)
| Function Type | Description | Period | Function Pointer |
|---|---|---|---|
| 0 | Periodic function | Will run the function every <period> milliseconds, but only if the previous function has already ended. | A function which gets passed a dictionary. It contains parameter names created in the getConfigParam function. eg fun0(self,params) |
| 1 | Runs when anything is said in Tibia by anyone. | This parameter is 0 and is not needed | A function which gets passed a parameter dictionary and a 4 value tuple. fun1(self,params,(typ,channel,nick,message)) |
| 2 | Like 1 but runs when anything starting with "%ta" is said in Tibia by you only. | This parameter is 0 and is not needed | A function which gets passed a parameter dictionary and a string. fun1(self,params,message) |
Parameter Type tuple Tuple contains 2 parameters, (<variable name>,<helpful description>) When passed to functions specified in the getFunDef function, the values are assigned based on what the user inputs in the Configuration Options of Python
Scripts seen in the image. They are always strings with a maximum length of 1022 characters.


