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 (457 KB)
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.
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.
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.:eek:
#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
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
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.
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.