Notifications
Clear all
[Closed] Read RGB light colors from file
Dec 18, 2009 7:28 pm
Hi
I'm doing a plugin for FumeFX which involves lights.
I want that the color of the light created is taken from a file.
I'm thinking on something like this:
the file light_color.txt has this:
Light color:
(color 255 0 0)
and the script has a part like this:
omnilight rgb:(color 230 255 255)
I want this:
omnilight rgb:[b]LIGHT_COLOR FILE COLOR[/b]
I want the RGB to read the 3rd line of the txt file.
Thanks
Nahuel
3 Replies
Dec 18, 2009 7:28 pm
Search the help file for “FileStream”.
A FileStream class implements text file input and output in MAXScript. A FileStream value represents an open text file in MAXScript. Text file I/O is performed by calling functions on the FileStream value.
-Eric
[left]
[/left]
Dec 18, 2009 7:28 pm
So, I managed to get this working:
Here is the code:
(
f = openfile “C:\Program Files\Autodesk\3ds Max 2010\Scripts\Startup\light_color.txt”while (not eof f) do ( inputData = readLine f inputData = trimright inputData inputArray = filterString inputData " " if inputArray.count == 3 do ( Rvalue = inputArray[1] as float Gvalue = inputArray[2] as float Bvalue = inputArray[3] as float ) ) omnilight rgb:(color Rvalue Gvalue Bvalue) )
Text file (light_color.txt):
255 0 0
But when i put that in my plugin, it gives me error.
Here is the plugin:
plugin light myLight
name:“myLight”
category: “myLight”( tool create ( f = openfile "C:\Program Files\Autodesk\3ds Max 2010\Scripts\Startup\light_color.txt" while (not eof f) do ( inputData = readLine f inputData = trimright inputData inputArray = filterString inputData " " if inputArray.count == 3 do ( Rvalue = inputArray[1] as float Gvalue = inputArray[2] as float Bvalue = inputArray[3] as float ) ) omnilight rgb:(color Rvalue Gvalue Bvalue) ) )
Why?