It's been about 10 years since I've done any real VB.NET programming and this is my first real stab at it in HS3. At this point I think I've got tunnel vision and perhaps a different set of eyes would be helpful. I am trying to make a script that will cycle through the scenes I've created for a particular room. I used a naming convention to help make this a little easier. Scenes for the bedroom begin with "br ", as in "br Deep Sea". Or "fr Deep Sea" for the family room.
If I can successfully get this one working, then I'll make one to cycle in the other direction. The problem I am having is that with each run of the script, a scene is skipped. So I'm just getting every other scene. The script is properly recognizing when it's at the top of the list and starts back at the beginning. No matter what I try it will either skip a scene or just stay on the same scene. Any insight would be greatly appreciated.
If I can successfully get this one working, then I'll make one to cycle in the other direction. The problem I am having is that with each run of the script, a scene is skipped. So I'm just getting every other scene. The script is properly recognizing when it's at the top of the list and starts back at the beginning. No matter what I try it will either skip a scene or just stay on the same scene. Any insight would be greatly appreciated.
Code:
Imports System.Collections.Generic Imports System.IO Sub Main(ByVal Parm As Object) Dim currscene As String = hs.GetVar("brscene") Dim nextscenenum As Integer = 0 Dim scenes() As String = hs.PluginFunction("JowiHue", "", "GetScenes", Nothing) Dim maxscenes As Integer = scenes.GetUpperBound(0) Dim x As Integer = 0 Dim y As Integer = 0 Dim roomscenes As New List(Of String) For x = 0 To maxscenes Dim scene As String = scenes(x) If Left(scene, 3) = "br " Then roomscenes.Add(scene) y = y + 1 If scene = currscene Then nextscenenum = y End If End If If x < maxscenes Then x = x + 1 Next Dim maxroomscenes As Integer = y Dim startscene As Integer Dim z As Integer If nextscenenum > 0 Then If nextscenenum > maxroomscenes Then startscene = 1 Else startscene = nextscenenum End If Else startscene = 1 End If hs.PluginFunction("JowiHue", "", "StartScene", {roomscenes(startscene)}) hs.SaveVar("brscene", roomscenes(startscene)) End Sub
Comment