Page 1 of 2 12 LastLast
Results 1 to 25 of 30

Thread: Simba----->Python

  1. #1
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default Simba----->Python

    I've been thinking about rewriting/importing srl includes so that i can use it with python without involving simba. Why? mainly because of multithreading and some other reasons. I can rewrite most of the color functions myself, but i have no clue how to implement smart and reflection. How would i go about doing this?

  2. #2
    Join Date
    May 2006
    Location
    Australia
    Posts
    370
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Maybe I'm completely wrong, but I think SMART is just a plugin. So all you need is to load the dll and call the appropriate functions to set it up/run it.
    ------
    Strong Holder
    Kill Goblins and Zombies in (ex) bot free zones. Loot & Bank. Stable: 1.2b

  3. #3
    Join Date
    Mar 2011
    Location
    Somerset, UK
    Posts
    304
    Mentioned
    0 Post(s)
    Quoted
    24 Post(s)

    Default

    I am pretty sure that loading the dll and calling the functions is how you use smart . look into the Smart.scar in Includes\SRL\SRL\misc as this contains the necessary functions to load and setup SMART ..

    i hope you have some luck converting / including SMART in python as i would love to Test this out ...

    If you Need Any beta testing .. Sign me up

  4. #4
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by sm0k3 View Post
    i hope you have some luck converting / including SMART in python as i would love to Test this out ...

    If you Need Any beta testing .. Sign me up
    Plus One.
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  5. #5
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    There is already a project for this.

    libMML (Getting MML into a library)
    pyMML (Using libMML in python)
    Someone also started a SRL port but cant do much work as pyMML is not complete.

    https://github.com/MerlijnWajer/Simb...rojects/libmml

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  6. #6
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    I've been thinking about rewriting/importing srl includes so that i can use it with python without involving simba. Why? mainly because of multithreading and some other reasons. I can rewrite most of the color functions myself, but i have no clue how to implement smart and reflection. How would i go about doing this?
    • Python is too slow to perform the findColor() and stuff itself.
    • Python doesn't really have real multithreading, but it goes by
    • pyMML aims to do exactly this, but performing all the CPU intensitive tasks with Simba's library.





    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  7. #7
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Dgby714 View Post
    There is already a project for this.

    libMML (Getting MML into a library)
    pyMML (Using libMML in python)
    Someone also started a SRL port but cant do much work as pyMML is not complete.

    https://github.com/MerlijnWajer/Simb...rojects/libmml
    I've seen that, but i want to use python natively and also because simba doesn't support multithreading(or is just the pascal interpreter that doesn't allow this?)

    Quote Originally Posted by Wizzup? View Post
    • Python is too slow to perform the findColor() and stuff itself.
    • Python doesn't really have real multithreading, but it goes by
    • pyMML aims to do exactly this, but performing all the CPU intensitive tasks with Simba's library.


    1-PIL?(python imaging library) Im pretty sure its fast enough for rs related stuff(i never used it, so i dont' really know)
    2-Again, i haven't used multithreading much, so im not too sure of its limitations and such, but i guess its better than not having any type of multithreading
    3-But right now if you wanted to expand the library it would be hard im guessing, whereas if you use python(or any language for that matter) you can easily expand the library to suit individual needs. Also you won't need to worry about OS specific things, because iirc simba doesn't work on macs(OS) right?

  8. #8
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Python natively? Don't know what you mean, unless you want MML to be in Python, which would be far too slow (as Wizzup? said. Python is a dynamic, interpreted, high level language. Those three things combined in a language == quite slow, about 100x slower than C, and Pascal rivals C in a lot of cases (in my cases for our purposes, it's negligible at best)).

    GIL. That's the extent of my Python-multi-threading knowledge, but I know it's frowned upon, so that's enough for me. Don't want to make this a huge point because I know very well I don't know a whole lot on the topic, but it's something that is always brought up.

    I entirely disagree with the third point. It's not hard to expand the library. It's been done quite a lot. It's a decently solid core (albeit I think it's far overgrown for it's own good), which won't complain if you add some functions. I've said a few times that I really dislike Python for projects. Dynamic languages in general are bad for projects, in my personal opinion. People get lazy. We don't always want to comment every single thing we do, which is a necessity to have a well-functioning library written in a language which supports dynamic typing.

    Also, Pascal is more OS-independent than Python, afaik. Python on windows is really Python on MinGW (or Cygwin? Can't remember) on Windows. With FPC, it's just FPC, afaik.

    C is more OS-independent than either, though, because just about every OS will work with C with no downloads/installations/etc. Winblows is the worst for this, though.

    Simba's core (MML) should work on Macs though. Not as well as it works in Win7 32bit, but it should work. The problem with Simba on Linux or Mac OS X (natively) is PascalScript, which is just a lame interpreter we stuck with because SCAR used it.

    I do support MML -> C, though. But I also want a lot of changes done to MML, most of which would be frowned upon I'm sure, so it probably won't ever be used as widely as Simba now, but we'll see, I suppose.

    PM me if you wanna talk about it. (Scripting would be done in Python I think. I have higher priorities than this, but it's something I'd be interested in working on.)

  9. #9
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Meh Dunno if its me or not but everyone here seems to like to use these ancient languages and they hate java.. I really dont see much advantages of using python or even libMML.. there are advantages but theyre not great.. Mostly people who support this, are users of python, delphi and pascal and users who already know such languages.. the three most ancient languages.

    Imho the best/greatest attempt to convert Simba/Scar scripts into any language was done by boberman and yakman.. which everyone seemed to forget.
    http://villavu.com/forum/showthread.php?t=30214
    I am Ggzz..
    Hackintosher

  10. #10
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Python is far less ancient than C++, by the way. Or Pascal.

    But anyway. I don't use Pascal or Python. I'd be all for using C or C++, but it would be quite the change which a lot of people don't like. But if you feel it's the right thing to do, why not do it? People are against it will be against it and won't do anything for it. It's kinda like asking for a software job without presenting any proof that you're good at what you do. You need to give them working software and say "hey, this works good, I made this, make it the most used thing you can because it's superior."

    Same thing applies here. I still think actively about doing some of this (MML -> C, which is the best choice in my opinion), and there's a decent chance I will. So we'll see what happens.

  11. #11
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    Same thing applies here. I still think actively about doing some of this (MML -> C, which is the best choice in my opinion), and there's a decent chance I will. So we'll see what happens.
    u better butt hurt kid

    luffs <3

  12. #12
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Quote Originally Posted by footballjds View Post
    u better butt hurt kid

    luffs <3
    ;D I think I will. I think I'll start with just porting MML to C (sorta; there are some things that I don't need to port, but just porting it should keep testing simple for nay-sayers). Then possibly rewrite it completely.

    But, I have higher interests with other stuff.

  13. #13
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    ;D I think I will. I think I'll start with just porting MML to C (sorta; there are some things that I don't need to port, but just porting it should keep testing simple for nay-sayers). Then possibly rewrite it completely.

    But, I have higher interests with other stuff.
    How 'bout you make a simple library with the basic necessities that a script needs.

    Mouse, Keyboard functions. Done =)
    O and maybe a few colour functions.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  14. #14
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Well that has been my plan (as I stated numerous times in my butthurt thread), but a lot of people will be butthurt either way I'm sure.

    Porting (mostly) would be easier than my plans for sure, but it would be more work. But, my ways would be far better, in my opinion.

    We'll see. And we should talk, John.

  15. #15
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    So, the only useful information i got so far is from benlands github, and i understood that smart can be used in python(correct me if im wrong), but I have no clue how to actually start smart from python, any help on this topic would be highly appreciated.

  16. #16
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    So, the only useful information i got so far is from benlands github, and i understood that smart can be used in python(correct me if im wrong), but I have no clue how to actually start smart from python, any help on this topic would be highly appreciated.
    Load the library?

    import * from ctypes
    DLL = WinDLL('libsmart.dll')
    DLL.smartsetup(blah...)

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  17. #17
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Thats the source code.. so as far as I know, smart is C++ & Java.. I do not know java very well nor python but a little searching told me that you'd have to use ctypes to access the functions within the dll and to import such a dll file as it includes c++ files and c++ functions.. Below is the python source code for smart.. You can always try and compile it and then load the compile libsmart.dll file.

    Example:
    http://www.knowledgetantra.com/compo...in-python.html
    Code:
    import ctypes
    # Load DLL into memory.
    hllDll = ctypes.WinDLL ("c:/libsmart.dll")
    ^needs verification.. The code below says otherwise so above might be wrong..
    then I guess use the functions in it.. or reference them. I doubt you need any wrappers. Check out here for a ctypes tut on loading .dll files: http://docs.python.org/library/ctype...#module-ctypes

    meh someone more experienced in python might be able to continue from here on with you..



    Code:
    #!/usr/bin/python
    
    """
     *  Copyright 2010 by Benjamin J. Land (a.k.a. BenLand100)
     *
     *  This file is part of the SMART Minimizing Autoing Resource Thing (SMART)
     *
     *  SMART is free software: you can redistribute it and/or modify
     *  it under the terms of the GNU General Public License as published by
     *  the Free Software Foundation, either version 3 of the License, or
     *  (at your option) any later version.
     *
     *  SMART is distributed in the hope that it will be useful,
     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     *  GNU General Public License for more details.
     *
     *  You should have received a copy of the GNU General Public License
     *  along with SMART. If not, see <http://www.gnu.org/licenses/>.
    """
    
    from ctypes import *
    import platform
    
    class point:
        """Dummy class for a generic point."""
        def __init__(self, x = 0, y = 0):
            self.x = x
            self.y = y
        def __str__(self):
            return '('+str(self.x)+','+str(self.y)+')'
            
    class jobject:
        """Represents Java objects returned by SMART."""
        def __init__(self, data = c_void_p(None)):
            self._as_parameter_ = data if data != None else c_void_p(None)
        def __str__(self):
            return '<jobject@'+str(self._as_parameter_.value)+'>'
            
    
    class Smart:
        """General SMART wrapper for python, requires v6.5 or later"""
        def __init__(self, root, args, width, height, initseq, jvmpath = None):
            """Sets up the python bindings for SMART, sets the JVM if specified, 
               and invokes the setup routine, assuming the libsmart library is
               in the current path."""
            if platform.system() == 'Windows':
                self._dll = CDLL('./libsmart.dll')
            else:
                self._dll = CDLL('./libsmart.so')
            #JVM.h
            self._dll.setJVMPath.argtypes = [c_char_p]
            self._dll.setJVMPath.restype = None
            #Smart.h
            self._dll.getImageArray.argtypes = []
            self._dll.getImageArray.restype = c_long
            self._dll.setTransparentColor.argtypes = [c_long]
            self._dll.setTransparentColor.restype = None
            self._dll.setDebug.argtypes = [c_bool]
            self._dll.setDebug.restype = None
            self._dll.setGraphics.argtypes = [c_bool]
            self._dll.setGraphics.restype = None
            self._dll.getDebugArray.argtypes = []
            self._dll.getDebugArray.restype = c_long
            self._dll.isActive.argtypes = []
            self._dll.isActive.restype = c_bool
            self._dll.isBlocking.argtypes = []
            self._dll.isBlocking.restype = c_bool
            self._dll.getRefresh.argtypes = []
            self._dll.getRefresh.restype = c_long
            self._dll.setRefresh.argtypes = [c_long]
            self._dll.setRefresh.restype = None
            self._dll.setup.argtypes = [c_char_p,c_char_p,c_long,c_long,c_char_p]
            self._dll.setup.restype = None
            #Reflection.h
            self._dll.stringFromBytes.argtypes = [c_void_p, c_char_p]
            self._dll.stringFromBytes.restype = c_long
            self._dll.stringFromChars.argtypes = [c_void_p, c_char_p]
            self._dll.stringFromChars.restype = c_long
            self._dll.stringFromString.argtypes = [c_void_p, c_char_p]
            self._dll.stringFromString.restype = c_long
            self._dll.invokeIntMethod.argtypes = [c_void_p, c_char_p, c_char_p, c_long, c_long]
            self._dll.invokeIntMethod.restype = c_long
            self._dll.freeObject.argtypes = [c_void_p]
            self._dll.freeObject.restype = None
            self._dll.getFieldObject.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldObject.restype = c_void_p
            self._dll.getFieldInt.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldInt.restype = c_long
            self._dll.getFieldShort.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldShort.restype = c_long
            self._dll.getFieldByte.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldByte.restype = c_long
            self._dll.getFieldBool.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldBool.restype = c_bool
            self._dll.getFieldLongH.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldLongH.restype = c_long
            self._dll.getFieldLongL.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldLongL.restype = c_long
            self._dll.getFieldFloat.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldFloat.restype = c_float
            self._dll.getFieldDouble.argtypes = [c_void_p, c_char_p]
            self._dll.getFieldDouble.restype = c_float
            self._dll.getFieldArrayObject.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayObject.restype = c_void_p
            self._dll.getFieldArrayInt.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayInt.restype = c_long
            self._dll.getFieldArrayFloat.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayFloat.restype = c_float
            self._dll.getFieldArrayDouble.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayDouble.restype = c_float
            self._dll.getFieldArrayBool.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayBool.restype = c_bool
            self._dll.getFieldArrayLongH.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayLongH.restype = c_long
            self._dll.getFieldArrayLongL.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayLongL.restype = c_long
            self._dll.getFieldArrayByte.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayByte.restype = c_long
            self._dll.getFieldArrayShort.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayShort.restype = c_long
            self._dll.getFieldArrayChar.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArrayChar.restype = c_long
            self._dll.getFieldArray3DObject.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DObject.restype = c_void_p
            self._dll.getFieldArray3DInt.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DInt.restype = c_long
            self._dll.getFieldArray3DFloat.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DFloat.restype = c_float
            self._dll.getFieldArray3DDouble.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DDouble.restype = c_float
            self._dll.getFieldArray3DBool.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DBool.restype = c_bool
            self._dll.getFieldArray3DLongH.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DLongH.restype = c_long
            self._dll.getFieldArray3DLongL.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DLongL.restype = c_long
            self._dll.getFieldArray3DByte.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DByte.restype = c_long
            self._dll.getFieldArray3DShort.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DShort.restype = c_long
            self._dll.getFieldArray3DChar.argtypes = [c_void_p, c_char_p, c_long, c_long, c_long]
            self._dll.getFieldArray3DChar.restype = c_long
            self._dll.getFieldArray2DObject.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DObject.restype = c_void_p
            self._dll.getFieldArray2DInt.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DInt.restype = c_long
            self._dll.getFieldArray2DFloat.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DFloat.restype = c_float
            self._dll.getFieldArray2DDouble.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DDouble.restype = c_float
            self._dll.getFieldArray2DBool.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DBool.restype = c_bool
            self._dll.getFieldArray2DLongH.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DLongH.restype = c_long
            self._dll.getFieldArray2DLongL.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DLongL.restype = c_long
            self._dll.getFieldArray2DByte.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DByte.restype = c_long
            self._dll.getFieldArray2DShort.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DShort.restype = c_long
            self._dll.getFieldArray2DChar.argtypes = [c_void_p, c_char_p, c_long, c_long]
            self._dll.getFieldArray2DChar.restype = c_long
            self._dll.getFieldArraySize.argtypes = [c_void_p, c_char_p, c_long]
            self._dll.getFieldArraySize.restype = c_long
            self._dll.isEqual.argtypes = [c_void_p, c_void_p]
            self._dll.isEqual.restype = c_bool
            self._dll.isNull.argtypes = [c_void_p]
            self._dll.isNull.restype = c_bool
            self._dll.isPathValid.argtypes = [c_void_p, c_char_p]
            self._dll.isPathValid.restype = c_bool
            #Input.h
            self._dll.sendKeys.argtypes = [c_char_p]
            self._dll.sendKeys.restype = None
            self._dll.isKeyDown.argtypes = [c_long]
            self._dll.isKeyDown.restype = c_bool
            self._dll.holdKey.argtypes = [c_long]
            self._dll.holdKey.restype = None
            self._dll.releaseKey.argtypes = [c_long]
            self._dll.releaseKey.restype = None
            self._dll.getMousePos.argtypes = [POINTER(c_long), POINTER(c_long)]
            self._dll.getMousePos.restype = None
            self._dll.moveMouse.argtypes = [c_long, c_long]
            self._dll.moveMouse.restype = None
            self._dll.windMouse.argtypes = [c_long, c_long]
            self._dll.windMouse.restype = None
            self._dll.dragMouse.argtypes = [c_long, c_long]
            self._dll.dragMouse.restype = None
            self._dll.holdMouse.argtypes = [c_long, c_long, c_bool]
            self._dll.holdMouse.restype = None
            self._dll.releaseMouse.argtypes = [c_long, c_long, c_bool]
            self._dll.releaseMouse.restype = None
            self._dll.clickMouse.argtypes = [c_long, c_long, c_bool]
            self._dll.clickMouse.restype = None
            #Color.h
            self._dll.getColor.argtypes = [c_long, c_long]
            self._dll.getColor.restype = c_long
            self._dll.findColor.argtypes = [POINTER(c_long), POINTER(c_long), c_long, c_long, c_long, c_long, c_long]
            self._dll.findColor.restype = c_bool
            self._dll.findColorTol.argtypes = [POINTER(c_long), POINTER(c_long), c_long, c_long, c_long, c_long, c_long, c_long]
            self._dll.findColorTol.restype = c_bool
            self._dll.findColorSpiral.argtypes = [POINTER(c_long), POINTER(c_long), c_long, c_long, c_long, c_long, c_long]
            self._dll.findColorSpiral.restype = c_bool
            self._dll.findColorSpiralTol.argtypes = [POINTER(c_long), POINTER(c_long), c_long, c_long, c_long, c_long, c_long, c_long]
            self._dll.findColorSpiralTol.restype = c_bool
            #set jvm path and invoke setup
            if jvmpath != None:
                self._dll.setJVMPath(jvmpath);
            self._dll.setup(root,args,width,height,initseq)
    
        #from JVM.cpp
    
        def setJVMPath(self, path):
            """Specify a JVM for SMART to use. May be called at any time, but only 
               affects the next full loading cycle of SMART."""
            setJVMPath(path)
    
        #from Smart.cpp
    
        def getImageArray(self):
            """Returns a c_void_p to SMART's image buffer array."""
            res = self._dll.getImageArray()
            return res.value
    
        def getDebugArray(self):
            """Returns a c_void_p to SMART's debug drawing array."""
            res = self._dll.getDebugArray()
            return res.value
    
        def setTransparentColor(self, color):
            """Sets the color (int value) that is transparent on the debug image."""
            self._dll.setTransparentColor(color)
    
        def setDebug(self, on):
            """Enables or disables the debug drawing."""
            self._dll.setDebug(on)
    
        def setGraphics(self, on):
            """Enables or disables renderig graphics on the screen."""
            self._dll.setGraphics(on)
            
        def isActive(self):
            """Specifies whether or not SMART has loaded."""
            res = self._dll.isActive()
            return res.value
    
        def isBlocking(self):
            """Specifies whether or not SMART is blocking events. (i.e. whether 
               SMART is enabled or disabled.)"""
            res = self._dll.isBlocking()
            return res.value
    
        def getRefresh(self):
            """Returns the value of the FPS slider."""
            res = self._dll.getRefresh()
            return res.value
    
        def setRefresh(self, x):
            """Sets the value of the FPS slider."""
            self._dll.setRefresh(x)
    
        def setup(self, root, args, w, h, initseq):
            """(Re)Initilizes SMART with the given arguments."""
            self._dll.setup(root, args, w, h, initseq)
    
        #from Reflection.cpp
    
        def stringFromBytes(self, parent, path):
            """Returns a string from a byte array."""
            res = self._dll.stringFromBytes(parent, path)
            return res.value
    
        def stringFromChars(self, parent, path):
            """Returns a string from a char array."""
            res = self._dll.stringFromChars(parent, path)
            return res.value
    
        def stringFromString(self, parent, path):
            """Returns a string from a string object."""
            res = self._dll.stringFromString(parent, path)
            return res.value
    
        def invokeIntMethod(self, obj, classname, methname, a, b):
            """Can invoke an int method with two int arguments - not recommended"""
            res = self._dll.invokeIntMethod(obj, classname, methname, a, b)
            return res.value
    
        def freeObject(self, parent):
            """Frees Object values. Must be called exactly once for every object."""
            self._dll.freeObject(parent)
    
        def getFieldObject(self, parent, path):
            """Gets an Object from a parent/path combo."""
            res = self._dll.getFieldObject(parent, path)
            return jobject(res)
    
        def getFieldInt(self, parent, path):
            """Gets an int from a parent/path combo."""
            res = self._dll.getFieldInt(parent, path)
            return res.value
    
        def getFieldShort(self, parent, path):
            """Gets a short from a parent/path combo."""
            res = self._dll.getFieldShort(parent, path)
            return res.value
    
        def getFieldByte(self, parent, path):
            """Gets a byte from a parent/path combo."""
            res = self._dll.getFieldByte(parent, path)
            return res.value
    
        def getFieldBool(self, parent, path):
            """Gets a boolean from a parent/path combo."""
            res = self._dll.getFieldBool(parent, path)
            return res.value
    
        def getFieldLong(self, parent, path):
            """Gets a long from a parent/path combo."""
            h = self._dll.getFieldLongH(parent, path).value
            l = self._dll.getFieldLongL(parent, path).value
            return (h << 32) | l
    
        def getFieldFloat(self, parent, path):
            """Gets a float from a parent/path combo."""
            res = self._dll.getFieldFloat(parent, path)
            return res.value
    
        def getFieldDouble(self, parent, path):
            """Gets a double from a parent/path combo."""
            res = self._dll.getFieldDouble(parent, path)
            return res.value
    
        def getFieldArrayObject(self, parent, path, i):
            """Gets an Object from an index in an array at a parent/path combo."""
            res = self._dll.getFieldArrayObject(parent, path, i)
            return jobject(res)
    
        def getFieldArrayInt(self, parent, path, i):
            """Gets an int from an index in an array at a parent/path combo."""
            res = self._dll.getFieldArrayInt(parent, path, i)
            return res.value
    
        def getFieldArrayFloat(self, parent, path, i):
            """Gets a float from an index in an array at a parent/path combo."""
            res = self._dll.getFieldArrayFloat(parent, path, i)
            return res.value
    
        def getFieldArrayDouble(self, parent, path, i):
            """Gets a double from an index in an array at a parent/path combo."""
            res = self._dll.getFieldArrayDouble(parent, path, i)
            return res.value
    
        def getFieldArrayBool(self, parent, path, i):
            """Gets a boolean from an index in an array at a parent/path combo."""
            res = self._dll.getFieldArrayBool(parent, path, i)
            return res.value
    
        def getFieldArrayLong(self, parent, path, i):
            """Gets a long from an index in an array at a parent/path combo."""
            h = self._dll.getFieldArrayLongH(parent, path, i).value
            l = self._dll.getFieldArrayLongL(parent, path, i).value
            return (h << 32) | l
    
        def getFieldArrayByte(self, parent, path, i):
            """Gets a byte from an index in an array at a parent/path combo."""
            res = self._dll.getFieldArrayByte(parent, path, i)
            return res.value
    
        def getFieldArrayShort(self, parent, path, i):
            """Gets a short from an index in an array at a parent/path combo."""
            res = self._dll.getFieldArrayShort(parent, path, i)
            return res.value
    
        def getFieldArrayChar(self, parent, path, i):
            """Gets a char from an index in an array at a parent/path combo."""
            res = self._dll.getFieldArrayChar(parent, path, i)
            return res.value
    
        def getFieldArray3DObject(self, parent, path, i, j, k):
            """Gets an Object from an index in a 3D array at a parent/path combo."""
            res = self._dll.getFieldArray3DObject(parent, path, i, j, k)
            return jobject(res)
    
        def getFieldArray3DInt(self, parent, path, i, j, k):
            """Gets an int from an index in a 3D array at a parent/path combo."""
            res = self._dll.getFieldArray3DInt(parent, path, i, j, k)
            return res.value
    
        def getFieldArray3DFloat(self, parent, path, i, j, k):
            """Gets a float from an index in a 3D array at a parent/path combo."""
            res = self._dll.getFieldArray3DFloat(parent, path, i, j, k)
            return res.value
    
        def getFieldArray3DDouble(self, parent, path, i, j, k):
            """Gets a double from an index in a 3D array at a parent/path combo."""
            res = self._dll.getFieldArray3DDouble(parent, path, i, j, k)
            return res.value
    
        def getFieldArray3DBool(self, parent, path, i, j, k):
            """Gets a boolean from an index in a 3D array at a parent/path combo."""
            res = self._dll.getFieldArray3DBool(parent, path, i, j, k)
            return res.value
    
        def getFieldArray3DLong(self, parent, path, i, j, k):
            """Gets a long from an index in a 3D array at a parent/path combo."""
            h = self._dll.getFieldArray3DLongH(parent, path, i, j, k).value
            l = self._dll.getFieldArray3DLongL(parent, path, i, j, k).value
            return (h << 32) | l
    
        def getFieldArray3DByte(self, parent, path, i, j, k):
            """Gets a byte from an index in a 3D array at a parent/path combo."""
            res = self._dll.getFieldArray3DByte(parent, path, i, j, k)
            return res.value
    
        def getFieldArray3DShort(self, parent, path, i, j, k):
            """Gets a short from an index in a 3D array at a parent/path combo."""
            res = self._dll.getFieldArray3DShort(parent, path, i, j, k)
            return res.value
    
        def getFieldArray3DChar(self, parent, path, i, j, k):
            """Gets a char from an index in a 3D array at a parent/path combo."""
            res = self._dll.getFieldArray3DChar(parent, path, i, j, k)
            return res.value
    
        def getFieldArray2DObject(self, parent, path, i, j):
            """Gets an Object from an index in a 2D array at a parent/path combo."""
            res = self._dll.getFieldArray2DObject(parent, path, i, j)
            return jobject(res)
    
        def getFieldArray2DInt(self, parent, path, i, j):
            """Gets an int from an index in a 2D array at a parent/path combo."""
            res = self._dll.getFieldArray2DInt(parent, path, i, j)
            return res.value
    
        def getFieldArray2DFloat(self, parent, path, i, j):
            """Gets a float from an index in a 2D array at a parent/path combo."""
            res = self._dll.getFieldArray2DFloat(parent, path, i, j)
            return res.value
    
        def getFieldArray2DDouble(self, parent, path, i, j):
            """Gets a double from an index in a 2D array at a parent/path combo."""
            res = self._dll.getFieldArray2DDouble(parent, path, i, j)
            return res.value
    
        def getFieldArray2DBool(self, parent, path, i, j):
            """Gets a boolean from an index in a 2D array at a parent/path combo."""
            res = self._dll.getFieldArray2DBool(parent, path, i, j)
            return res.value
    
        def getFieldArray2DLong(self, parent, path, i, j):
            """Gets a long from an index in a 2D array at a parent/path combo."""
            h = self._dll.getFieldArray2DLongH(parent, path, i, j).value
            l = self._dll.getFieldArray2DLongL(parent, path, i, j).value
            return (h << 32) | l
    
        def getFieldArray2DByte(self, parent, path, i, j):
            """Gets a byte from an index in a 2D array at a parent/path combo."""
            res = self._dll.getFieldArray2DByte(parent, path, i, j)
            return res.value
    
        def getFieldArray2DShort(self, parent, path, i, j):
            """Gets a short from an index in a 2D array at a parent/path combo."""
            res = self._dll.getFieldArray2DShort(parent, path, i, j)
            return res.value
    
        def getFieldArray2DChar(self, parent, path, i, j):
            """Gets a char from an index in a 2D array at a parent/path combo."""
            res = self._dll.getFieldArray2DChar(parent, path, i, j)
            return res.value
    
        def getFieldArraySize(self, parent, path, dim):
            """Returns the size of a dimension of an array at a parent/path combo."""
            res = self._dll.getFieldArraySize(parent, path, dim)
            return res.value
    
        def isEqual(self, a, b):
            """Tests the equality of two Objects."""
            res = self._dll.isEqual(a, b)
            return res.value
    
        def isNull(self, obj):
            """Tests if an Object is really NULL or just pretending."""
            res = self._dll.isNull(obj)
            return res.value
    
        def isPathValid(self, parent, path):
            """Tests the validity of a parent/path combo."""
            res = self._dll.isPathValid(parent, path)
            return res.value
    
        #from Input.cpp
    
        def sendKeys(self, string):
            """Sends a string of characters to the client in a human way."""
            self._dll.sendKeys(string)
    
        def isKeyDown(self, c):
            """Tests if a key code is down."""
            res = self._dll.isKeyDown(c)
            return res.value
    
        def holdKey(self, c):
            """Holds the specified key code."""
            self._dll.holdKey(c)
    
        def releaseKey(self, c):
            """Releases the specified key code."""
            self._dll.releaseKey(c)
    
        def getMousePos(self):
            """Returns the current mouse position."""
            x = c_long()
            y = c_long()
            self._dll.getMousePos(byref(x), byref(y))
            return point(x.value,y.value)
    
        def moveMouse(self, x, y):
            """Sets the mouse to the specified position."""
            self._dll.moveMouse(x, y)
            
        def holdMouse(self, x, y, left):
            """Holds the mouse (left or right) at the spcecified position."""
            self._dll.holdMouse(x, y, left)
    
        def releaseMouse(self, x, y, left):
            """Releases the mouse (left or right) at the specified position."""
            self._dll.releaseMouse(x, y, left)
    
        def clickMouse(self, x, y, left):
            """Clicks the mouse (left or right) humanly at the specified position."""
            self._dll.clickMouse(x, y, left)
    
        def windMouse(self, x, y):
            """Moves the mouse humanly to a specified position."""
            self._dll.windMouse(x, y)
    
        def dragMouse(self, x, y):
            """Drags the mouse humanly to a specified position."""
            self._dll.dragMouse(x, y)
    
        #from Color.cpp
    
        def getColor(self, x, y):
            """Quickly gets the color from the specified point."""
            res = self._dll.getColor(x, y)
            return res.value
    
        def findColor(self, x, y, color, xs, ys, xe, ye):
            """Quickly finds the color from the specified point in the given box."""
            xx = c_long(x)
            yy = c_long(y)
            res = self._dll.findColor(byref(xx), byref(yy), color, xs, ys, xe, ye)
            if res.value:
                return point(xx.value,yy.value)
            return None
    
        def findColorTol(self, x, y, color, xs, ys, xe, ye, tol):
            """Quickly finds the color with tolerance from the specified point in the given box."""
            xx = c_long(x)
            yy = c_long(y)
            res = self._dll.findColorTol(byref(xx), byref(yy), color, xs, ys, xe, ye, tol)
            if res.value:
                return point(xx.value,yy.value)
            return None
    
        def findColorSpiral(self, x, y, color, xs, ys, xe, ye):
            """Quickly finds the color from the specified point in the given box using a spiral."""
            xx = c_long(x)
            yy = c_long(y)
            res = self._dll.findColorSpiral(byref(xx), byref(yy), color, xs, ys, xe, ye)
            if res.value:
                return point(xx.value,yy.value)
            return None
    
        def findColorSpiralTol(self, x, y, color, xs, ys, xe, ye, tol):
            """Quickly finds the color with tolerance from the specified point in the given box using a spiral."""
            xx = c_long(x)
            yy = c_long(y)
            res = self._dll.findColorSpiralTol(byref(xx), byref(yy), color, xs, ys, xe, ye, tol)
            if res.value:
                return point(xx.value,yy.value)
            return None
    
    if __name__ == "__main__":
        smart = Smart('http://world19.runescape.com/', 'plugin.js?param=o0,a2,m0', 765, 503, '')
        import time
        time.sleep(10)
    Last edited by Brandon; 05-10-2011 at 06:19 AM.
    I am Ggzz..
    Hackintosher

  18. #18
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    You mean CBAS, in regards to Ben's github? That's sorta different, but whatever.

    http://villavu.com/forum/forumdisplay.php?f=363
    https://github.com/MerlijnWajer/Simb...rojects/libmml

    Both should help. It can be (and has been) done.

  19. #19
    Join Date
    Feb 2006
    Location
    Berkeley, CA
    Posts
    1,837
    Mentioned
    52 Post(s)
    Quoted
    60 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    I can rewrite most of the color functions myself, but i have no clue how to implement smart and reflection. How would i go about doing this?
    Someone posted this code without a source, but here is the source:
    https://github.com/BenLand100/SMART/...test-python.py

    Basically, that class defines all the methods that exist within SMART itself in a python friendly way with docs. I.E. there is nothing in SRL/Reflection source that needs more methods for SMART than are defined there. Or, more simply, anything else you need for Reflection will exist in the reflection source code that should be around somewhere (don't ask me where, idk).

  20. #20
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Reflection is hosted at https://github.com/SRL/srl-reflection. I think.

  21. #21
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    So I've not completely read all the new posts, but I want to counter a few arguments. Mainly the one that states that Pascal is too old for MML and that writing it in C would be better. It's really utter nonsense. It's not true that Simba doesn't work on Macs _because_ we use Pascal. It doesn't work on Mac because no developer has a Mac nor has the energy to port it to another platform which our current interpreter doesn't support. Mac support _will_ come if we find a proper interpreter. While it is very useful to have ``C-Compatible'' functions because Pascal has it's own (just like Java, which is worse - bytecode) libMML is made _just_ for this. It exports all the MML functionality to any language that can read a library C-style. (pyMML anyone?) The ``overhead'' of doing an extra call it near to void; especially if you start thinking about all the other stuff Simba/MML does ``under the hood'', let alone what the kernel and display manager do. It's just _one_ extra call, swapping a few arguments, copying a list. That's it, it's not a performance penalty either. Since FreePascal is also cross platform, I think it is a total waste to re-write it in C at this point. If you want to do anything, just learn Pascal. It's not much harder than C (I think it's easier, but not hating on C here) and work on MML. We did our best right at the start to create a nice (OOP) structure for MML; and I'd like to think we made a nice structure. Later on we made a few additions with Ben joining in and him smashing down some of our brainfarts - so I must say I'm really quite happy with the way MML is at the moment. And if you're really upset about copying a few arguments/lists around, you can always make a branch of MML where you replace the internal pascal-type arrays with pointers. We'll gladly merge it to master if we can see it is stable.

    Really, if you want to help - learn Free Pascal. Learn how to use pointers, objects, learn casting. The basics. I'm getting back to Simba in a few weeks of time hopefully, but I'm open for some question and I'm sure Niels and others won't mind helping out with Free Pascal either. Oh, and if you really feel like doing good work, write stuff down that you don't understand while trying to understand MML so we can improve/write documentation/faqs for it.

    Python surely isn't a language that is too ``old'' (for being the interpreter). It's only a year older than Java or so. It's true that it has the GIL, but that doesn't really get in the way you guys want multithreading to be. So it's not an issue, _at_all_. I think the plan we laid out with libMML (C-style) and Python is not a bad one. Even if you would like to see other languages supported first I don't think it's a bad idea to focus on this plan first. Once libMML and parts of pyMML are done, you can start working on a port for your <insert favourite language here>. Strength through Unity, cut the talking and start doing something. Really, luffs (and others), if you spent even half the time trying to understand MML instead of coding, you'd be working on libMML and others in no time.

    Oh yeah, the MML API is cross platform too, so you wouldn't even need to learn the Windows and Linux API's for targeting windows, using the mouse, etc.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  22. #22
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    For those of you still interested in this, here is something to drool over:

    1)Download the zipped SMART-Test folder
    2)Unzip the folder
    3)Run Rand.py and have fun seeing the mouse move everytime you type y.

    Thats all it does for now. Oh and in case you're wondering about the class_smart file, its a modified version from benland's github repo. Previously it didn't run on windows(for me anyway), so i had to tweak some stuff.

    Note: To terminate the program press any other character than y. You still have to kill the process from taskmanager to free the memory.

  23. #23
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default




    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  24. #24
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Here is something more advanced than my last attempt. This time its more like libmml, but it only works with SMART, ive yet to figure out how to incorporate bitmap functions(im working on dtm functions right now).

    Instructions:
    1)unzip PySRL.zip
    2)run test.py

  25. #25
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    I just made a simple python/smart-test, with some simple colorpicking, and OCR (using google tesseract) for uptext and shit, it's not much but... I've just started, and it will ONLY work under windows (Might need to change width+height in window.py if not on XP, donno). It's simple start. I've had testbots running for some hours on it. Only prob. by doing it this way is that the client can not be minemized.

    See the test.py for the syntax, and setup (include the RSL/text to test GetUpText, IsUpText). Functions is found in the Inc/rafiki.py

    Requirements:
    >> Python 2.7 (might work with some older, and maybe some newer..)
    >> PyWin32
    >> PIL (Python Image Library - for color and bitmaps)
    >> Tesseract-OCR (Text Recognition)

    PS: For now.. My bitmapfunction is fkn. slow as it's just a crazy loop.. I'm thinkin about using a numpy-array to solve that one, as PIL is limited, and slow. Numpy will give me Cpp-speed.
    Last edited by slacky; 02-25-2012 at 01:42 AM.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •