Author Topic: Need some scripting help  (Read 3515 times)

Offline jwilliams31

  • Sr. Member
  • ****
  • Posts: 145
    • Williams Family Christmas Lights
Need some scripting help
« on: November 29, 2011, »
I have 2 trees that I have set up kind of like a mega tree. A bunch of strings running down, each on a separate channel. I was thinking of possibly having them do a slow chase during the background sequence, but need some help with how to script it.

Also, during the background, I currently have the lights on some bushes do a fade between white and multi-colored strings every 5 minutes.

Here is my current script:

Code: You are not allowed to view links. Register or Login
while (now.CompareTo(start0) >= 0 && now.CompareTo(end0) <= 0)
{
On(Channels(allOther), At (60));
On(Channels(whiteLights), At (60), For (300).Seconds, Wait);

Ramp(Channels(whiteLights), 60, 0, Over (10).Seconds);
Ramp(Channels(multiLights), 0, 60, Over (10).Seconds, Wait);

On(Channels(multiLights), At (60), For (300).Seconds, Wait);

Ramp(Channels(multiLights), 60, 0, Over (10).Seconds);
Ramp(Channels(whiteLights), 0, 60, Over (10).Seconds, Wait);

now = DateTime.Now; //update the current time
}

The problem is that, with the Waits for the fades, the Chase function doesn't work right because it completes and then stops and waits.

Does anyone have any thoughts on how I can make the chase work with the above script?

I already tried posting on DIYC, but so far I havent found a solution.

Thanks.

Jason
Einstein once said: "There are two things that are infinite; the universe and human stupidity. And, I'm not too sure about the universe."

Offline inzeos

  • Sr. Member
  • ****
  • Posts: 505
Re: Need some scripting help
« Reply #1 on: November 29, 2011, »
Interesting... Did not know you could script like that in Vixen...  Is that in all current versions?

Offline rrowan

  • Administrator
  • Sr. Member
  • *****
  • Posts: 5899
  • 08096
Re: Need some scripting help
« Reply #2 on: November 29, 2011, »
see if this post provides any useful info

You are not allowed to view links. Register or Login

Rick R.
Light Animation Hobby - Having fun and Learning at the same time. (21st member of DLA)
You are not allowed to view links. Register or Login
Warning SOME assembly required

Offline DanHouston

  • Sr. Member
  • ****
  • Posts: 499
Re: Need some scripting help
« Reply #3 on: November 30, 2011, »
I'm not totally sure what you are trying to do, so this may not help, but I'll take a stab at it....

