[Closed] Rollout Issues
I guess this must be a simple question and I’m already feeling stupid, but I just can’t find out how to do this. It’s as simple as that: I’m trying to control a value in a rollout when I press a button in another rollout. But I can’t find a way to do that without getting errors. Would be great if someone could point me to the right direction. Here’s the sample code:
rollout Test1 "Test1"
(
spinner spnTest1 range:[-100000,10000,100] scale:0.1 fieldWidth:50 align:#center enabled:true
)
rollout Test2 "Test2"
(
button btnTest2 "Test2"
on btnTest2 pressed do spnTest1.value = 10
)
Test = newrolloutfloater "Test" 100 200 100 100
addrollout Test1 Test
addrollout Test2 Test
Problem is the line “on btnTest2 pressed do spnTest1.value = 10” where I try to call the spnTest1.value of the other rollout. This seems to be impossible. Is there any way I can have a connection between different rollouts?
[color=Silver]on btnTest2 pressed [color=Red]to[/color] spnTest1.value = 10[/color] – must be do
rollout rol_1 "1"
(
spinner sp range:[0,1e9,0] fieldWidth:50 offset:[0,3] across:2
button bt "b1" width:70
on bt pressed do ::rol_2.sp.value += 10
)
rollout rol_2 "2"
(
spinner sp range:[0,1e9,0] fieldWidth:50 offset:[0,3] across:2
button bt "b2" width:70
on bt pressed do ::rol_1.sp.value += 10
)
d = newrolloutfloater "" 200 130 200 200
addrollout rol_1 d
addrollout rol_2 d
Yes, thank you, stupid me. But still my question remains. When you correct it (to->do), then the spnTest1 is undefined because it is in another rollout. How can I go about this? Thanks.
EDIT:
Ah, I just saw that you have provided a new sample script. I see you have called the value by accessing the rollout first. Great, exactly what I was looking for. One little question: What are the double-colons for?
if you call a control from other rollout you have to call it by full path —- rollout_name.control_name
What are the double-colons for?
try to find a very good explanation by Bobo on this forum
it’s there: http://forums.cgsociety.org/showpost.php?p=7049931&postcount=2
Ok, just one more question. Is it possible to do something like this?
(
rollout rol_1 "1"
(
spinner sp range:[0,1e9,0] fieldWidth:50 offset:[0,3] across:2
button bt "b1" width:70
on bt pressed do ::rol_2.sp.value += 10
)
rollout rol_2 "2"
(
spinner sp range:[0,1e9,0] fieldWidth:50 offset:[0,3] across:2
button bt "b2" width:70
--on bt pressed do ::rol_1.sp.value += 10
)
on rol_2.bt pressed do ::rol_1.sp.value += 10
)
d = newrolloutfloater "" 200 130 200 200
addrollout rol_1 d
addrollout rol_2 d
As you see, I have put the “on bt pressed do ::rol_1.sp.value += 10” line out of the rollout rol_2. I’ll get an error then. Is it possible to build all the rollouts first, then do the expressions?
Declare the variables as globals before you define them.
<deleted example that added nothing new>
EDIT – forget that example. You are trying to declare a rollout handler outside of the scope of the rollout, which is an error. You could set up your handler in the rollout to call an external (possibly global) function I suppose.