Notifications
Clear all

[Closed] Full Dynamic rollout – var visibility pb

Hello,

I have to build a project based on a floater including a head rollout (static) followed by a dynamic rollout (displayed after a specific action) and a last foot rollout (static)

The first lauch crashes because my main floater variable is not recognise by my function which updates the rollouts. The second launch is ok since my variable exists for the function.

I tried many attempts to fix this skeleton before to go further without any success.

If someone has a suggestion or a better solution. I am not programmer so I don’t know the best way to achieve this, just made this from offline help.

Thanks a lot

here is my code:

–///////////////////////////VARIABLES///////////////////////////////////////

–controls attributes

btnState_createObject=true

btnState_removeObject=false

–dynamic rollout display

displayDynaRollout=false

–floater settings

defaultRolloutHeight=125

defaultRolloutWidth=350

rolloutHeight=defaultRolloutHeight

rolloutWidth=defaultRolloutWidth

defaultRolloutPosX=50

defaultRolloutPosY=120

mainFloater=newRolloutFloater “Dynamic rollouts” defaultRolloutWidth defaultRolloutHeight defaultRolloutPosX defaultRolloutPosY

–Rollouts display update—————————————————————————

function majRollouts =

(

–initalize size for floater

rolloutHeight=defaultRolloutHeight

rolloutWidth=defaultRolloutWidth

–destroy all the rollouts

for roll in mainFloater.rollouts do removeRollout roll mainFloater

–rebuild all the rollouts

addrollout rolloutHead mainFloater –ERROR FIRST LAUNCH:removeRollout requires RolloutClass, got:undefined”

if displayDynaRollout then

(

addRollout rolloutA mainFloater

rolloutHeight+=60

)

addrollout rolloutFoot mainFloater

–adjust the size

mainFloater.size=[rolloutWidth,rolloutHeight]

)

–Controls display update————————————————————————

–This is not really necessary there but need it for my bigger project

function majControls =

(

rolloutHead.btn_createObject.enabled=btnState_createObject

rolloutHead.btn_removeObject.enabled=btnState_removeObject

)

–Create an object——————————————————————–

function createObject =

(

global gizmoObject=sphere name:“object” radius:100 segs:20 hemisphere:0.5

–Rollouts

displayDynaRollout=true

–controls

btnState_createObject=false

btnState_removeObject=true

)

–Destroy the Object ——————————————————–

function destroyObject =

(

delete gizmoObject

–Rollouts

displayDynaRollout=false

–Controls

btnState_createObject=true

btnState_removeObject=false

)

–/////////////////////////USER INTERFACE/////////////////////////////////////////////////////////////////////////////////////////

rollout rolloutHead “Steady head rollout”

(

button btn_createObject “Create object” height:18 width:150 offset:[-80,5] enabled:btnState_createObject

button btn_removeObject “Remove object” height:18 width:150 offset:[80,-23] enabled:btnState_removeObject

–SKY CREATION ok

on btn_createObject pressed do

(

createObject()

majRollouts()

majControls()

)

–SKY DESTRUCTION ok

on btn_removeObject pressed do

(

destroyObject()

majRollouts()

majControls()

)

)

rollout rolloutA “Dynamic rollout”

(

colorpicker col_ObjectColor “color” color:[137,204,255]

)

rollout rolloutFoot “Steady foot rollout”

(

button btn_close “Close floater” height:18 width:150

)

addRollout rolloutHead mainFloater

addRollout rolloutFoot mainFloater

3 Replies

People will find it easier to look at you code if it is in code tags. When you paste the code in use the # at the top of the menu…

This is a search result for dynamic rollouts which may help
http://forums.cgsociety.org/showthread.php?f=98&t=497862&highlight=dynamic+rollout

Yup – I’m not going to look at your code, but it sounds like you need to pre-declare your rollout names.

At the top of the script, simply put:

local rolloutHead, rolloutA, rolloutFoot -- rename these as you require

Obviously you would replace these with your rollout names, but it allows functions that have been declared before your rollouts know that they are coming.

Hotknife – ok for the code insertion trick, I will do next time.

Davestewart – Thanx, it works of course. I already used this in C++ once but didn’t remember this trick See you

Badoumba

vbmenu_register(“postmenu_5123072”, true);