|
|
Link Object to a Vertex Added on: Mon Aug 14 2000 |
Page: 1 2 3 4 5 6 7 8 9 10 |
The next line changes the label below the Get Vert button. In order to change the what the text of the label says we change the value of "vertnumL.text" If you remember, vertnumL was our label we made that said "Vertex Number: (none selected)" Well we want to change this to "Vertex Number: (our vertex number)"
So this is how we do it. vertnumL.text = "Vertex Number: " + (vertnum as string).
The vertnumL.text stores the string (what is says) well we want to keep the "Vertex Number: " part. But we want to add the number of our vertex. So we add it to the string by using the "+" sign.
The only problem is the variable vertnum (our vertex number) is stored as a interger but the value of vertnumL.text has to be a string. This is why the "as string" is there. It converts the integer to a string so it can be appended onto "Vertex Number: " Back to the block of script we wrote. The next two lines...
VertPicked = true
if ChildPicked == true do LinkME_Button.enabled = on are needed to activate
our LinkME_Button we made. We had made the LinkME_Button inactive when we created it.
if is a conditional statement. If this then that. The "==" doesn't assign anything, it is used to test. We are testing to see if the Child has already been picked. If it has then the LinkME_Button will become enabled. If it hasn't then it remains locked.
The button should now work when you use it. Remember, you HAVE to select a vertex before you push the get vert button. Because the Button gets what ever is currently selected. If a vertex is not selected and you push the button the script will crash and burn. Onto the next button.
To get the "Get Child" button to work, type the following,
on GetChild_PB picked obj do (
Child_Obj = obj
childnameL.text = "Child Object: " + Child_Obj.name
ChildPicked = true
if VertPicked == true do LinkME_button.enabled = on
) --close on getchild The first thing you should notice is that the syntax is different for the button. This is a different type of button, the pickbutton, so different syntax is needed.
The general form follows, on PickButtonName picked ObjectName do ( ..... )
ObjectName is the object that you picked. Since the obj is a
temporary name we will assign it to a variable, Child_Obj.
The next line "childnameL.text = "Child Object: " + Child_Obj.name" changes the label below the button to the name of the Child_Obj we picked.
The name of an object is stored under Child_Obj.name which is a string so we don't
need to convert anything.
The rest of the new script is the same as the previous button. Just with the ChildPicked and VertPicked swapped with each other.
|
|
|
|