xScript script help needed.

Xlobby plugin development

xScript script help needed.

Postby scottw on Tue Mar 11, 2008 1:59 am

Ok let me try to get this out...I think it's simple.
I have a variable say variable>something that gets populated with a Genre name and is updated with a button push in XL. I want to have a script read that variable and copy the contents to a new variable say variable>somethinglist that will get appended to. So each time the button gets pushed in XL to populate "variable>something" the script will append to "variable>somethinglist" so I can have a list of Genre's instead of just one at a time.

Does that make sense???

Thanks if anyone can help.
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Re: xScript script help needed.

Postby dalanik on Tue Mar 11, 2008 8:01 am

No problem, I just don't see what you would use it for, but it's pretty easy:

Code: Select all
Module Script

Public Sub Main()
   Dim StrGenre, StrGenreList

   ' *** get genre from xlobby database
   StrGenre = Xlobby.GetXlobbyVar("%movies>genre%")

   ' *** get list variable from xlobby
   StrGenreList = Xlobby.GetXlobbyVar("variable>genrelist")
   ' *** append it to list (I suppose you want space to separate)
   StrGenreList = StrGenreList & " " & StrGenre

   ' *** now, save list to xlobby variable
   Xlobby.SendCommand("xlobby", "save to variable", StrGenreList, "genrelist" )
End Sub

End Module
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Re: xScript script help needed.

Postby scottw on Tue Mar 11, 2008 1:12 pm

Thanks dalanik,

I will try it out in a bit.

I will also post back what I am doing since it's kind of hard to explain...even though I am probably making it more complicated than it is :lol:
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Re: xScript script help needed.

Postby scottw on Tue Mar 11, 2008 2:06 pm

Works great...

One more question: How can I send a carriage return instead of a space in this line???
Code: Select all
' *** append it to list (I suppose you want space to separate)
   StrGenreList = StrGenreList & " " & StrGenre



Thanks
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Re: xScript script help needed.

Postby dalanik on Tue Mar 11, 2008 3:19 pm

CHR(13) ?
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Re: xScript script help needed.

Postby scottw on Tue Mar 11, 2008 5:46 pm

Thanks it appears to be:
ControlChars.CrLf

Found it in tswhites intheaters script.

Seems to be working, I will post later what I was doing.

Thanks alot!!!!
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Re: xScript script help needed.

Postby scottw on Mon Mar 17, 2008 1:05 am

OK here is what I was doing. My wife wanted me to be able to add all songs from the music DB to the playlist and shuffle it, I did this without a problem.....but I wanted more :lol:

I have a few stand-up comedy mp3's that I did not want included so I figured I would list all of the genres with the ability to pick individual genres loading all songs from that genre. I wanted to use a category of filter details so I would not have to type all the genres in manually, so I just do a "Set Filter" on Genre at the page load and it automatically lists all the Genre's from my music DB. The only problem I had was I wanted to be able to see what Genre's were selected already, toggle buttons would do this but I didn't know how to get that to work with a category, so I decided to have them listed in a text box as they were selected using the music>genre variable. The problem with this was to get the textbox to "list" the genre's instead of show one and then replace that one each time another was selected.
This is where the script came into play, thanks a bunch dalanik!!!

The problem I then ran into was it would not work on the thin client, AHHHHHHH

I finally got by that using xReceive/xSend.
I replaced the text box using the xReceive variable: plugin>XReceive>received

Here is the script I used:

Code: Select all
Module Script

Public Sub Main(Source as string)
   Dim StrGenre, StrGenreList

   ' *** get genre from xlobby database
   'StrGenre = Xlobby.GetXlobbyVar("%music>genre%")
'StrGenre = Xlobby.GetXlobbyVar("%variable>testvar%")

   ' *** get list variable from xlobby
   StrGenreList = Xlobby.GetXlobbyVar("variable>genrelist")
   ' *** append it to list (I suppose you want space to separate)
   StrGenreList = StrGenreList & ControlChars.CrLf & Source

   ' *** now, save list to xlobby variable
   Xlobby.SendCommand("xlobby", "save to variable", StrGenreList, "genrelist" )
   Xlobby.SendCommand("xlobby", "run event", "general", "test" )
End Sub

End Module


Each time a category entry is clicked it runs:
Save to Variable
----Information: %music>genre%
----Variable: testvar
Add All
----Category Name: Music
Command
----Plugin: XscriptNG
----Command: ExecScript
----Variables: musicgenres.txt "%music>genre%"
Set Sort Order:
----Category Name: playlist
----Sort Order: shuffle.pos (shuffle.pos is created using the xMusic plugin)

The last event in the script:

Code: Select all
   Xlobby.SendCommand("xlobby", "run event", "general", "test" )


just send the genrelist variable to the server thru xSend which is then displayed on the server and thin client thru the plugin>XReceive>received variable. The cool part about this is the thin client and the server are always in sync with this....we need more of xReceive!!!!

This is just a quick type up of what I did but if anyone needs more info or clearer instructions just let me know.
Here is a screen cap of the Genre Select screen:

Image

This was just whipped up quick as you can tell and is not finished, as you can tell with all of the "test" commands and event groups.
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Re: xScript script help needed.

Postby Marbles_00 on Mon Mar 17, 2008 2:05 am

Scott,

That is pretty cool. Great work. I had to laugh though how "High School Musical" got its own genre :lol: :lol: :lol:
Marbles_00
 
Posts: 1867
Joined: Wed Apr 06, 2005 12:44 pm
Location: Canada

Re: xScript script help needed.

Postby scottw on Mon Mar 17, 2008 12:18 pm

Yeah you know how it is....was easier for my daughter to find "her" music. :lol:
We already have WAF now I guess we need KAF.
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland