Notifications
Clear all

[Closed] toggle a script on and off

thanks guys! such a dumb little thing… but now i see how toggling works and i am sure it will come in use in the future…

I took the script a few steps further, not the toolbar button will check on and off to show the light status, and any lights that are created will be set to the current toggle state. ie If the lights are toggled off any lights that are copied, cloned or merged will be turned off.

Here’s the code:

macroScript lightsToggle
 	category:"Wahooney Tools"
 	tooltip:"Toggle Lights On\Off"
 	buttonText:"Lights off"
 (
 	global lightStatus = true
 	global LightToggleCB
 	
 	fn LightToggleCB =
 	(
 		n = callbacks.notificationParam()
 		
 		if superclassof n == light then
 			n.on = lightStatus
 	)
 	
 	on execute do
 	(
 		lightStatus = not lightStatus
 		lights.on = lightStatus
 	)
 	
 	on isChecked do
 	(
 		not lightStatus
 	)
 	
 	callbacks.removeScripts id:#wtToggleLights
 	callbacks.addScript #sceneNodeAdded "LightToggleCB()" id:#wtToggleLights
 )
 
Page 2 / 2