WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   If statements and button presses (https://forum.worldviz.com/showthread.php?t=3891)

new_horizon 08-23-2011 01:48 AM

If statements and button presses
 
Hi All,

Is there any way of using an IF statement that involves a particular button press instead of a mouse position?

For example...

If buttondown = zone3button:

Thanks

Mark

new_horizon 08-23-2011 02:36 AM

To be more specific I would like to store each buttonpress as a variable (3 in total) and then use a for loop to dictate whether the response was correct.

I have tried using mouse position instead, but this does not fit my purpose. The code looks like this currently and I would like to replace the m_pos1, m_pos2 and m_pos3 occurrences with button presses.

Code:

                zone1button.visible(viz.ON)
                zone2button.visible(viz.ON)
                zone3button.visible(viz.ON)
                zone4button.visible(viz.ON)
                zone5button.visible(viz.ON)
                nonebutton.visible(viz.ON)
                yield viztask.waitAny( [ viztask.waitButtonDown(zone1button),viztask.waitButtonDown(zone2button),viztask.waitButtonDown(zone3button),viztask.waitButtonDown(zone4button),viztask.waitButtonDown(zone5button),viztask.waitButtonDown(nonebutton)])
                m_pos1 = viz.buttondown
                yield viztask.waitAny( [ viztask.waitButtonDown(zone1button),viztask.waitButtonDown(zone2button),viztask.waitButtonDown(zone3button),viztask.waitButtonDown(zone4button),viztask.waitButtonDown(zone5button),viztask.waitButtonDown(nonebutton)])
                m_pos2 = viz.buttondown
                yield viztask.waitAny( [ viztask.waitButtonDown(zone1button),viztask.waitButtonDown(zone2button),viztask.waitButtonDown(zone3button),viztask.waitButtonDown(zone4button),viztask.waitButtonDown(zone5button),viztask.waitButtonDown(nonebutton)])
                m_pos3 = viz.buttondown
                print m_pos1, m_pos2, m_pos3
                m_pos = [m_pos1,m_pos2,m_pos3]
#                mousepress = viz.ask('Where were the objects that moved towards you?')
                grid.visible(viz.OFF)
                zone1button.visible(viz.OFF)
                zone2button.visible(viz.OFF)
                zone3button.visible(viz.OFF)
                zone4button.visible(viz.OFF)
                zone5button.visible(viz.OFF)
                nonebutton.visible(viz.OFF)
                for pos in m_pos:
                        if on_off == 1:
                                if pos[0] > 0.4 and pos[0] < 0.6 and pos[1] > 0.1:
                                        stim=nv
                                        R = 1
                                        stim = 0
                                        prob_calc(R) # should be using last valid nv & R to calc next nv
                                        stop_calc()
                                elif pos[0] < 0.4 or pos[0] > 0.6 and pos[1] > 0.1:
                                        stim=nv
                                        R = 0
                                        stim = 0
                                        prob_calc(R) # should be using last valid nv & R to calc next nv
                                        stop_calc()
                        if on_off == 0:
                                stim = 0
                                nulltrials = nulltrials + 1
                                if pos[0] > 0.4 and pos[0] < 0.6 and pos[1] > 0.1:
                                        falsep = falsep+1
                                falserate = 100*falsep/nulltrials



All times are GMT -7. The time now is 09:03 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC