From Stealth Client

Jump to: navigation, search

Python

To run python script - file should be saved with py extension, for example test.py. Otherwise Pascal interpreter runs.

Stealth using an ordinary interpreter to execute python scripts, which you will need to download from the official site: [1]. 2.7 and 3.2 versions of interpreters supported. It is desirable to use version 3.2. After installation, you need to restart stealth.

All stealth functions are in the stealth module. Before running the script it is always automatically executed(there is no need to repeat it):

from stealth import *

respectively, all functions are imported into the script namespace.

A simple script can consist of one file, for example:

while True:
  UseSkill ('Hiding')
  Wait (11000)

In the super sophisticated and clever scripts, or to reuse the code can be useful to use a command such as import

import mycode
 
while True:
  mycode.myfunc ()
  Wait (11000)

import directive operates on a similar principle to the {$ Include 'hungry.inc'} You should manually add "from stealth import *" in the imported script

from stealth import *
 
while True:
  UseSkill ('Hiding')
  Wait (11000)

Syntax of the language you can learn fron the book [2]

or this [3]

Sample code is here [4]

Virtually all functions in the interaction with the stealth remained in the same form as they were in the Pascal scripts. The exception is the function of type Doc:Api/GetPathArray, which had to pass a variable array that they fill. the case with python - function returns an array of such data.

All functions have __doc__ block filled. You can get function signature like this:

print (GetPathArray.__doc__)

You can see what parameters expects one or another function

Example: GetPathArray (DestX: Integer, DestY: Integer, Optimized: Boolean, Accuracy: Integer) -> List of Tuple (X, Y, Z: Integer)

also you can use our functios guide here

Differences with Pascal Script

In pascal you can call function without parameters (procedure) call without brackets, for example Ground

In Python this trick does not work, you must explicitly add empty brackets: Ground()

In Pascal hexadecimal numbers are denoted as $AAAAAAAA

In Python a bit differently: 0xAAAAAAAA

Variables of type moveOpenDoor and the rest are implemented as functions

SetMoveOpenDoor(True) GetMoveOpenDoor()

Python - the case-sensitive language(unlike PascalScript). This means that UseObject and useobject - it's different functions. By this you must be keep in mind that all functions begin with capital letters (like in documentation).

Example script

from datetime import datetime
 
def PrepareKindling ():
    WaitTargetTile (3296, 1700, 1626, 5) # tree
    UseObject (ObjAtLayer (RhandLayer ())) # skid dagger
    if not WaitJournalLine (datetime.now (), 'You chip off some kindling', 60000):
        return False
    MoveItem (FindType (0x0DE1, Backpack ()), 1, Ground (), 0,0,0)
    Wait (1000)
    return True
 
while True:
    if FindType (0x0DE1, Ground ()) or PrepareKindling ():
        UseObject (FindType (0x0DE1, Ground ())) # skid sawdust
        Wait (5000)