cteasley Posted March 2, 2010 Share Posted March 2, 2010 During, I believe, the Tech I training, the notion of using variables to trigger the execution of code that could be initiated from multiple locations within the project was discussed.In some senses, it does complicate the programming but the long term benefits are well worth it. Specifically, it reduces the number of lines of code in the “main” script, and more importantly, it makes it easier to maintain the project and thus, the project is more stable over time. I believe it is what the object-oriented folks call encapsulation. For example, let’s say your project is configured so that there is a custom button and a keypad button to turn off the theater. Instead of placing the same code in the custom button and in the keypad button script: 1. Define a Boolean variable (e.g., TheaterOff) 2. Place the common code in the When the variable Variables->TheaterOff changes script 3. Perform Toggle Variables->TheaterOff in the “main” script to initiate the common code Now when it is time to modify the turning off of the Theater, you only have to do this in one location, and don’t have to try to remember all the places you or one of your associates put the turn off Theater logic. You can go so far as to adopt a convention that states all projects will have a RoomOn, RoomOff, RoomLightsOn, RoomLightsOff, RoomAVOn, and RoomAVOff variable for every room in the project. The RoomLightsOn and RoomLightsOff variables might be considered a little redundant of a light scene but it does provide a level of consistancy. Thoughts or other recommendations? Link to comment Share on other sites More sharing options...
This topic is now archived and is closed to further replies.