Calling CycleStates from script loses client context?

Forum to discuss MLScript plugin that enables VBScript and JavaScript scripting within MLServer3.
User avatar
simonmason
Expert
Expert
Posts: 855
Joined: Tue Dec 26, 2006 9:06 pm
Contact:

Calling CycleStates from script loses client context?

Postby simonmason » Sat Jan 03, 2009 8:38 am

Ok, I am using the default AudioZones cyclestates in the the 0019 setup. I can issue the command MLCycleStates|Next~AudioZones from any scene no problem - this then increments a number of variables including one called client_actzone.

Now, when I issue the same command from a script it creates a new variable called _actzone and increments this. Obviously even though the script is being called from a scene within MainLobby it is losing the context of the client name?

How can I pass the client name to cyclestates to get it to increment the correct variable?
Simon D. S. Mason

User avatar
simonmason
Expert
Expert
Posts: 855
Joined: Tue Dec 26, 2006 9:06 pm
Contact:

Postby simonmason » Sat Jan 03, 2009 10:28 am

P.S. I tried using the doPlugin command because it provides the context of the client name - this didn't work but I may not have gotten the syntax right - then again, it might not be the right command to use here!

'MLServer.doPlugin "MLCycleStates", "AudioZones", "Next", cStr(client)
Simon D. S. Mason

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Postby CinemarDave » Sat Jan 03, 2009 1:31 pm

You have to specifically pass the client name to the script function in order for the sript to use it. Post the script you are using here and I'll show you how it can be modified to process the clientname variable.

User avatar
simonmason
Expert
Expert
Posts: 855
Joined: Tue Dec 26, 2006 9:06 pm
Contact:

Postby simonmason » Sat Jan 03, 2009 2:46 pm

Here is the script in question. Just search for cyclestates for the specific section. Thanks.

Code: Select all

Option Explicit

' MLServer Command Reference
'  MLServer.cmdReceive command - allows you to send MLServeCmd's back to the server
'  MLServer.cmdReceivePush command - allows you to push a MLServeCmd onto the MLServer command queue
'  MLServer.SetVariable variable, value - allows you to set MLServer variables
'  MLServer.GetVariable variable - allows you to get the value of the specified MLServer variable
'  MLServer.DelVariable variable, value - allows you to delete MLServer variables
'  MLServer.LogMLEvent sName, sEvent - allows you to add an entry in the MLServer Event Log
'  MLServer.doPlugin PluginName, PluginCommand, PluginParameters, ClientName


Sub ZoneSelect (Params)
' Param one is zone number (room) - controlled by mlcyclestates - currently 1-8
' Param two is client name
' Param three is "NO" to NOT switch source or "CHA1,2,3,4,5,6,OFF" to change source as well as switching screen
' Param four is "YES" to change zone or "NO" to not change zone
' Example call: MLScript|Audio.ZoneFunctions~ZoneSelect~{{{{clientname}}_actzone}}~{{clientname}}~NO~YES

' Script will load appropriate playing now based upon source

