Variables (Scripting) in Rollout Definitions

Variables (Scripting) in Rollout Definitions

Anonymous
Not applicable
297 Views
3 Replies
Message 1 of 4

Variables (Scripting) in Rollout Definitions

Anonymous
Not applicable
Hi there,

So I have this rollout, containing 20 parameters with 16 slots for each one. Something like this...

--continues above 

bs_constraint_val_14 type:#float ui:bs_constraint_val_14
bs_constraint_val_15 type:#float ui:bs_constraint_val_15
bs_constraint_val_16 type:#float ui:bs_constraint_val_16

bs_rotation_val_1 type:#integer ui:bs_rotaion_val_1
bs_rotation_val_2 type:#integer ui:bs_rotaion_val_2
bs_rotation_val_3 type:#integer ui:bs_rotaion_val_3

--continues below


And the inability to use even simple variables and scripts in the rollout definitions is driving me nuts (and hurting my arm). 16 x 20 is 320 lines of code describing each value. How can I use an index or variable or script to condense this?

i.e.

for i = 1 to 16 do 
(
bs_constraint_val_ type:#float ui:bs_constraint_val_
)


Yes, I know that doesn't work.
0 Likes
298 Views
3 Replies
Replies (3)
Message 2 of 4

Steve_Curley
Mentor
Mentor
Sadly you can't - AFAIK anyway.

What you can do though is write a script to write the script - or at least the 320 lines of it...

Add the remaining definitions, change the indentation to suit. Run it and just copy/paste from the listener into your script.


(
local parms = #(
#("bs_constraint_val_", "float"),
#("bs_rotation_val_", "integer")
-- and so on
)

for parm = 1 to parms.count do
(
for t = 1 to 16 do
format "%% type:#% ui:%%\n" parms (t as string) parms parms (t as string) to:listener
)
)


Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 3 of 4

Anonymous
Not applicable
Thankyou, that will work.

I also found this, but haven't tried yet:

{rollout_creator}.addLocal {string}

This function can be used to add local variables to the rollout definitions. The variable’s value can be initialized by passing the init: value
0 Likes
Message 4 of 4

Steve_Curley
Mentor
Mentor
If you look at stdplugs\stdscripts\baselib\rolloutcreator.ms it is basically a bunch of string manipulation routines. I've not looked at it too closely, but it looks like you would have to call those functions within a loop anyway, so I'm not entirely conviced it would save you much time/effort.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes