PDA

View Full Version : Loading rollouts from external files


tuomasj
09-15-2005, 02:26 PM
Hi,

I am trying to make a custom laucher for all sorts of scripts that I am using. I wrote a script that iterates through a text file which has script's filename and rollout name.

like:

general.ms generalStuffRollout
rigging.ms riggingBasicRollout
stupid.ms stupidUselessRollout


I have one big float window on screen and I'm trying to add every loaded rollout in it, but this is what I get:
-- Type error: addRollout requires RolloutClass, got: "generalStuffRollout"

Here is that piece of code that generates the error:

for each line in file:
(scriptFilename and rolloutName are parsed each time)
FileIn scriptFilename
addRollout rolloutName


Does anyone know what is the problem here?

Thanks,

Tuomas

Light
09-15-2005, 02:54 PM
Are your rollouts in global scope?




Light

tuomasj
09-15-2005, 03:12 PM
Are your rollouts in global scope?

Well, I think so. Haven't really figured out how to load scripts dynamically the right way.

I mean, hehe, the structure of extenal rollout looks like this:


rollout generalStuffRollout "General stuff rollout" (
button dummyButton "Button"
...etc...
)


Or is there a easier / better way to do this kind of script launcher? Loading dynamically UI elements from other scripts...

--tuomas

Light
09-15-2005, 03:31 PM
Try this:

Put your rollout definitions into stdscripts folder. They will be defined when max loaded. After that you can use a script to combine them all in a script like this:

global rollout01, rollout02, rollout03, rAllInOne

rAllInOne = newRolloutFloater "All In One" 200 450

addRollout rollout01 rAllInOne
addRollout rollout02 rAllInOne
addRollout rollout03 rAllInOne

This is better than fileIn because each time you use fileIn, max will reevaluate the contents of the script, whereas this method will define your rollout definitions once when max starts.




Light

Bobo
09-15-2005, 03:34 PM
Hi,

I am trying to make a custom laucher for all sorts of scripts that I am using. I wrote a script that iterates through a text file which has script's filename and rollout name.

like:

general.ms generalStuffRollout
rigging.ms riggingBasicRollout
stupid.ms stupidUselessRollout


I have one big float window on screen and I'm trying to add every loaded rollout in it, but this is what I get:
-- Type error: addRollout requires RolloutClass, got: "generalStuffRollout"

Here is that piece of code that generates the error:

for each line in file:
(scriptFilename and rolloutName are parsed each time)
FileIn scriptFilename
addRollout rolloutName


Does anyone know what is the problem here?

Thanks,

Tuomas


According to the error message, "generalStuffRollout" is still a string from your list of names, not a rollout class. After FileIn and before addRollout, you have to convert the rollout name into the rollout instance using EXECUTE:

for each line in file:
(scriptFilename and rolloutName are parsed each time)
FileIn scriptFilename
theRollout = execute rolloutName --get the rollout instance by name
addRollout theRollout --add the instance, not the name

tuomasj
09-16-2005, 06:21 AM
you have to convert the rollout name into the rollout instance using EXECUTE:

Thanks, that did the trick! :) Now it works just the way I wanted.


Light, thanks for your tip. I'll try that too.

--tuomas

CGTalk Moderation
09-16-2005, 06:21 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.