Controlling Daylight System with MAXscript

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  05 May 2010
Controlling Daylight System with MAXscript

Hi everyone

I'm just starting to learn MAXScript, and I know the basics, but I would like to figure out how to change a Daylight system that I have manually created using a script.

Based on this documentation, I've put together the following code:


 $Daylight01.controller
 
 Controller:Sunlight_Daylight_Slave_Controller
 
 <Daylight_Slave_Controller>.solar_time Float
 
 fn TimeFromSolarTime solar_time = 
 
 (
 
 hrs = int(solar_time/3600.0) -- full hours in the solar_time value
 
 min = int((solar_time - hrs*3600.0)/60.0) -- full minutes in the difference between the full time and the full hours
 
 sec = int(solar_time - hrs*3600.0 - min*60.0 + 0.5) -- full seconds in the rest of the value
 
 #(hrs,min,sec) -- return the result as a 3 elements array
 
 )
 


I'm not exactly sure where to insert the actual desired time value (I've tried a few places). In any case, when I select the code and press Enter to run it, I get the following error:

Controller:Sunlight_Daylight_Slave_Controller
 -- Error occurred in anonymous codeblock; filename: C:\Users\Jeremy\Documents\Modeling and Design\3dsMAX\scripts\lightcalc.ms; position: 37
 -- Syntax error: at keyword parameter, expected <factor>
 --  In line: Controller:S


There is precious little documentation on this, so I would appreciate the help!
 
  05 May 2010
The first three lines arent actually needed.
If you have created the sunlight system, you need to call the function like so:

TimeFromSolarTime(300.0)

I take it you are starting out with max so i'll explain it a bit.
"fn" means you're starting a new function. after that comes the function name followed by any paramaters you want to pass to the function. The function code is the bit between the brackets. You need to define the function before calling it (otherwise it doesnt exist yet). so in the example below it does just that.
If the function needs paramaters, you must specify what they are by putting it in the brackets. the example passes 300.0



 
fn TimeFromSolarTime solar_time = 
 
(
hrs = int(solar_time/3600.0) -- full hours in the solar_time value
min = int((solar_time - hrs*3600.0)/60.0) -- full minutes in the difference between the full time and the full hours
sec = int(solar_time - hrs*3600.0 - min*60.0 + 0.5) -- full seconds in the rest of the value
solar_array = #(hrs,min,sec) -- return the result as a 3 elements array
return(solar_array) 
)
 
TimeFromSolarTime(300.0)
print solar_array



now it loads and returns and array with 3 values called solar_array.
to access the individual values you do it like this:

solar_array[1] --hrs
solar_array[2] --min
solar_array[3] --sec
__________________
www.richterdesigns.co.uk

Last edited by dutch_delight : 05 May 2010 at 12:55 PM.
 
  05 May 2010
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:30 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.