Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bge
- inputDict = {}
- # [ gameCommand, indexForSerialisation, ListToUse, Player
- #movements
- inputDict['WKEY'] = [ 'Forward', 0, 0,0 ]
- inputDict['AKEY'] = [ 'Left', 1 , 0, 0 ]
- inputDict['SKEY'] = [ 'Back', 2 , 0, 0]
- inputDict['DKEY'] = [ 'Right', 3 , 0, 0]
- #actions
- inputDict['MouseL'] = [ 'AimL', 0 , 1, 0]
- inputDict['MouseR'] = [ 'Fire', 1 , 1, 0]
- inputDict['QKEY'] = [ 'Grab', 2 , 1, 0]
- def main():
- cont = bge.logic.getCurrentController()
- own = cont.owner
- key = cont.sensors['Keyboard']
- mouseL = cont.sensors['MouseL']
- mouseR = cont.sensors['MouseR']
- inputs = []
- outputs = [ [], [] ]
- if key.positive:
- for event in key.inputs:
- string_in = bge.events.EventToString(event[0])
- inputs.append(string_in)
- #print(input)
- for input in inputs:
- if input in inputDict:
- v = inputDict[input]
- outputs[v[2]].append(v)
- if mouseL.positive:
- if 'MouseL' in inputDict:
- v = inputDict['MouseL']
- outputs[v[2]].append(v)
- if mouseR.positive:
- if 'MouseR' in inputDict:
- v = inputDict['MouseR']
- outputs[v[2]].append(v)
- for outputList in outputs:
- outputList = sorted(outputList, key = lambda x: x[1])
- #print(outputs)
- NL = [[],[]]
- index=0
- for inputList in outputs:
- for gameInput in inputList:
- if gameInput[0] not in NL[index]:
- NL[index].append(gameInput[0])
- index+=1
- #own['D'] = str(NL)
- if 'Actor' not in own:
- own['Actor'] = own.scene.objects['Actor']
- if NL[0]!=[] or NL[1]!=[]:
- own['Actor']['Move']= str(NL[0])
- own['Actor']['Act']= str(NL[1])
- own['Actor']['Timer'] = 60
- else:
- own['Actor']['Move']=[]
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement