Scripting Resources & Utilities > Stealth Snippets\Library

[V6.1.3, Python] Script Snippet

(1/1)

slyone:
I haven't seen many Python script snippets using Stealth so I figured I'd post a simple example.  Hopefully this helps other people who are getting into Stealth and want to use Python.

Below is a snippet that opens your character's backpack and then opens all of the backpacks within your characters backpack.  Copy and paste the code into a text file with the .py extension.  Then load it up in Stealth and run it.


--- Code: ---import stealth

stealth.AddToSystemJournal("Begin")

#Open Backpack
backpackID = stealth.Backpack()
stealth.UseObject(backpackID)
stealth.Wait(1000)

#Find all backpacks within your backpack
backpackType = 0x0E75
allColors = 0xFFFF

# Search character backpack for backpacks of all colors, don't search recursively
stealth.FindTypeEx(backpackType, allColors, backpackID, False)

#Loop over all backpacks found and open them
result = stealth.GetFindedList()
stealth.AddToSystemJournal("Backpacks found:\t%d" %(stealth.FindCount()))
for bpID in result:
    stealth.UseObject(bpID)
    stealth.Wait(1000)
   
stealth.AddToSystemJournal("All Done")

--- End code ---

I'm using Python 2.7 but this snippet should work in either Python 2.x or Python 3.x.

Johnz125:
A new knowledge for me the best.

Navigation

[0] Message Index

Go to full version