Page 1 of 3 123 LastLast
Results 1 to 20 of 48
  1. #1
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835

    BGE Python 2.4 to 2.5 converter (in progress)

    Hello Blenderartists.
    I am soon to embark on a tutorial series for Blender with my colleagues Guillame and Christian! I thought that i'd write a script converter, for those that don't have Python skills, and want to use generic scripts in the wild. It's working and in progress, and i'll keep you updated here.

    Blend File (please test and if something doesn't convert, send me your test script!)
    Python2.4to2.59.blend

    python converter.PNG
    Last edited by agoose77; 31-Aug-11 at 17:42.



  2. #2
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    Ok, i'm nearly close to a test release
    Last edited by agoose77; 31-Aug-11 at 03:27.



  3. #3
    Hey It was very cool, and very useful I am very interesting by this, because I work on a game and I am start to convert all the game to blender 2.5



  4. #4
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    Right, can someone post some old, not too complex 2.49 scripts that they KNOW are deprecated and don't work



  5. #5
    Member kurotatsu's Avatar
    Join Date
    Sep 2009
    Location
    wyo-colo-braska
    Posts
    276
    This system would be an incredible asset for the community. An ingenious solution to a roadblock I face as well, with so much of my work wrapped up in 2.49.

    Please bring this to completion, and you'll have a friend for life.lol

    This is no less than we've come to expect from you Agoose77, well done, truly well done.

    Can't wait for the release.

    Kuro.

    Edit: here's my lifebar hud script.

    Code:
    gl = GameLogic
    cont = gl.getCurrentController()
    own = cont.owner
    sceneList = GameLogic.getSceneList()
    for scene in sceneList:
                  
     objList = scene.objects
     
     # check object in each scene
     for obj in objList:
      
      # match player to saved player name
      if obj.name == "OB" + own['ID']:
       
       player = obj
       
       own['Text'] = player[own.prop]
       
       break
    My script for camera collision.

    Code:
    g = GameLogic
    c = g.getCurrentController()
    o = c.getOwner()
    Ray = c.getSensor("Collision")
    if Ray.isPositive():    
     Collision = Ray.getHitPosition()    
     Camera = c.getSensor("CamPar").getOwner()
     Camera.setPosition(Collision)
    else:    
     OrigCamera = c.getSensor("CamPos").getOwner()    
     OrigCameraLoc = OrigCamera.getPosition()    
     Camera = c.getSensor("CamPar").getOwner()    
     Camera.setPosition(OrigCameraLoc)
    And if ya reaaaaalllly want ta see if it will work.lol My main player script.

    Code:
    #Original script by Excalaberr, additional by Kurotatsu.
    import GameLogic as g
    cont = g.getCurrentController()
    own = cont.owner
    
    #All input from User mouse and keyboard..
    #Mouse and Ray sensors.
    left = cont.sensors['kuroleft']
    middle = cont.sensors['blocktap']
    middleoff = cont.sensors['blockoff']
    right = cont.sensors['Right']
    ray = cont.sensors['ray']
    #Keyboard sensors.
    Wbutton = cont.sensors['Press W']
    Sbutton = cont.sensors['Press S']
    Abutton = cont.sensors['Press A']
    Dbutton = cont.sensors['Press D']
    Wbuttoff = cont.sensors['Press Woff']
    Sbuttoff = cont.sensors['Press Soff']
    Abuttoff = cont.sensors['Press Aoff']
    Dbuttoff = cont.sensors['Press Doff']
    #Attack controls(Acuators):
    guard = cont.actuators['block']
    idle = cont.actuators['Idle']
    slash1 = cont.actuators['Attack']
    slash2 = cont.actuators['ninjaslash']
    slash3 = cont.actuators['jumpslash1']
    throw = cont.actuators['throwshuriken']
    throw2 = cont.actuators['jumpingstars']
    punch = cont.actuators['punchcombo']
    kick = cont.actuators['kick']
    claw = cont.actuators['clawslash']
    magicsmall = cont.actuators['magicsmall']
    shootfireball = cont.actuators['shootfireball']
    #sound(Actuators) must be set to Playstop.
    jmpsnd = cont.actuators['kurojumpsound']
    swdsnd = cont.actuators['swdsnd']
    clawsnd = cont.actuators['clawsnd']
    flamesnd = cont.actuators['flamesnd']
    steelswd = cont.actuators['steelsnd']
    fizzle = cont.actuators['fizzle']
    #Motion(Actuators) controls:
    fwd = cont.actuators['Forward']
    bckwrd = cont.actuators['Backward']
    leftrotate = cont.actuators['Left Turn']
    rightrotate = cont.actuators['Right Turn']
    leftstrafe = cont.actuators['leftsidestep']
    rightstrafe = cont.actuators['rightsidestep']
    stop = cont.actuators['stop']
    #Property(Acuators):
    manaempty = cont.actuators['manaempty']
    #####################################
    # This is the movement part of code.#
    #####################################
    #Forward
    if Wbutton.positive:
     
     cont.activate(fwd)
    if Wbuttoff.positive:
     
     cont.deactivate(fwd)
     cont.activate(stop)
    #Backward
    if Sbutton.positive:
     
     cont.activate(bckwrd)
    if Sbuttoff.positive:
     
     cont.deactivate(bckwrd)
     cont.activate(stop)
    #Left
    if Abutton.positive and middleoff.positive:
     
     cont.activate(leftrotate)
    if Abuttoff.positive:
     
     cont.deactivate(leftrotate)
     cont.activate(stop)
    #Right
    if Dbutton.positive and middleoff.positive:
     
     cont.activate(rightrotate)
    if Dbuttoff.positive:
     
     cont.deactivate(rightrotate)
     cont.activate(stop)
    ####################################
    #This is the Property Block of code#
    ####################################
     
    if own['magic']<0:
     
     cont.activate(manaempty)
    
    ####################################
    # This is the Attack Block of code.#
    ####################################
    #Melee punch.
    if left.positive:
     
     ray.range == own.range
     
     if own['melee']==1:
      
      cont.activate(punch)
      
      if ray.positive:
      
          obj = ray.hitObject
      
          if punch.frame >= 10:
       
       #print 'frame'
          
       if obj.has_key('enemy'):
        obj['hp'] -= 100
           
       if obj.has_key('brk'):  
        obj['brk'] += 1
      
      
    #Ninjato and Polearm attack.  
    if left.positive:
     
     if own['ninjato']==1:
      
      cont.activate(slash2)
      cont.activate(steelswd)
      cont.activate(jmpsnd)
      
      if ray.positive:
      
          obj = ray.hitObject
      
          if slash2.frame >= 10:
       
       #print 'frame'
          
       if obj.has_key('enemy'):
        obj['hp'] -= (own['att'])
           
       if obj.has_key('brk'):  
        obj['brk'] += 1
    #Shuriken and fireball throwing while jumping.  
      
    if left.positive and own['grounded']==0 :
     
     if own['ranged']==1:
      
      cont.activate(throw2)
      
    if left.positive and own['grounded']==0 and own['magic']>4:
     
     if own['fireball']==1:
      
      cont.activate(magicsmall)
      cont.activate(shootfireball)
      cont.activate(throw2)
      cont.activate(flamesnd)
     
    if left.positive and own['grounded']==0 and own['magic']<4:
     
     if own['fireball']==1:
      
      cont.activate(fizzle)
      
    #Shuriken and fireball throwing on ground.  
    if left.positive and own['grounded']==1 :
     
     if own['ranged']==1:
      
      cont.activate(throw)
      
    if left.positive and own['grounded']==1 and own['magic']>4:
     
     if own['fireball']==1:
      
      cont.activate(magicsmall)
      cont.activate(shootfireball)
      cont.activate(throw)
      cont.activate(flamesnd)
      
    if left.positive and own['grounded']==1 and own['magic']<4:
     
     if own['fireball']==1:
      
      cont.activate(fizzle)
      
      
    #Attack jumping for all swords except ninjato.  
      
    if left.positive and own['grounded']==0 :
     
     if own['slash']==1:
      
      cont.activate(slash3)
      cont.activate(swdsnd)
      
      if ray.positive:
      
          obj = ray.hitObject
      
          if slash3.frame >= 10:
       
       #print 'frame'
          
       if obj.has_key('enemy'):
        obj['hp'] -= (own['att'])
           
       if obj.has_key('brk'):  
        obj['brk'] += 1
        
        
          
    #Attack on ground for all swords and katana and ax, except ninjato.
    if left.positive and own['grounded']==1:
     
     if own['slash']==1:
      
      cont.activate(slash1)
      cont.activate(swdsnd)
      
      if ray.positive:
      
          obj = ray.hitObject
      
          if slash1.frame >= 10:
       
       #print 'frame'
          
       if obj.has_key('enemy'):
        obj['hp'] -= (own['att'])
           
       if obj.has_key('brk'):  
        obj['brk'] += 1
     
     
    #Attack for Wolvie claws.  
    if left.positive:
     
     if own['claws']==1:
      
      cont.activate(claw)
      cont.activate(clawsnd)
      
      if ray.positive:
      
          obj = ray.hitObject
      
          if claw.frame >= 10:
       
       #print 'frame'
          
       if obj.has_key('enemy'):
        obj['hp'] -= (own['att'])
           
       if obj.has_key('brk'):  
        obj['brk'] += 1
      
      
    #Blocking and Stafe left and right
    if middle.positive:
     
     cont.activate(guard)
     
    if middle.positive and Abutton.positive:
     
     cont.activate(leftstrafe)
    if middle.positive and Abuttoff.positive:
     
     cont.deactivate(leftstrafe)
     cont.activate(stop)
     
    if middle.positive and Dbutton.positive:
     
     cont.activate(rightstrafe)
    if middle.positive and Dbuttoff.positive:
     
     cont.deactivate(rightstrafe)
     cont.activate(stop)
      
    if middleoff.positive:
      
     cont.deactivate(guard)
     cont.deactivate(leftstrafe)
     cont.deactivate(rightstrafe)
     cont.activate(stop)
    #Kicking attack for ground and jumping the same. 
      
    if right.positive:
     
     ray.range == 5
     
     cont.activate(kick)
     cont.activate(jmpsnd)
     
     
     if ray.positive: 
      
      obj = ray.hitObject
      
      if kick.frame >= 19:
       
       #print 'frame'
       #pay attention this one is different!!   
       if obj.has_key('enemy'):
        obj['hp'] -= (own['kick_att'])
           
       if obj.has_key('brk'):  
        obj['brk'] += 1
    Hope this helps.
    Last edited by kurotatsu; 29-Aug-11 at 18:08. Reason: added scripts.
    "My perception is my reality."-Kuro.
    My game Voidkeepers Thread.
    My Random Example Thread.



  6. #6
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    progress is slow due to some errors



  7. #7
    Member kurotatsu's Avatar
    Join Date
    Sep 2009
    Location
    wyo-colo-braska
    Posts
    276
    No prob, you got the skill. And errors are to be expected, so don't lose faith. Even slow progress is progress.

    Kuro.
    "My perception is my reality."-Kuro.
    My game Voidkeepers Thread.
    My Random Example Thread.



  8. #8
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    Request:
    So, i've got a very basic demo for you all, and i'd like to hear what happens o.0
    However, if you're using tons of nested functions (e.g obj.setPosition(obj.getPosition()) )
    i don't know how that'll perform :/



  9. #9
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    If you've downloaded it, please re-download as if statements were breaking!



  10. #10
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    Latest Version Posted.
    Support for:
    • change has_key (this will also change has_key for other features
    • getOwner() and other deprecated functions
    • addActiveActuator
    • Nested Functions



  11. #11
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    Latest Version (.02) posted.
    Support for:
    Lack of spaces between operators and comparators (forgot to add the < or > symbols!)



  12. #12
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    Fixed a kind of catastrophic error!
    Let me know what bugs you receive!



  13. #13
    Member JohnnyBlack's Avatar
    Join Date
    Nov 2009
    Location
    Earth>Romania
    Posts
    1,781
    That would be just Great!



  14. #14
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    Please try it out!



  15. #15
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    Another little update: got a few bugfixes to post, and a slightly clearer code layout.
    I'm going to work on it as best I can- there a few issues where python code is valid but irrelevant, such as hasattr and setattr because that method of accusing properties is correct, but not for gameobjects. Can anyone suggest a solution: for the moment I'm just going to notify the user, but the only method of correctin it that I can think of is to spider the Target and see if its a gameobject, but this would require a code workaround, but viable nonetheless.



  16. #16
    I have test this, and I got an error:
    Code:
    Found Operator! Added spaces to relevant positions
    ('cam', 'GL')
    Stored Modules added
    Total changes made: 0
    Python script error - object 'Cube', controller 'Python#CONTR#1':
    Traceback (most recent call last):
      File "Converter", line 280, in <module>
      File "/home/bugs/Documents/Logiciels/blender/blender-2.59-linux-glibc27-i686/2.59/python/lib/python3.2/codecs.py", line 300, in decode
        (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 21: invalid continuation byte
    I am under Linux (Xubuntu 11.04 up to date), and there is accented character in the comments of my scripts (I am French).



  17. #17
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    I've uploaded the update, so try it!
    also, can you paste lines 290-310 in your script?



  18. #18
    I have download the new blend, but the error is always at line 300.



  19. #19
    Member agoose77's Avatar
    Join Date
    Aug 2010
    Location
    United Kingdom
    Posts
    6,835
    can i see your code? thanks!



  20. #20
    The problem is that I use it on the script's folder of my game, and I do not know on which file it blocks.
    So if you want I can make a compress file of this folder and send you an mp with a link to download this.



Page 1 of 3 123 LastLast

Posting Permissions

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