Python script question....

hi i have the player script in game and i’m using this:


W = cont.sensors["W"]
S = cont.sensors["S"]

if W.positive or S.positive:
    do something....

and i want to use the bindable controls… is there any way to simulate something like W.positive?

PS i dont want to connect all the sensors so i will apreciate something to use the keyboard sensor with the allkeys enabled…

thanks for your help…

see the BGE API. Look for getKeyStatus

Other options:


def keys(cont):
    
    event = cont.sensors["sKeyAll"].events[0]    #checks first pressed key only

    if event[1]==1 or event[1]==3:
        key = event[0]

        if key==GameKeys.TWOKEY:
            if event[1]==1:
                print ("pressed"+str( key ) )


I hope it helps

i’ll try this but i think it will be complicated if i want to save the player controls to config file… anyway thanks