I think you want to switch between your white lights and multi-color lights every 5 minutes. And you want them to ramp on/off as the transition to do that. If that's what you want to do here's what I would do (I'll send you my code that does this every minute when I get home):
1. Create a variable that stores the state of your white lights (Integer whiteOn;) (You could also use boolean, but I prefer integer). Let's say 0 is off and 1 is on.
2. Use the Mod function (I think it is %) with 5 and check for 0 (so this will evaluate to true every 5 minutes).
    a. If whiteOn = 0 (ramp on white and ramp off multi....no need for the wait parameter)
    b. if whiteOn = 1 (ramp on multi and ramp off white....no need for the wait parameter)

Here is some uncompiled code so there are probably errors in it, but should get you going (again, I'll post the real code when I get home):

Integer whiteOn;
.
.
.
whiteOn = 0;
.
.
.
while (now.CompareTo(start0) >= 0 && now.CompareTo(end0) <= 0)
    {
        On(Channels(allOther), At (60));
        if (now.minutes % 5 == 0) then
            {
                if (whiteOn == 0) then
                    {
                        Ramp(Channels(multiLights), 60, 0, Over (10).Seconds);
                        Ramp(Channels(whiteLights), 0, 60, Over (10).Seconds);
                        whiteOn = 1;
                    }
                else
                    {
                        Ramp(Channels(whiteLights), 60, 0, Over (10).Seconds);
                        Ramp(Channels(multiLights), 0, 60, Over (10).Seconds);
                        whiteOn = 0;
                    }
            }                               
        //update the current time
        now = DateTime.Now;
    }


2011 - Year #1
    4000 lights and 16 channels
    5 Songs sequenced
2012 - Year #2
    5000 lights and 123 channels
    8 Songs sequenced

Offline inzeos

  • Sr. Member
  • ****
  • Posts: 505
Re: Need some scripting help
« Reply #4 on: November 30, 2011, »
You are not allowed to view links. Register or Login
I'm not totally sure what you are trying to do, so this may not help, but I'll take a stab at it....

I think you want to switch between your white lights and multi-color lights every 5 minutes. And you want them to ramp on/off as the transition to do that. If that's what you want to do here's what I would do (I'll send you my code that does this every minute when I get home):
1. Create a variable that stores the state of your white lights (Integer whiteOn;) (You could also use boolean, but I prefer integer). Let's say 0 is off and 1 is on.
2. Use the Mod function (I think it is %) with 5 and check for 0 (so this will evaluate to true every 5 minutes).
    a. If whiteOn = 0 (ramp on white and ramp off multi....no need for the wait parameter)
    b. if whiteOn = 1 (ramp on multi and ramp off white....no need for the wait parameter)

Here is some uncompiled code so there are probably errors in it, but should get you going (again, I'll post the real code when I get home):

Integer whiteOn;
.
.
.
whiteOn = 0;
.
.
.
while (now.CompareTo(start0) >= 0 && now.CompareTo(end0) <= 0)
    {
        On(Channels(allOther), At (60));
        if (now.minutes % 5 == 0) then
            {
                if (whiteOn == 0) then
                    {
                        Ramp(Channels(multiLights), 60, 0, Over (10).Seconds);
                        Ramp(Channels(whiteLights), 0, 60, Over (10).Seconds);
                        whiteOn = 1;
                    }
                else
                    {
                        Ramp(Channels(whiteLights), 60, 0, Over (10).Seconds);
                        Ramp(Channels(multiLights), 0, 60, Over (10).Seconds);
                        whiteOn = 0;
                    }
            }                               
        //update the current time
        now = DateTime.Now;
    }

You could probably simplify it a lot... by setting the channels to a known state to start with an assuming that the state will stay the same.

Then you can ramp on for a ramp period for one and off for another and pause or sleep for the amount of time that one color should be on for.

Offline DanHouston

  • Sr. Member
  • ****
  • Posts: 499
Re: Need some scripting help
« Reply #5 on: November 30, 2011, »
It looked like he was trying to do that with the wait commands and it was not working for him. In mine I am doing other things so I want to run the loop every 10 seconds or so (I think that is the default), and I wanted it to be odd/even minutes so I had to check the time (of course if you are not concerned with that then what you had mines the wait on the RAMP commands should work). A couple of updates to the previous bit I posted....should work, although I did not have a chance to test with my lights.

int whiteOn = 0;
.
.
.
while (now.CompareTo(start0) >= 0 && now.CompareTo(end0) <= 0)
    {
        On(Channels(allOther), At (60));
        if (now.minutes % 5 == 0) then
            {
                if (whiteOn == 0)
                    {
                        Ramp(Channels(multiLights), 60, 0, Over (10).Seconds);
                        Ramp(Channels(whiteLights), 0, 60, Over (10).Seconds);
                        whiteOn = 1;
                    }
                else
                    {
                        Ramp(Channels(whiteLights), 60, 0, Over (10).Seconds);
                        Ramp(Channels(multiLights), 0, 60, Over (10).Seconds);
                        whiteOn = 0;
                    }
            }                               
        //update the current time
        now = DateTime.Now;
    }

2011 - Year #1
    4000 lights and 16 channels
    5 Songs sequenced
2012 - Year #2
    5000 lights and 123 channels
    8 Songs sequenced

Offline jwilliams31

  • Sr. Member
  • ****
  • Posts: 145
    • Williams Family Christmas Lights
Re: Need some scripting help
« Reply #6 on: December 01, 2011, »
Actually I'm trying to do 2 things.

1) I want to switch between my white and multicolored lights with an overlapping fade for the transition.  This IS working with the code that I posted.

2) I have 2 trees that I draped light strings down, similar to a mega tree (just with fewer lights).  I would like to have the lights on these trees chase.

The problem I'm having is getting these to work together. 

If I use the "chase" function, it will run through once, but then will not run again until the Waits complete.

I'm looking for some advice on how to get these to play nice together.  A constant chase as well as the light transition every 5 minutes.

Thanks.

Jason
Einstein once said: "There are two things that are infinite; the universe and human stupidity. And, I'm not too sure about the universe."

Offline jwilliams31

  • Sr. Member
  • ****
  • Posts: 145
    • Williams Family Christmas Lights
Re: Need some scripting help
« Reply #7 on: December 01, 2011, »
I added Dan's example.  Here's what I have now:

Code: You are not allowed to view links. Register or Login
while (now.CompareTo(start0) >= 0 && now.CompareTo(end0) <= 0)
  {
    On(Channels(allOther, palmLights1,
palmLights2, palmLights3, palmLights4,
palmLights5, palmLights6, Signs), At (60));
    Chase(ChannelRange(palmLights1, palmLights6), Over (3700).Milliseconds);
    if (now.minutes % 5 == 0)
    {
      if (whiteOn == 0)
      {
        Ramp(Channels(multiLights), 60, 0, Over (10).Seconds);
        Ramp(Channels(whiteLights), 0, 60, Over (10).Seconds);
        whiteOn = 1;
      }
      else
      {
        Ramp(Channels(multiLights), 60, 0, Over (10).Seconds);
        Ramp(Channels(whiteLights), 0, 60, Over (10).Seconds);
        whiteOn = 0;
      }
    }
    now = DateTime.Now; //update the current time
  }

But it won't compile.  I get an error:

"System.DateTime does not contain a definition for minutes"

for this line,  if (now.minutes % 5 == 0).

Thanks.

Einstein once said: "There are two things that are infinite; the universe and human stupidity. And, I'm not too sure about the universe."

Offline DanHouston

  • Sr. Member
  • ****
  • Posts: 499
Re: Need some scripting help
« Reply #8 on: December 01, 2011, »
Mispelled it....now.Minute
2011 - Year #1
    4000 lights and 16 channels
    5 Songs sequenced
2012 - Year #2
    5000 lights and 123 channels
    8 Songs sequenced

Offline jwilliams31

  • Sr. Member
  • ****
  • Posts: 145
    • Williams Family Christmas Lights
Re: Need some scripting help
« Reply #9 on: December 02, 2011, »
Vixen doesn't like something.  It keeps crashing when I run the script.



Einstein once said: "There are two things that are infinite; the universe and human stupidity. And, I'm not too sure about the universe."

Offline DanHouston

  • Sr. Member
  • ****
  • Posts: 499
Re: Need some scripting help
« Reply #10 on: December 02, 2011, »
I'll adjust it to match my light profile and run it when I get home.
2011 - Year #1
    4000 lights and 16 channels
    5 Songs sequenced
2012 - Year #2
    5000 lights and 123 channels
    8 Songs sequenced

Offline DanHouston

  • Sr. Member
  • ****
  • Posts: 499
Re: Need some scripting help
« Reply #11 on: December 02, 2011, »
It does not seem to like using Milliseconds....I've never done anything that granular with a script in Vixen so I don't have experience with it (I've always done it over seconds). I changed it to 3 seconds for testing purposes and it ran without crashing.

Start by commenting out the chase command and see if it runs for you. If it does you know that you need to work on the chase command. Next you might try my test of using seconds rather than milliseconds.

The other thing I did not get to test here (I just had the chase on a single light) was if it is really working correctly since nothing is slowing it down from being called over and over again....You may need to enclose it in an if/then check to make sure it is not called again until the previous run completed (you could use wait here, but since you are doing 3.7 seconds that will hurt your 5 minute check).
2011 - Year #1
    4000 lights and 16 channels
    5 Songs sequenced
2012 - Year #2
    5000 lights and 123 channels
    8 Songs sequenced

Offline jwilliams31

  • Sr. Member
  • ****
  • Posts: 145
    • Williams Family Christmas Lights
Re: Need some scripting help
« Reply #12 on: December 03, 2011, »
So I disabled everything except the transition.  Vixen doesn't seem to be crashing now, but it's also not doing the transition correctly.  The just kind of flicker and then eventually both the white and multicolor stay on.

Here is my code as it is right now.  I'm going to try to take a screen recording to show you the behavior that I'm seeing when I run/preview it.

Code: You are not allowed to view links. Register or Login
int whiteOn;

whiteOn = 0;

  while (now.CompareTo(start0) >= 0 && now.CompareTo(end0) <= 0)
  {
//    On(Channels(allOther, palmLights1,
// palmLights2, palmLights3, palmLights4,
// palmLights5, palmLights6, Signs), At (60));

    if (now.Second % 20 == 0)
    {
      if (whiteOn == 0)
      {
        Ramp(Channels(multiLights), 60, 0, Over (10).Seconds);
        Ramp(Channels(whiteLights), 0, 60, Over (10).Seconds);
        whiteOn = 1;
      }
      else
      {
        Ramp(Channels(whiteLights), 60, 0, Over (10).Seconds);
        Ramp(Channels(multiLights), 0, 60, Over (10).Seconds);
        whiteOn = 0;
      }
    }
    now = DateTime.Now; //update the current time
  }
Einstein once said: "There are two things that are infinite; the universe and human stupidity. And, I'm not too sure about the universe."

Offline DanHouston

  • Sr. Member
  • ****
  • Posts: 499
Re: Need some scripting help
« Reply #13 on: December 03, 2011, »
It's not doing the ramp correctly? Do you have anywhere in your code where those are just set to ON? Is your last post your complete script?

I saw that flickering in mine when I accidentally had one of the channels in the original "ON" command with my other lights.
2011 - Year #1
    4000 lights and 16 channels
    5 Songs sequenced
2012 - Year #2
    5000 lights and 123 channels
    8 Songs sequenced

Offline jwilliams31

  • Sr. Member
  • ****
  • Posts: 145
    • Williams Family Christmas Lights
Re: Need some scripting help
« Reply #14 on: December 03, 2011, »
No.  In fact I just completely simplified the script and removed everything except the lights I want to transition.

This is my entire script.

Code: You are not allowed to view links. Register or Login
void Start() {

//***********************************************************************************************

DateTime now = DateTime.Now; //Gets the current time

ChannelCollection whiteLights;
ChannelCollection multiLights;

//*********************************************************************************************

whiteLights = Channels(Center_Oak_White, Bush_1_White, Bush_2_White, Bush_3_White, Bush_4_White,
Bush_5_White, Bush_6_White, Split_Palm_White, Left_Oak_White);

multiLights = Channels(Center_Oak_Multi, Bush_1_Multi, Bush_2_Multi, Bush_3_Multi, Bush_4_Multi,
Bush_5_Multi, Bush_6_Multi, Split_Palm_Multi, Left_Oak_Multi);

//*********************************************************************************************

int whiteOn;
whiteOn = 0;

//*********************************************************************************************

  while (true)
  {
    if (now.Second % 20 == 0)
    {
      if (whiteOn == 0)
      {
        Ramp(Channels(multiLights), 60, 0, Over (10).Seconds);
        Ramp(Channels(whiteLights), 0, 60, Over (10).Seconds);
        whiteOn = 1;
      }
      else
      {
        Ramp(Channels(whiteLights), 60, 0, Over (10).Seconds);
        Ramp(Channels(multiLights), 0, 60, Over (10).Seconds);
        whiteOn = 0;
      }
    }
 
    now = DateTime.Now; //update the current time
  }
}

Also, the script with run for about a minute or so, the lights will flicker and then stay on and then Vixen will crash.

In case I hadn't mentioned it yet, I'm running this on 2.1.4.0
« Last Edit: December 03, 2011, by jwilliams31 »
Einstein once said: "There are two things that are infinite; the universe and human stupidity. And, I'm not too sure about the universe."