[Closed] Loading rollouts from external files
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
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
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
Thanks, that did the trick! Now it works just the way I wanted.
Light, thanks for your tip. I’ll try that too.
–tuomas