Dim ZoneSource
Dim Zone
Dim client, switchsource, switchzone, actzone
Dim MyServer, temp

 
 
   ' Retrieve system variables
       MyServer = MLServer.GetVariable ("server_servername")
     temp =  "1 - Started Script Audio.ZoneFunctions in Sub ZoneSelect with params : " & params(0) & " & " & params(1) & " & " & params(2) & " & " & params(3)
        MLServer.LogMLEvent cStr(MyServer),cStr(temp) ,0

   ' Retrieve paramaters
   Zone = Params(0)
   client = params(1)
   switchsource = params(2)
   switchzone = params(3)
 
    if switchzone = "YES" then
      temp =  "Changing Zone from zone reported in command line - " & Zone
      MLServer.LogMLEvent cStr(MyServer), cstr(temp), 0
      actzone = client & "_actzone"
      Zone = MLServer.GetVariable(cStr(actzone))
      temp =  "Changing Zone from zone retrieved from variable - " & Zone
      MLServer.LogMLEvent cStr(MyServer), cstr(temp), 0

      MLServer.LogMLEvent cStr(MyServer), cstr(temp), 0
      'MLServer.cmdReceive "MLCycleStates|Next~AudioZones"
      'MLServer.doPlugin "MLCycleStates", "AudioZones", "Next", cStr(client)
      MLServer.cmdReceive "MLCycleStates|Next~AudioZones"
      Zone = MLServer.GetVariable(cStr(actzone))
      temp =  "New Zone is  - " & Zone
      MLServer.LogMLEvent cStr(MyServer), cstr(temp), 0

   end if

   Select case Zone
   case 1
      ZoneSource = MLServer.GetVariable("mlhsplugin_n17")
   case 2
      ZoneSource = MLServer.GetVariable("mlhsplugin_n18")
   case 3
      ZoneSource = MLServer.GetVariable("mlhsplugin_n19")
   case 4
      ZoneSource = MLServer.GetVariable("mlhsplugin_n20")
   case 5
      ZoneSource = MLServer.GetVariable("mlhsplugin_n21")
   case 6
      ZoneSource = MLServer.GetVariable("mlhsplugin_n22")
   case 7
      ZoneSource = MLServer.GetVariable("mlhsplugin_o85")
   case 8
      ZoneSource = MLServer.GetVariable("mlhsplugin_o86")
   case 9
      ZoneSource = MLServer.GetVariable("mlhsplugin_o87")
   case 10
      ZoneSource = MLServer.GetVariable("mlhsplugin_o88")
   case 11
      ZoneSource = MLServer.GetVariable("mlhsplugin_o89")
   case 12
      ZoneSource = MLServer.GetVariable("mlhsplugin_o90")
   end select

   Select case ZoneSource
   case "CHA1"
      ' Tuner 1
      MLServer.LogMLEvent cStr(MyServer), "CHA1 found through case",0
      MLServer.cmdReceivePush "MLCmd|ChangeScene~" & Client & "~" & "0019_media_radio1.mls"
   case "CHA2"
      ' Amy's playlist
      MLServer.LogMLEvent cStr(MyServer), "CHA2 found through case",0
      MLServer.cmdReceive "MLCmd|ChangeScene~" & Client & "~" & "0019_media.mls"   
      WScript.Sleep(2000)
      MLServer.cmdReceivePush "Zone.CHA2"
   case "CHA3"
      ' Tuner 2
      MLServer.LogMLEvent cStr(MyServer), "CHA3 found through case",0
      MLServer.cmdReceivePush "MLCmd|ChangeScene~" & Client & "~" & "0019_media_radio3.mls"
   case "CHA4"
      ' Simon's Playlist
      MLServer.LogMLEvent cStr(MyServer), "CHA4 found through case",0
      MLServer.cmdReceive "MLCmd|ChangeScene~" & Client & "~" & "0019_media.mls"   
      WScript.Sleep(2000)
      MLServer.cmdReceivePush "Zone.CHA4"
   case "CHA5"
      ' Kids playlist
      MLServer.LogMLEvent cStr(MyServer), "CHA5 found through case",0
      MLServer.cmdReceivePush "MLCmd|ChangeScene~" & Client & "~" & "0019_media.mls"   
      WScript.Sleep(2000)
      MLServer.cmdReceivePush "Zone.CHA5"
   case "CHA6"
      ' Internet radio
      MLServer.LogMLEvent cStr(MyServer), "CHA6 found through case",0
      MLServer.cmdReceive "MLCmd|ChangeScene~" & Client & "~" & "0019_media.mls"
      WScript.Sleep(2000)
      MLServer.cmdReceivePush "Zone.CHA6"
   end select
End Sub

MLServer.LogMLEvent "HOMESEER", "Entered Script"
Simon D. S. Mason

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Postby CinemarDave » Sat Jan 03, 2009 9:36 pm

You already have the client name as a local variable. That's good now change your MLServer.cmdReceive command to MLServer.cmdReceiveClient and pass the client name as the second variable. Like MLServer.cmdReceiveClient "MLCycleStates|Next~AudioZones", Client

This should do what you want.

User avatar
simonmason
Expert
Expert
Posts: 855
Joined: Tue Dec 26, 2006 9:06 pm
Contact:

Postby simonmason » Sun Jan 04, 2009 8:30 am

Yes, that worked! Any thoughts on my previously posted issue with the timing of my zone change command for MusicLobby. That is driving me crazy. I can explain again if that helps.
Simon D. S. Mason


Return to “MLScript”

Who is online

Users browsing this forum: No registered users and 1 guest