PDA

View Full Version : about triggering action


haohaoxuexi1
04-19-2016, 12:06 PM
Is that possible to set up something like this:

Firstly I press keyboard "A" after that I press keyboard "C"

Then one action is triggered.

And this two step is in a order, the first one has to be activated first them do the second one, after that the action is triggered.

Is that any sample code for this?

haohaoxuexi1
04-19-2016, 12:31 PM
The input is not constricted to keyboard, also for other input

Jeff
04-20-2016, 01:39 AM
You could use a viztask function to wait for one event and then another before an action is triggered. The following code shows this with key events:

import viz
import viztask
import vizact

viz.go()

piazza = viz.addChild('piazza.osgb')

avatar = viz.addAvatar('vcc_male2.cfg',pos=[-3,0,5])
avatar.state(1)
walk = vizact.walkTo([3,0,5])

viz.move([0,0,-4])

def triggerAction():

yield viztask.waitKeyDown('a')
yield viztask.waitKeyDown('c')
avatar.runAction(walk)

viztask.schedule( triggerAction() )