WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-18-2008, 10:43 AM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
Two definitions?

Hello, I am wondering how one can get something like this to work... there's a dropdown list, and when the player selects an item from the dropdown and clicks on an avatar, he 'uses' it on that avatar. I've been having a bit of trouble with this, as I'm using a code similar to this:

Code:
def onList(e):
	if e.object == DropDown and e.newSel == 4 and button == viz.MOUSEBUTTON_LEFT:
	viz.message('You beat the game!')
(Also, should it be 'e.oldSel'?)

Or something like that.
My problem is that I can't get it so that once the player selects something from the list, that he/she can USE it on the enviroment/on avatars. I can get it to print anything if the player selects something from the dropdown, but in order to use in collaboration with the left click, I'd need a different definition for it (i.e. if something is selected and the player clicks with it, then x action happens). Is this the only way to accomplish this, or do you advise something else?
Reply With Quote
  #2  
Old 08-18-2008, 05:20 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use the DropDown.getSelection() command at any time to get the index of the currently selected item. So when an avatar is clicked with the mouse, use this command to get the item that is currently selected and then perform the appropriate action.
Reply With Quote
  #3  
Old 08-19-2008, 08:47 AM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
I'm not completely sure I'm following... Once I get the index, I'm not sure how to call it up only for a certain selection once I do a certain action (clicking the avatar, per se)
Also I'm not too sure if I know even how to trigger an event by clicking on an avatar either >_<
This link had a little example of a pre-selected option that prints the object that's selected... but I already know how to print things when items are selected. What I'm using is this:

Code:
def onList(e):
	if e.object == DropDown and e.newSel == 4:
		print 'A equipped'
		patient.execute(4)
		viz.message('A equipped')
	if e.object == DropDown and e.newSel == 1:
		viz.message('B equipped')
	if e.object == DropDown and e.newSel == 2:
		viz.message('C equipped')
	if e.object == DropDown and e.newSel == 3:
		viz.message('D equipped')
	if e.object == DropDown and e.newSel == 5:
		viz.message('E equipped')
0 is Empty hands so I figured not to do anything for that. I'm trying to get it so that when the player selects the fourth option he'll be able to use it on the avatar
Sorry about all these questions too, I hope I'm not being bothersome
Reply With Quote
  #4  
Old 08-21-2008, 09:46 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I don't fully understand what you are trying to do, so I'm not sure what exactly the problem is. You know how to get the currently selected item from the list, so now you just need to do something with the information. If you want to perform an action on an avatar, then create a list that maps an index to an action, and use this to decide which action to perform.
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:34 AM.


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