Author Topic: [Release] Stealth Python wrapper [UPDATED 2014-08-21]  (Read 20331 times)

0 Members and 1 Guest are viewing this topic.

Offline BoydonTopic starter

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
[Release] Stealth Python wrapper [UPDATED 2014-08-21]
« on: October 25, 2013, 03:47:57 AM »
+1
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 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
« Last Edit: August 21, 2014, 01:32:13 PM by Boydon »
Member of the Stealth development team.

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: [Release] Stealth Python wrapper [UPDATED 2013-10-25]
« Reply #1 on: October 25, 2013, 04:01:22 AM »
+1
Added to Pinpoint List. Thank you for your contribution :)

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2013-10-25]
« Reply #2 on: October 25, 2013, 12:37:12 PM »
+1
Boydon is alive!

\o/



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline slyone

  • Full Member
  • ***
  • Posts: 135
  • Activity:
    0%
  • Reputation Power: 2
  • slyone has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 1
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2013-10-25]
« Reply #3 on: October 25, 2013, 04:57:09 PM »
+1
Thanks for posting this wrapper.

I just loaded it up in Eclipse PyDev and saw an error in reference to 
Code: [Select]
TTilePichueI 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
Code: [Select]
class TTilePichue(Structure): with lowercase 'hue' and then you refer to a
Code: [Select]
TTilePicHue with uppercase 'Hue' on lines 1376, 1378, 1379, and 1380.  Then you refer to a
Code: [Select]
ttilepichue all lowercase on lines 1382 and 1383. 

Here are the lines I'm refering too:
Code: [Select]
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    ]

Code: [Select]
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
Started playing back at the Second Age

Offline BoydonTopic starter

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2013-10-25]
« Reply #4 on: October 26, 2013, 09:12:00 AM »
+1
Thank you, slyone.
This is now fixed and you can grab it from the beta repo.
Member of the Stealth development team.

Offline slyone

  • Full Member
  • ***
  • Posts: 135
  • Activity:
    0%
  • Reputation Power: 2
  • slyone has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 1
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2013-10-26]
« Reply #5 on: December 06, 2013, 03:20:21 PM »
+1
Below are four changes to have the wrapper (dated 2013-10-26) more closely match the embedded python functions in Script.dll:

1)  Change
 
Code: [Select]
line 951:        def Script_ClientTargetResponse():  To
 
Code: [Select]
line 951:        def ClientTargetResponse():
2)  Add (starting at about line 2415)
Code: [Select]
  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
 
Code: [Select]
line 2249:        def FindDistance():  To
 
Code: [Select]
line 2249:        def GetFindDistance():
4)  Change
 
Code: [Select]
line 3031:        def GetTargetStatus():  To
 
Code: [Select]
line 3031:        def TargetPresent():

Thanks,
S
Started playing back at the Second Age

Offline BoydonTopic starter

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2013-10-26]
« Reply #6 on: December 07, 2013, 01:36:43 PM »
+1
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.
Member of the Stealth development team.

Offline BoydonTopic starter

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2014-01-03]
« Reply #7 on: January 03, 2014, 05:34:59 AM »
+1
Wrapper is updated, see the first post for a list of changes.

Happy new year to everyone.  :)
Member of the Stealth development team.

Node

  • Guest
Re: [Release] Stealth Python wrapper [UPDATED 2014-01-03]
« Reply #8 on: March 26, 2014, 05:29:19 AM »
+1
Stealth 6.4.0 , Python 2.7

GetMoveThroughNPC()
Code: [Select]
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()
Code: [Select]
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

Offline BoydonTopic starter

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2014-01-03]
« Reply #9 on: April 01, 2014, 01:36:37 AM »
+1
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. ;)
Member of the Stealth development team.

Offline BoydonTopic starter

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2014-04-03]
« Reply #10 on: April 15, 2014, 01:35:37 PM »
+1
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. :)
« Last Edit: April 15, 2014, 01:37:57 PM by Boydon »
Member of the Stealth development team.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: [Release] Stealth Python wrapper [UPDATED 2014-04-03]
« Reply #11 on: April 15, 2014, 02:46:24 PM »
+1
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!
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Vlek

  • Jr. Member
  • **
  • Posts: 35
  • Activity:
    0%
  • Reputation Power: 1
  • Vlek has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
    • Bloodclan Orcs
Re: [Release] Stealth Python wrapper [UPDATED 2014-04-15]
« Reply #12 on: July 20, 2014, 09:23:42 AM »
+1
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.

Offline BoydonTopic starter

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2014-04-15]
« Reply #13 on: July 22, 2014, 04:08:46 AM »
+1
It should work with Python 2.7.

What kind of error do you have?
Member of the Stealth development team.

Offline BoydonTopic starter

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
Re: [Release] Stealth Python wrapper [UPDATED 2014-08-03]
« Reply #14 on: August 03, 2014, 09:45:14 AM »
+1
Wrapper is updated.
Member of the Stealth development team.

Tags: