bhnh
01-31-2008, 08:18 PM
Here's a code snippet wiring a 2-way connection between objects...
rollout wtest "Wire Test"
(
button btn_b1 "Make Box 1"
button btn_b2 "Make Box 2"
button btn_wire "Connect"
local b1, b2, amt
on btn_b1 pressed do
(
b1 = box()
)
on btn_b2 pressed do
(
b2 = box pos:[50,0,0]
)
on btn_wire pressed do
(
amt = -4
paramWire.connect2way b1.rotation.controller[#Z_Rotation]\
b2.rotation.controller[#Z_Rotation] "Z_Rotation" ("Z_Rotation*"+ amt as string)
)
)
createDialog 200 100
After executing this, if you rotate box1 then box2 behaves as advertised; it rotates four times for every one rotation of box1, in the opposite direction from box1. BUT if you rotate box2, multiplication by the variable is ignored, so both boxes rotate in the same direction at the same rate. When I wire this connection manually, the ratio of spin and direction is the same regardless of which box is rotated. What am I missing in the code to get the same results? Many thanks.
rollout wtest "Wire Test"
(
button btn_b1 "Make Box 1"
button btn_b2 "Make Box 2"
button btn_wire "Connect"
local b1, b2, amt
on btn_b1 pressed do
(
b1 = box()
)
on btn_b2 pressed do
(
b2 = box pos:[50,0,0]
)
on btn_wire pressed do
(
amt = -4
paramWire.connect2way b1.rotation.controller[#Z_Rotation]\
b2.rotation.controller[#Z_Rotation] "Z_Rotation" ("Z_Rotation*"+ amt as string)
)
)
createDialog 200 100
After executing this, if you rotate box1 then box2 behaves as advertised; it rotates four times for every one rotation of box1, in the opposite direction from box1. BUT if you rotate box2, multiplication by the variable is ignored, so both boxes rotate in the same direction at the same rate. When I wire this connection manually, the ratio of spin and direction is the same regardless of which box is rotated. What am I missing in the code to get the same results? Many thanks.
