ScriptUO
Scripting Resources & Utilities => Stealth Client => Topic started by: Boydon on October 25, 2013, 03:47:57 AM
-
Hello everybody,
the first release of Python wrapper for stealth is now available in the beta repository of Stealth:
https://bitbucket.org/Stealthadmin/stealth-beta-client/downloads
It was developed to be full compliant with the standard Python implementation already embedded within Stealth: in this way people can recycle already developed code while having the full power of Python.
I developed it using Python 3.X, but the code should be cross compatible with Python 2.7 (although I didn't have enough time to test it). Not all the function have been tested so please report any bug you meet.
Once you have imported it, you need to compile your .py project with your favorite freeze tool (cx_Freeze (http://cx-freeze.sourceforge.net/) is my favorite) to be able to run it in Stealth.
Changelog
---------- 2014-08-03 ----------
Changed:
- Renamed StartStealthPipeInstance to StartStealthSocketInstance for compatibility with Stealt 6.5.2 and addes some backward compatibility
---------- 2014-08-03 ----------
Added:
- GetMoveTroughNPC
- SetMoveTroughNPC
- StealthPath
Fixed:
- The following methods are now returning a list and not a single CR/LF separed string
+ GetContextMenu
+ GetGumpButtonDescription
+ GetGumpFullLines
+ GetGumpShortLines
+ GetGumpTextLines
+ GetLastMenuItems
+ GetMenuItems
+ GetShopList
- TStaticItemRealXY is now correctly declared
- AddToSystemJournal arguments are handled correctly
- Added the missing Tile filed to the TStaticItemRealXY
Changed:
- Renamed TStaticCellRealXY into TStaticItemRealXY
---------- 2014-04-15 ----------
Added:
- StartStealthPipeInstance
- CorrectDisconnection
- FindTypesArrayEx
The first two method are now needed to start external scripts.
Removed:
- StelathPath
- GetMoveTroughNPC
- SetMoveTroughNPC
All this methods are not public yet and will be available with the next stealth release.
Fixed:
- GetStaticArtBitmap
- FoundedParamID
- SetStatState (thx Encelar for this)
---------- 2014-01-03 ----------
Added:
- GetMoveOpenDoor
- SetMoveOpenDoor
- ClearInfoWindow
- FillInfoWindow
- ClearSystemJournal
Removed:
- ConvertFlagsToFlagSet (better implementation is needed)
Fixed:
- fixes suggested from slyone at http://www.scriptuo.com/index.php?topic=11704.msg100039#msg100039
- some code cleaning
-
Added to Pinpoint List. Thank you for your contribution :)
-
Boydon is alive!
\o/
-
Thanks for posting this wrapper.
I just loaded it up in Eclipse PyDev (http://www.scriptuo.com/index.php?topic=9374.0) and saw an error in reference to TTilePichue
I see the disclaimer of the Tile wrapping not being complete and this may be part of what you were referring to but I thought I'd post in an effort to be helpful. I also don't know all the differences between Python3.x and Python2.x. I currently run with Python2.7 and the error I see in PyDev may not be an error in Python3.x. Anyways, I haven't tried to test this specific code in a script yet to see if it fails at these locations due to Python's case sensitivity. So hopefully I'm not crying wolf.
On line 407 you defined the class TTilePichue(Structure):
with lowercase 'hue' and then you refer to a TTilePicHue
with uppercase 'Hue' on lines 1376, 1378, 1379, and 1380. Then you refer to a ttilepichue
all lowercase on lines 1382 and 1383.
Here are the lines I'm refering too:
407 class TTilePichue(Structure):
408 _pack_ = 1
409 _fields_ = [
410 ('x', c_int),
411 ('y', c_int),
412 ('id', c_int),
413 ('color', c_int),
414 ('Page', c_int),
415 ('ElemNum', c_int),
416 ]
1376 # TilePicHue : array of TTilePicHue
1377 if tmp.value > 0:
1378 # print('TilePicHue : array of {} TTilePicHue'.format(tmp.value))
1379 gump_elements = (TTilePicHue * tmp.value )()
1380 memmove(addressof(gump_elements), addressof(byte_array) + stream_position, ( sizeof(TTilePicHue) * tmp.value ))
1381 Result['TilePicHue'] = [
1382 {'x' : ttilepichue.x, 'y' : ttilepichue.y, 'id' : ttilepichue.id, 'color' : ttilepichue.color,
1383 'Page' : ttilepichue.Page, 'ElemNum' : ttilepichue.ElemNum, } for ttilepichue in gump_elements]
1384 stream_position += sizeof(TTilePicHue) * tmp.value
Thanks again.
-S
-
Thank you, slyone.
This is now fixed and you can grab it from the beta repo.
-
Below are four changes to have the wrapper (dated 2013-10-26) (https://bitbucket.org/Stealthadmin/stealth-beta-client/downloads) more closely match the embedded python functions in Script.dll:
1) Change
line 951: def Script_ClientTargetResponse():
To
line 951: def ClientTargetResponse():
2) Add (starting at about line 2415)
stealth_dll.Script_FindTypesArrayEx.argtypes = [[c_ushort], [c_ushort], [c_uint], [c_bool]]
stealth_dll.Script_FindTypesArrayEx.restype = [c_uint]
def FindTypesArrayEx(ObjTypes, Colors, Containers, Recursive):
return stealth_dll.Script_FindTypesArrayEx(ObjTypes, Colors, Containers, Recursive)
3) Change
line 2249: def FindDistance():
To
line 2249: def GetFindDistance():
4) Change
line 3031: def GetTargetStatus():
To
line 3031: def TargetPresent():
Thanks,
S
-
Thank you slyone.
Points #1, #3 and #4 are are fixed in my copy and will be available in next realese (it will be realsed after Stealth update).
Point #2 require a different implementation cause ObjTypes, Colors, Containers are arrays and need to be handled differently.
-
Wrapper is updated, see the first post for a list of changes.
Happy new year to everyone. :)
-
Stealth 6.4.0 , Python 2.7
GetMoveThroughNPC()
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import stealth
File "C:\Python\custom\stealth.py", line 2051, in <module>
stealth_dll.Script_GetMoveThroughNPC.restype = c_ushort
File "C:\Python\lib\ctypes\__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "C:\Python\lib\ctypes\__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Script_GetMoveThroughNPC' not found
SetMoveThroughNPC()
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import stealth
File "C:\Python\custom\stealth.py", line 2060, in <module>
stealth_dll.Script_SetMoveThroughNPC.argtypes = [c_ushort]
File "C:\Python\lib\ctypes\__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "C:\Python\lib\ctypes\__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Script_SetMoveThroughNPC' not found
-
You where faster than my fix. :D
Problem is that those two function are in current Stealth git version, but are not public yet (they will on next release). :D
Version 2014-03-28 has this fixed. Sorry for the inconvenience. ;)
-
Some of you already noticed intermediate versions, but as of today there is a new version of the wrapper: all the news are in the first post.
I've been working slow on the wrapper cause I put my efforts in another project, some news will come at the due time. :)
-
I've been working slow on the wrapper cause I put my efforts in another project, some news will come at the due time. :)
Other project? You are a big tease!
-
Hello, I know I'm a little late to the party, but is this wrapper still 2.7 compatible? I tried running it as is in both 2.7.5 and 3.2.5, but it's throwing up errors at the stealth_dll = WinDLL("") line even though I set it to the correct location.
-
It should work with Python 2.7.
What kind of error do you have?
-
Wrapper is updated.
-
Link is broken. :'(
-
Try again. :)
-
I was reading through the wrapper, and you have an event persistence class that looks very, very intriguing. Is it possible to get a tut on how to use it? I am thinking about using something like that to do statistical data analysis.
Is it possible to use it to receive data such as damage (who damages who, the amount, etc), healing (same as damage), players showing up, players leaving, hiding, recall, etc, etc?
-
Wrapper is updated.
@Vlek
What exactly do you want to know? I am not sure if you want to know how to use it (see below) or why it has been done in that way (as you probably guess there is a reason behind ;)).
Anyway feel free to use my code as you like. :D
Here is a snippet that shows you how to use it (beware that it is untested! :P):
#!python2
from __future__ import print_function
import os
import sys
from py_stealth import *
#this only works if you freeze with cx_freeze
exe_name = os.path.basename(sys.executable)
print(exe_name)
StartStealthSocketInstance(exe_name)
def OnSpeech(text, senderName, senderID):
AddToSystemJournal('[{}] {} has just said: {}'.format(senderID, senderName, text))
AddToSystemJournal('test')
SetEventProc('evSpeech', OnSpeech)
SetEventProc('evUnicodeSpeech', OnSpeech)
#20 seconds
for x in range(0, 401):
Wait(50)
CorrectDisconnection()
To have a list of events and parameters, have a look here (http://stealth.od.ua/Doc:Manual/Reference/Events).
-
Oooo, perfect. That's exactly what I was looking for. I was thinking I'd have to make my own event handler, but hopefully I can make a semi-veneer that'll make this easily callable for my statistical analysis module I'm trying to make. Thanks, man.
-
I know it has been over a year, but I never was able to use the wrapper. I'm having significant, weird issues with stealth not liking my scripts that are entirely legal python code.
I understand I have to use something like cx_freeze to put these into executables, but, when I do that, I was getting a silent error that the script.dll wasn't included. I tried adding it into the archive file that gets generated with the executable in cx_freeze, but then it doesn't error out at all. It just runs the program forever in the background if I try to use it or run it through stealth.
I mean, I froze literally this for crying out loud:
import py_stealth as stealth
stealth.UOSay('Hello world!')
And it was playing forever without having put anything in game.
I guess what I'm asking is, can I get a brief tutorial on how to properly create an executable using this thing? I think that's where I'm messing up.
-
Sorry! I figured it out on my own.
One thing though, it looks like your
On line 2259,
def FindTypeArrayEx(ObjTypes, Colors, Containers, InSub):
should be:
def FindTypesArrayEx(ObjTypes, Colors, Containers, InSub):