--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --This script opens up a floater in which a countdown to the next autobackup is shown in numbers and the progress bar. You may skip the next --autobackup by pressing the "skip" button. 3dsmax will not autobackup your files when you haven't changed the scene, which would cause --the timer to get asynchronized. This script will always force autobackup to keep it synchronized, no matter if you changed anything in the scene, --so make sure your autobak-files don't get overwritten too fast when AFK. Timer-offset should be close to 0m 0s (as in the listener), sometimes it pops away for a few --seconds, but usually gets synched right afterwards. There still is lots of room for improvement i guess :] --Note: You need an Autobackup-Interval of at least 0.2 (12 seconds), or this script will not work properly. --You can change the autobackup-interval while the script is running, just hit "skip" once to synchronize. --Tested with Max 2009. May work in prior versions, but definitely not below Max 9. -- --v0.1 Still some debugging stuff in here, to get some feedback while running. -- --written by br0t --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- macroScript autobakTimer category:"Custom" ButtonText:"Autobak Timer" tooltip:"Time until next Autobackup" ( rollout ro_autobakTimer "Autobak" width:89 height:29 ( global myArray=#() --used to check for type of saving, here: if it was an autobackup local myTime = autoBackup.time*60 as Integer --myTime specifies the time until next backup. starts with the preset value in seconds. local outTime = autoBackup.time*60 as Integer --time to put out as the label caption local one = 100/(autoBackup.time*60.0) --one percent local interim1 = 0.0 --helper to calculate progress bar iteration local interim2 = 0.0 --helper to calculate progress bar iteration local interim3 = 0.0 --helper to calculate progress bar iteration local temp = autoBackup.time as float --helper to store interval for later reset Timer clock_secs "" pos:[37,-16] width:24 height:24 interval:1000 progressBar pb_nextBackup "" pos:[-1,-1] width:90 height:13 enabled:true value:0 color:(color 30 10 190) label time_cnt "" pos:[3,15] width:41 height:14 button btn_skip "Skip" pos:[47,14] width:42 height:15 fn resetStuff= --'nuff said ( myTime = autoBackup.time*60 as Integer outTime = autoBackup.time*60 as Integer one = 100/(autoBackup.time*60.0) interim1 = 0.0 interim2 = 0.0 interim3 = 0.0 temp = autoBackup.time pb_nextBackup.value = 0 )--end fn fn forceBackup= --force a backup: setting a very short interval, resetting the timer and constructing a box for a very short time to change the scene (needed to trigger autobackup) ( print "autobakTimer - Force Backup..." resetStuff() autoBackup.time = 0.01 myBox = box() autosave.resetTimer() delete myBox )--end fn on ro_autobakTimer open do --adds callbacks for saving when the rollout is created ( if autoBackup.time < 0.2 then --check for very low interval, this script will not work with such low values ( messagebox "autobakTimer - The Autobackup-Interval has to be at least 0.2 min." destroyDialog ro_autobakTimer )--end if callbacks.Addscript #filePostSaveProcess "myArray = (callbacks.notificationParam())" id:#countdownBackup --save the type of saving into myArray -> to check if it has been an autobackup print "autobakTimer - Callbacks have been registered." autosave.resetTimer() --reset the timer at startup, to synchronize script to the internal autobacktimer of 3dsmax )--end on open on ro_autobakTimer close do --removes the callbacks when the rollout is closed ( callbacks.removescripts #filePostSaveProcess id:#countdownBackup print "autobakTimer - Callbacks have been deleted." resetStuff() temp = undefined --release old value )--end on on btn_skip pressed do --reset stuff ( autosave.resetTimer() resetStuff() )--end on on clock_secs tick do ( if (autobackup.enabled) then --if autobackup is not enabled, give a hint (see below) ( if myArray[1] == 3 do --check the myArray2 for autobackups ( print ("autobakTimer - Autobackup finished, Timer reset at: "+outTime as String) autoBackup.time = temp --reset the interval, for if forceBackup has been triggered before resetStuff() myArray[1] = 0 --reset myArray2[1] )--end if --iterating and coloring the progress bar: interim1 = interim1 + one --this is a float value that represents the maximum percentage the progressbar should be filled interim2 = (mod interim1 1) --the rest of mod, has to be subtracted from interim1 to get a value that can be converted to integer interim3 = (interim1-interim2) as integer -- final integer value that equals the desired value of the progressbar pb_nextBackup.value = interim3 if pb_nextBackup.value >= 100 then (pb_nextBackup.color = [0,0,0]) else if pb_nextBackup.value >= 90 then (pb_nextBackup.color = [255,0,0]) else if pb_nextBackup.value >= 75 then (pb_nextBackup.color = [225,190,10]) else if pb_nextBackup.value >= 50 and pb_nextBackup.value < 75 then (pb_nextBackup.color = [255,255,20]) else (pb_nextBackup.color = [30,190,10]) valDown = (myTime as integer)-1 --helper variable to count down from start time if valDown == -1 do ( forceBackup() )--end if myTime = valDown outTime = ((myTime/60) as String+"m "+((mod myTime 60) as integer) as String+"s") --calculating output time time_cnt.caption = outTime as String )--end if else (time_cnt.caption = "disabled") )--end on )--end rollout createDialog ro_autobakTimer )--end macroscript