Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Dancer control script v4.5.6
- //
- // 11/25 changed the listener from opening and closing to leaving open
- // and just activating and deactivating with llListenControl.
- integer gTouched; //button touched on the hud
- integer gPlayButton; //prim number of play button
- integer gShuffleButton; //prim number of shuffle button.
- integer gInfoButton; //prim number of the info button
- integer gMinButton; //prim number of the minimize button
- string gButtonTouched; //name of what button on the hud was touched
- string gDanceCard; //current dance notecard
- list gDanceList; //list of dances in notecard
- list gTempDanceList; //list of unshuffled dances held for buttle_suffle()
- list gNoteCards; //dance notecards list
- list gDancerKeys; //dancer names and uuid keys on dance slots
- list gDisplayNames; //list of display names from keys
- string tempKey;
- key owner; //owner of hud
- integer gNotecardLine; //Current note card line
- key gNotecardQueryId; //notecard file handle
- integer menuindex; //counter for DialogPlus
- integer gChannel; //DialogPlus channel number
- integer gDanceNum; //current dance number in the list
- string gTimerNum; //current timer number for dance switch
- integer infoFlag; //if info button is set to verbose mode.
- vector gOldLocation; //location on screen before min button is pressed
- // Linked Messages integer commands
- integer FWD =1; //forward 1 dance in the list
- integer PLAY =2; //play the current dance sellected
- integer PAUSE =3; //pause the current dance sellected
- integer RWD =4; //backward 1 dance in the list
- integer SHUFFLE_ON =5; //dance list is random
- integer SHUFFLE_OFF =6; //dance list is sequenced
- integer SYNC =7; //resync the dancers
- integer LOAD =8; // load the list of dances
- integer TIMER =9; // set the timer for the dances
- integer INFO =10; //set the info flag
- integer TIME_CHANGE =11; // time signal to switch to the next dance
- integer ADDKEY =12; //Add DanceKey to dancer list
- integer ADDGOOD =13; //The dance is good to add
- integer ADDREJECT =14; //the dancer has been rejected from being added
- integer DELKEY =15; //delete dancer key from the dancer list
- // Texture for Suffle off
- string SOFF = "bdd61b36-e00d-5c9d-fd5b-34ce15dec1c5";
- // Texture for Suffle on
- string SON = "ad9651e3-ca77-fb09-ca6e-5d30e1321f68";
- // Play Texture for Play button
- string PLAYTXT = "729aee79-5ef0-3baf-eacc-06857889c28b";
- // Pause Texture for Play button
- string PAUSETXT = "8a818aa5-ebdd-fbf2-d239-b2165e92a59e";
- // Left Arrow for minmize button
- string LEFT = "37f2ff4a-cafa-e1fa-69f4-9ddb012dcddf";
- // Right Arrow for minmize button
- string RIGHT = "da33f7fc-db6f-12f6-2297-89b3551abc58";
- integer NOTE_CHANNEL_LISTENER = -900; //Channel for NoteCard listener
- integer DANCE_CHANNEL_LISTENER = -901; //Channel for Dance listener
- integer TIMER_CHANNEL_LISTENER = -902; //Channel for Timer listener
- integer EJECT_CHANNEL_LISTENER = -903; //Channel for master dancer listener
- integer note_handle; //handle for notecard loading listener events
- integer dance_handle; //handle for dance selecting listener events
- integer timer_handle; //handle for dance time dialog listener events
- integer eject_handle; //handler for eject dialog listener events
- //move the hud off to the left with the min or max button is pressed
- min_max()
- {
- list l = llGetLinkPrimitiveParams(gMinButton, [PRIM_TEXTURE,1]);
- if(llList2String(l, 0) == "left arrow")
- {
- gOldLocation = llGetLocalPos();
- // llOwnerSay((string) gOldLocation);
- llSetPos(<gOldLocation.x, 0.0326734, gOldLocation.z>);
- llSetLinkTexture(gMinButton, RIGHT, ALL_SIDES);
- }
- if(llList2String(l, 0) == "right arrow")
- {
- llSetPos(gOldLocation);
- llSetLinkTexture(gMinButton, LEFT, ALL_SIDES);
- }
- //llSetPos(llGetLocalPos() + (<0.0, 0.20, 0 > * llGetLocalRot()));
- }
- //send sync command to the dancers to sync them
- sync()
- {
- list l;
- l = llGetLinkPrimitiveParams(gPlayButton, [PRIM_TEXTURE,1]);
- if(llList2String(l, 0) != "play")
- {
- llMessageLinked(LINK_SET, PAUSE, currDance(),"");
- llSleep(0.2);
- llMessageLinked(LINK_SET, PLAY, currDance(), "");
- }
- }
- //get a list of notecards then load dances from it
- fLoadFromNoteCard()
- {
- integer lNotesNum = llGetInventoryNumber(INVENTORY_NOTECARD);
- //if (llGetListLength(gDanceList) > 0)
- // llMessageLinked(LINK_SET, PAUSE, currDance(), "");
- gNoteCards = [];
- //gDanceList = [];
- gTempDanceList = [];
- gNotecardLine = 0;
- //gDanceNum = 0;
- while (lNotesNum--)
- gNoteCards += llGetInventoryName(INVENTORY_NOTECARD, lNotesNum);
- llListenControl(note_handle, TRUE);
- DialogPlus(owner, "Load Dance Notecard", gNoteCards, NOTE_CHANNEL_LISTENER, menuindex = 0);
- }
- // controls the suffle button texture and sends the command
- // to the dancer scripts to randomize the dance list.
- button_shuffle()
- {
- list l;
- l = llGetLinkPrimitiveParams( gTouched, [PRIM_TEXTURE, 1]);
- if (llList2String(l, 0) == "Shuffle Off")
- {
- llMessageLinked(LINK_SET, PAUSE, currDance(), "");
- llSetLinkTexture(gShuffleButton, SOFF, ALL_SIDES);
- gTempDanceList = gDanceList;
- gDanceList = llListRandomize(gDanceList, 1);
- l = llGetLinkPrimitiveParams(gPlayButton, [PRIM_TEXTURE, 1]);
- if(llList2String(l, 0) != "play")
- llMessageLinked(LINK_SET, PLAY, currDance(), "");
- //llOwnerSay(llList2CSV(gDanceList));
- } else
- {
- llSetLinkTexture(gShuffleButton, SON, ALL_SIDES);
- llMessageLinked(LINK_SET, PAUSE, currDance(), "");
- gDanceList = gTempDanceList;
- l = llGetLinkPrimitiveParams(gPlayButton, [PRIM_TEXTURE, 1]);
- if(llList2String(l, 0) != "play")
- llMessageLinked(LINK_SET, PLAY, currDance(), "");
- //llOwnerSay(llList2CSV(gDanceList));
- }
- }
- /// shuffle dance if shuffle button is on shuffle
- // play if the play button is set to play
- shuffle_and_play()
- {
- list l;
- l = llGetLinkPrimitiveParams( gShuffleButton, [PRIM_TEXTURE, 1]);
- if(llList2String(l, 0) != "Shuffle Off")
- {
- gTempDanceList = gDanceList;
- gDanceList = llListRandomize(gDanceList, 1);
- //llOwnerSay(llList2CSV(gDanceList));
- }
- l = llGetLinkPrimitiveParams(gPlayButton, [PRIM_TEXTURE, 1]);
- //llOwnerSay(llList2String(l, 0));
- if (llList2String(l, 0) != "play")
- llMessageLinked(LINK_SET, PLAY, currDance(), "");
- }
- // step forward one dance in the list
- fwd ()
- {
- list l;
- string tempDance;
- l = llGetLinkPrimitiveParams(gPlayButton, [PRIM_TEXTURE, 1]);
- tempDance = currDance();
- if (llList2String(l, 0)== "play")
- nextDance();
- else
- {
- llMessageLinked(LINK_SET, PLAY, nextDance(), "");
- llMessageLinked(LINK_SET, PAUSE, tempDance, "");
- }
- if(infoFlag == 1)
- llOwnerSay("Now Playing " +currDance()+".");
- }
- // step backward on in the dance list
- rwd()
- {
- list l;
- string tempDance;
- l = llGetLinkPrimitiveParams(gPlayButton, [PRIM_TEXTURE, 1]);
- tempDance = currDance();
- if (llList2String(l, 0)== "play")
- prevDance();
- else
- {
- llMessageLinked(LINK_SET, PLAY, prevDance(), "");
- llMessageLinked(LINK_SET, PAUSE, tempDance, "");
- }
- if(infoFlag == 1)
- llOwnerSay("Now Playing " +currDance()+".");
- }
- // play pause button interaction
- button_play ()
- {
- list l;
- if(llGetListLength(gDanceList) == 0)
- {
- llOwnerSay("No Dances Loaded. Load Dances First.");
- return;
- }
- // if script time is less than 2 seconds play/pause
- if(llGetTime() < 2)
- {
- l = llGetLinkPrimitiveParams( gPlayButton, [PRIM_TEXTURE,1]);
- if (llList2String(l, 0) == "play")
- {
- llSetLinkTexture( gPlayButton, PAUSETXT, ALL_SIDES);
- llMessageLinked(LINK_SET, PLAY, currDance(), "");
- }
- else
- {
- llSetLinkTexture( gPlayButton, PLAYTXT, ALL_SIDES);
- llMessageLinked(LINK_SET, PAUSE, currDance(), "");
- }
- }
- else
- {
- // if script time is < 2 seconds open a dialog with dances in it
- // long touch on the play/pause button
- llListenControl(dance_handle, TRUE);
- DialogPlus(owner, "Select a Dance", gDanceList,
- DANCE_CHANNEL_LISTENER, menuindex = 0);
- }
- }
- //select the next dance in the list
- string nextDance()
- {
- ++gDanceNum;
- if(gDanceNum >= llGetListLength(gDanceList))
- gDanceNum = 0;
- return llList2String(gDanceList, gDanceNum);
- }
- //select the prev dance in the list
- string prevDance()
- {
- --gDanceNum;
- if(gDanceNum < 0)
- gDanceNum = llGetListLength(gDanceList) - 1;
- return llList2String(gDanceList, gDanceNum);
- }
- show_dancer_list()
- {
- list l;
- integer i;
- llOwnerSay(llList2CSV(gDancerKeys));
- llOwnerSay("/*******************************************************/");
- for(i = 0; i < llGetListLength(gDancerKeys); i += 2)
- {
- llOwnerSay(llList2CSV(llList2List(gDancerKeys, i, (i+1))));
- }
- llOwnerSay("/*******************************************************/");
- gDisplayNames = llList2ListStrided(gDancerKeys, 0, -1, 1);
- llOwnerSay("display names: " +llList2CSV(gDisplayNames));
- return;
- }
- // play single selected dance only
- play_single(string selected)
- {
- string tempDance;
- if(infoFlag == 1)
- llOwnerSay("Single Dance Mode, playing " +selected+ ".");
- llMessageLinked(LINK_SET, TIMER, "None", "");
- tempDance = currDance();
- gDanceNum = llListFindList(gDanceList, (list) selected);
- llMessageLinked(LINK_SET, PLAY, selected, "");
- llMessageLinked(LINK_SET, PAUSE, tempDance, "");
- llSetLinkTexture( gPlayButton, PAUSETXT, ALL_SIDES);
- }
- //return the current dance in the list
- string currDance()
- {
- return llList2String(gDanceList, gDanceNum);
- }
- //function to display info
- info()
- {
- if(llGetTime() > 2)
- {
- if (infoFlag == 0)
- {
- llOwnerSay("Verbose mode is now on.");
- infoFlag = 1;
- return;
- }
- else if(infoFlag == 1)
- {
- llOwnerSay("Verbose mode is now off.");
- infoFlag = 0;
- return;
- }
- }
- if(gTimerNum == "" || gTimerNum == "None")
- llOwnerSay("Timer is not set.");
- else
- llOwnerSay("Timer is set to " +gTimerNum+ " seconds.");
- llOwnerSay("Now Playing: " + currDance());
- }
- //Created by Ugleh Ulrik
- //This sort
- //Edited by Taff Nouvelle to put the buttons in correct order.
- list order_buttons(list buttons)
- {
- return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) +
- llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);
- }
- DialogPlus(key avatar, string message, list buttons, integer gChannel, integer CurMenu)
- {
- llSetTimerEvent(30);
- if (12 < llGetListLength(buttons))
- {
- list lbut = buttons;
- list Nbuttons = [];
- if(CurMenu == -1)
- {
- CurMenu = 0;
- menuindex = 0;
- }
- if((Nbuttons = (llList2List(buttons, (CurMenu * 10), ((CurMenu * 10) + 9)) + ["Back", "Next"])) == ["Back", "Next"])
- DialogPlus(avatar, message, lbut, gChannel, menuindex = 0);
- else
- llDialog(avatar, message, order_buttons(Nbuttons), gChannel);
- }
- else
- llDialog(avatar, message, order_buttons(buttons), gChannel);
- }
- //return the number of the prim named
- integer getPrimNum (string button)
- {
- integer nPrims = llGetNumberOfPrims();
- integer i;
- for( i = 0; i < nPrims; ++i)
- {
- string pName = llGetLinkName(i);
- if (pName == button)
- return i;
- }
- return 0;
- }
- //look for key in dancerlist, add or reject if its in the list
- integer check_and_addkey(string ikey)
- {
- if(llGetListLength(gDancerKeys) == 0)
- {
- gDancerKeys += ikey;
- gDancerKeys += llGetDisplayName(ikey);
- return 1;
- }
- if(llListFindList(gDancerKeys, (list) ikey) != -1)
- return 0;
- else
- {
- gDancerKeys += ikey;
- gDancerKeys += llGetDisplayName(ikey);
- return 1;
- }
- }
- //delete a key from the gDancerKeys list
- delete_key(string ikey)
- {
- integer key_location = llListFindList(gDancerKeys, (list) ikey);
- gDancerKeys = llDeleteSubList(gDancerKeys, key_location, (key_location+1));
- }
- default
- {
- state_entry()
- {
- gPlayButton = getPrimNum("Play");
- gShuffleButton = getPrimNum("Shuffle");
- gInfoButton = getPrimNum("info");
- gMinButton = getPrimNum("min");
- infoFlag = 0;
- llSetLinkTexture( gPlayButton, PLAYTXT, ALL_SIDES);
- llSetLinkTexture( gShuffleButton, SON, ALL_SIDES);
- llSetLinkTexture( gMinButton, LEFT, ALL_SIDES);
- owner = llGetOwner();
- gDanceNum = 0;
- gDancerKeys = [];
- note_handle = llListen(NOTE_CHANNEL_LISTENER, "", owner, "");
- dance_handle = llListen(DANCE_CHANNEL_LISTENER, "", owner, "");
- timer_handle = llListen(TIMER_CHANNEL_LISTENER, "", owner, "");
- eject_handle = llListen(EJECT_CHANNEL_LISTENER, "", owner, "");
- llListenControl(note_handle, FALSE);
- llListenControl(dance_handle, FALSE);
- llListenControl(timer_handle, FALSE);
- llListenControl(eject_handle, FALSE);
- }
- changed(integer change)
- {
- if (change & CHANGED_OWNER)
- {
- llResetScript();
- owner = llGetOwner();
- }
- }
- // We need a listen for the dialog itself, but as well as the Back/Next bbutton.
- listen(integer channel, string name, key id, string message)
- {
- string msg;
- list dialogList;
- //handle listen event for timer button
- if(channel == TIMER_CHANNEL_LISTENER)
- {
- llMessageLinked(LINK_SET, TIMER, message, "");
- llSetTimerEvent(0);
- llListenControl(timer_handle, FALSE);
- sync();
- gTimerNum = message;
- return;
- }
- //set list and message for dialog box for loading notecards
- if(channel == NOTE_CHANNEL_LISTENER)
- {
- msg = "Load Dance Notecard";
- dialogList = gNoteCards;
- }
- //set list and message for dialog box for loading dances
- if(channel == DANCE_CHANNEL_LISTENER)
- {
- msg = "Select a Dance";
- dialogList = gDanceList;
- }
- if(channel == EJECT_CHANNEL_LISTENER)
- {
- msg = "Select Dancer to Eject";
- dialogList = gDisplayNames;
- }
- if(message == "Next")
- DialogPlus(owner, msg, dialogList, channel, ++menuindex);
- else if(message == "Back")
- DialogPlus(owner, msg, dialogList, channel, --menuindex);
- else
- {
- //llOwnerSay(message);
- llSetTimerEvent(0);
- // load notecard to list
- if(channel == NOTE_CHANNEL_LISTENER)
- {
- llListenControl(note_handle, FALSE);
- gDanceCard = message;
- gNotecardQueryId = llGetNotecardLine(gDanceCard, gNotecardLine);
- }
- //select a dance
- if(channel == DANCE_CHANNEL_LISTENER)
- {
- llListenControl(dance_handle, FALSE);
- play_single(message);
- }
- // Eject a dancer from the hud
- if(channel == EJECT_CHANNEL_LISTENER)
- {
- llListenControl(eject_handle, FALSE);
- tempKey = llList2String(gDancerKeys,
- llListFindList(gDisplayNames,
- (list) message));
- llSay(0, "tempKey: "+ tempKey);
- }
- }
- }
- touch_start(integer start_number)
- {
- llResetTime();
- }
- touch_end(integer total_number)
- {
- gTouched = llDetectedLinkNumber(0);
- list l = llGetLinkPrimitiveParams( gTouched, [PRIM_NAME]);
- llOwnerSay("Number: " +(string) gTouched+ " Name: "+ llList2String(l, 0));
- gButtonTouched = llList2String(l, 0);
- if (gButtonTouched == "FWD")
- fwd();
- else if (gButtonTouched == "RWD")
- rwd();
- else if (gButtonTouched == "Shuffle")
- button_shuffle();
- else if (gButtonTouched == "Play")
- button_play();
- else if (gButtonTouched == "Load")
- fLoadFromNoteCard();
- else if (gButtonTouched == "Timer")
- {
- list dTime = ["None", "15", "30", "60", "90", "120"];
- llListenControl(timer_handle, TRUE);
- llDialog(owner, "Set Dance Time", dTime, TIMER_CHANNEL_LISTENER);
- } else if (gButtonTouched == "min")
- min_max();
- else if (gButtonTouched == "Sync")
- sync();
- else if (gButtonTouched == "info")
- info();
- else
- {
- // if (llGetSubString(gButtonTouched, 0, 5) == "Dancer"
- if (llGetTime() > 2)
- {
- llOwnerSay("Dancer Button Touched");
- show_dancer_list();
- }
- }
- }
- dataserver (key query_id, string data)
- {
- if (query_id == gNotecardQueryId)
- if(data == EOF)
- {
- llOwnerSay("Loaded " +(string) llGetListLength(gTempDanceList)+ " dances from " +gDanceCard+ " notecard.");
- if(llGetListLength(gDanceList) > 0)
- llMessageLinked(LINK_SET, PAUSE, currDance(), "");
- gDanceList = gTempDanceList;
- gDanceNum = 0;
- shuffle_and_play();
- }
- else
- {
- gNotecardQueryId = llGetNotecardLine(gDanceCard, ++gNotecardLine);
- if (llStringLength(data) != 0)
- gTempDanceList += data;
- }
- }
- // timer for dialog menu.
- timer()
- {
- llOwnerSay("Dialog Menu timed out.");
- llListenControl(timer_handle, FALSE);
- llListenControl(dance_handle, FALSE);
- llListenControl(note_handle, FALSE);
- llSetTimerEvent(0);
- }
- // incoming timer event for timed dances.
- link_message(integer sender_num, integer num, string str, key id)
- {
- list l;
- l = llGetLinkPrimitiveParams(gPlayButton, [PRIM_TEXTURE,1]);
- if(num == TIME_CHANGE)
- {
- if(llList2String(l, 0) != "play")
- fwd();
- }
- if(num == ADDKEY)
- {
- if(check_and_addkey(str) == 1)
- {
- llOwnerSay(llList2CSV(gDancerKeys));
- llMessageLinked(LINK_SET, ADDGOOD, str, "");
- if(llList2String(l, 0) != "play")
- {
- llSleep(5.0);
- sync();
- }
- }
- else
- {
- llMessageLinked(LINK_SET, ADDREJECT, str, "");
- }
- }
- if(num == DELKEY)
- delete_key(str);
- if(num == SYNC)
- {
- llSleep(5);
- sync();
- }
- }
- on_rez(integer start_param)
- {
- gDancerKeys = [];
- }
- }
Add Comment
Please, Sign In to add comment