WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-23-2011, 01:48 AM
new_horizon new_horizon is offline
Member
 
Join Date: Apr 2010
Posts: 43
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

Last edited by new_horizon; 08-23-2011 at 01:52 AM.
Reply With Quote
  #2  
Old 08-23-2011, 02:36 AM
new_horizon new_horizon is offline
Member
 
Join Date: Apr 2010
Posts: 43
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
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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