• Announcements

    • Xiola Linden

      The New Community Platform   03/21/2017

      We are still working on making adjustments and changes to the new platform. Thanks  to everyone who has been sending in feedback and filing any bugs you've encountered! 

sunandfun

Resident
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About sunandfun

  • Rank
    Newbie
  1. ty very much Innula Actually i solved adding a ShowCmdDlg(); after the 1421 (Menu anim) condition in 3rd script and is workin fine Wanted to inform earlier but my account was locked Tks again
  2. ~TouchMaster v5.0 integer gnTouchState;key gkToucher;default{ state_entry() { gnTouchState = 0; } touch_start(integer num_detected) { if (gnTouchState == 1) { gnTouchState = 2; llSetTimerEvent(0.0); llMessageLinked(LINK_THIS, 1402, "", llDetectedKey(0)); } } touch_end(integer num_detected) { if (gnTouchState == 0) { gnTouchState = 1; gkToucher = llDetectedKey(0); llSetTimerEvent(0.6); } else gnTouchState = 0; } timer() { if (gnTouchState == 1) { gnTouchState = 0; llSetTimerEvent(0); llMessageLinked(LINK_THIS, 1401, "", gkToucher); } } on_rez(integer start_param) { llResetScript(); }} BedMaster v5.0 //------------------------------------------------------------------------//// Link Msgs// =========// 1 + nBall Start Anim// 11 + nBall Stop Anim// 21 + nBall Sitter// 31 + nBall Face anim// 201 Faster// 202 Slower// 301 Anim data req// 302 Anim list req// 303 - 349 Anim list// 400 - 407 Anim Data response// 411 - 412 BallPos Override// 418 Anim Data End Override// 419 Anim Data End// 503 SavePos cmd// 504 Send cmd// 510 + nBall BallPos Scanned// 701 Texture cmd// 801 Channel used// 802 Base Pos/Rot// 810 Dataslave Number// 811 Menu Plugin// 812 Other Plugin// 901 Anims read// 1101 (touched)// 1102 *Move* cmd// 1103 *Swap* cmd// 1104 -None- cmd// 1105 *EndMove* cmd// 1201 !Cyber// 1202 Block Facials// 1203 Allow Facials// 1204 Taken over// 1205 Balls in use// 1401 Touched// 1402 Double click// 1420 Menu cat/grp// 1421 Menu anim// 1422 No Menu// 1423 Menu ready// 1601 ?// 1700 - 1739 DataStore Start// 9002 Email address//// Channels:// 989 Sitter/Anim info// 10*key + 1000 Maintenance dialog// 10*key + 1001 Menu dialog// 10*key + 1002 Cyber dialog// 10*key + 1003 ToBall// 10*key + 1004 FromBall// 10*key + 1005 HUD/Attachment talk// 10*key + 1006 Rezzed Toys talk////------------------------------------------------------------------------integer gnChnDialog;integer gnChnToBall;integer gnChnFromBall;integer gnCmdDiaOffset;integer gnListen1;integer gnListen2;integer gnMaxBalls = 4;list glsBallNames = [ "~~Pink Ball", "~~Blue Ball", "~~Green Ball", "~~Yellow Ball" ];integer gabOccupied;integer gnOccupied;integer gnMaxDataStore;integer gnCountBall;integer gnSpeeds;integer gnMenuSpace;integer gnBallOffset;integer gnCurrSpeed;integer gnCurrCountBall;vector gvOffset;vector gvBasePos;rotation gvBaseRot;vector gvLocBasePos;rotation gvLocBaseRot;list glvCurrPos;list glrCurrRot;integer gbIsDemo;integer gbMoving;integer gnMoveBall;integer gbHasCyber;integer gbHasMemory;integer gbFacialBlocked;integer gbPosOverridden;integer gbRotOverridden;integer gbOvertaken;key gkToucher;integer gnTouchState;integer gnDiaMode;integer DIA_MODE_SYS = 1;integer DIA_MODE_MOVEBALL = 2;// Anim Datainteger gnCmdCnt;list glvCmd_Ball_Pos;list glrCmd_Ball_Rot;list glsCmd_Ball_Pose;list glsCmd_Ball_Anim;list glnCmd_Ball_NFace;list glnCmd_Ball_ixFace;list glsCmd_Ball_Face;list glnCmd_Ball_FacePct;integer KeyToNum(string sKey){ // i.e. f80d8877-8b9e-d96c-0ec1-7fe7640f4f36 return (integer)("0x" + llGetSubString(sKey, -4, -1));}ActivateNew(){ vector vBase; rotation rBase; vector vCurrPos; vector vNewPos; rotation rNewRot; string sNewAnim; gnCurrSpeed = 0; llSetTimerEvent(0.0);//llOwnerSay("New anim balls " + (string)gnCurrCountBall + "=>" + (string)gnCountBall + ", overtaken=" + (string)gbOvertaken); llMessageLinked(LINK_ALL_OTHERS, 1204, (string)gnCountBall, NULL_KEY); vBase = gvBasePos; rBase = gvBaseRot; if (vBase == ZERO_VECTOR) { vBase = llGetRootPosition(); rBase = llGetRootRotation(); } integer nBall; for (nBall = gnCountBall; nBall < gnCurrCountBall; ++nBall) { llMessageLinked(LINK_THIS, 11 + nBall, "", NULL_KEY); // stop anim llMessageLinked(LINK_THIS, 21 + nBall, "", NULL_KEY); // no sitter llSay(gnChnToBall, "Ball" + (string)(nBall + 1) + "|Derez"); SetOccupied(nBall + 1, 0); } for (nBall = 0; nBall < gnCountBall; ++nBall) { integer nBallIndex = (nBall + gnBallOffset) % gnCountBall; vCurrPos = llList2Vector(glvCurrPos, nBall); vNewPos = llList2Vector(glvCmd_Ball_Pos, nBallIndex) + gvOffset; if (vNewPos == gvOffset) vNewPos = <0.0, 0.0, 1.5>; // should not happen rNewRot = llList2Rot(glrCmd_Ball_Rot, nBallIndex); if (nBall >= gnCurrCountBall) // not rezzed { llRezObject(llList2String(glsBallNames, nBall), llGetPos() + <0.0, 0.0, 1.0>, ZERO_VECTOR, ZERO_ROTATION, gnChnToBall); llSleep(0.5); } rotation rCurrRot = llList2Rot(glrCurrRot, nBall);//llOwnerSay("channel" + (string)gnChnToBall + ": Ball" + (String)(nBall + 1) + "|Pos|" + (string)(vBase + vNewPos * rBase) + "|" + (string)(rNewRot * rBase)); llWhisper(gnChnToBall, "Ball" + (string)(nBall + 1) + "|Pos|" + (string)(vBase + vNewPos * rBase) + "|" + (string)(rNewRot * rBase)); glvCurrPos = llListReplaceList(glvCurrPos, [ vNewPos ], nBall, nBall); glrCurrRot = llListReplaceList(glrCurrRot, [ rNewRot ], nBall, nBall); string sPose = llList2String(glsCmd_Ball_Pose, nBallIndex); if ((gnOccupied < 2) && (sPose != "")) { sNewAnim = sPose; } else { sNewAnim = llList2String(glsCmd_Ball_Anim, nBallIndex * gnSpeeds); if (llList2Integer(glnCmd_Ball_NFace, nBallIndex) > 0) llSetTimerEvent(2.0); } llMessageLinked(LINK_THIS, nBall+1, sNewAnim, NULL_KEY);//llWhisper(0, "Ball " + (string)(nBall + 1) + ": anim " + sNewAnim); } llMessageLinked(LINK_SET, 1205, (string)gnOccupied, NULL_KEY); gbOvertaken = FALSE; gnCurrCountBall = gnCountBall;}integer HasInv(integer nType, string sName){ integer L = llStringLength(sName) - 1; integer N = llGetInventoryNumber(nType); integer i; for (i=0; i<N; ++i) if (llGetSubString(llGetInventoryName(nType, i), 0, L) == sName) return TRUE; return FALSE;}SetOccupied(integer nIndex, integer nValue){ if (nValue > 0) gabOccupied = gabOccupied | (1 << nIndex); else gabOccupied = gabOccupied & ~(1 << nIndex); gnOccupied = 0; integer i; for (i=0; i<8; ++i) { if (gabOccupied & (1 << i)) ++gnOccupied; } llMessageLinked(LINK_SET, 1205, (string)gnOccupied, NULL_KEY);//llWhisper(0, "Occupied map=" + (string)gabOccupied + ", count=" + (string)gnOccupied);}ShowMaintainDlg(){ gnListen2 = llListen(gnChnDialog, "", gkToucher, ""); gnDiaMode = DIA_MODE_SYS; list lsOptions = [ "Save", "AutoOn", "AutoOff", "Send" ]; string sText = "Maintenance Menu\n\nSave=Save Ballpositions\nAutoOn=Set autohide on\nAutoOff=Set autohide off\nSend=Send Positions"; if (HasInv(INVENTORY_SCRIPT, "~TexMaster")) { sText += "\nTexture = Select cover texture"; lsOptions += [ "Texture" ]; } llDialog(gkToucher, sText, lsOptions, gnChnDialog);}ShowCmdDlg(){ gbPosOverridden = FALSE; gbRotOverridden = FALSE; llMessageLinked(LINK_THIS, 1101, (string)gnCurrCountBall + " " + (string)gbMoving, gkToucher); // show menu // return; qui non va Nik }StartBallMove(){ list lsOptions = []; integer i; gkToucher = llGetOwner(); for (i=0; i<gnCurrCountBall; ++i) lsOptions += [ llGetSubString(llList2String(glsBallNames, i), 2, -1) ]; if (gnListen2 == 0) gnListen2 = llListen(gnChnDialog, "", gkToucher, ""); gnDiaMode = DIA_MODE_MOVEBALL; llDialog(gkToucher, "Select a ball", lsOptions, gnChnDialog);}default{ state_entry() { llSay(0, "Reading configuration, please wait for the ready message"); gbIsDemo = (llGetSubString(llGetScriptName(), -5, -1) == " Demo"); gbMoving = FALSE; gbFacialBlocked = FALSE; gbOvertaken = FALSE; gnCurrSpeed = 0; gnCurrCountBall = 0; gnCmdDiaOffset = 0; gvBasePos = ZERO_VECTOR; gvBaseRot = ZERO_ROTATION; gvLocBasePos = ZERO_VECTOR; gvLocBaseRot = ZERO_ROTATION; gvOffset = (vector)llGetObjectDesc(); glvCurrPos = []; glrCurrRot = []; gnTouchState = 0; gabOccupied = 0; gnCmdCnt = 0; llSetRemoteScriptAccessPin(5783201); key kRoot = llGetLinkKey(LINK_ROOT); if (llGetNumberOfPrims() == 1) kRoot = llGetKey(); gnChnDialog = 10 * KeyToNum(kRoot) + 1000; gnChnToBall = gnChnDialog + 3;//llOwnerSay("listening on channel " + (string)gnChnToBall);// gnChnToBall = 30000 + llFloor(llFrand(10000)); gnChnFromBall = gnChnDialog + 4; gnListen1 = llListen(gnChnFromBall, "", NULL_KEY, ""); gbHasCyber = HasInv(INVENTORY_SCRIPT, "~CyberMaster"); gbHasMemory = HasInv(INVENTORY_SCRIPT, "~MemoryMaster"); llMessageLinked(LINK_SET, 801, (string)gnChnDialog, NULL_KEY); llSay(gnChnToBall, "Ball1|Derez"); llSay(gnChnToBall, "Ball2|Derez"); llSay(gnChnToBall, "Ball3|Derez"); llSay(gnChnToBall, "Ball4|Derez"); gnMaxDataStore = -1; integer nNoteCount = llGetInventoryNumber(INVENTORY_NOTECARD); integer i; for (i=0; i<nNoteCount; ++i) { string sName = llGetInventoryName(INVENTORY_NOTECARD, i); if (llGetSubString(sName, 0, 6) == "!Config") { ++gnMaxDataStore; string sScript = "~DataStore v5.0"; if (gnMaxDataStore > 0) sScript += " " + (string)gnMaxDataStore; llSetScriptState(sScript, TRUE); llMessageLinked(LINK_THIS, 1700 + gnMaxDataStore, sName, NULL_KEY); } } for (i=gnMaxDataStore+1; i<40; ++i) { llSetScriptState("~DataStore v5.0 " + (string)i, FALSE); } llMessageLinked(LINK_SET, 302, "0", (key)"0"); } timer() { if (gbFacialBlocked) return; integer nBall; for (nBall = 0; nBall < gnCountBall; ++nBall) { integer nBallIndex = (nBall + gnBallOffset) % gnCountBall; integer nF = llList2Integer(glnCmd_Ball_NFace, nBallIndex); integer ixF = llList2Integer(glnCmd_Ball_ixFace, nBallIndex); integer nPct = (integer) llFrand(100.0); integer iF; for (iF=0; iF<nF; ++iF) { nPct -= llList2Integer(glnCmd_Ball_FacePct, ixF + iF); if (nPct <= 0) { string sFace = llList2String(glsCmd_Ball_Face, ixF + iF); llMessageLinked(LINK_THIS, 31 + nBall, sFace, NULL_KEY); iF = 999; } } } } listen (integer channel, string name, key id, string message) {//llOwnerSay("Heard " + message); if ((channel == gnChnDialog) && (id == gkToucher)) { if (gnDiaMode == DIA_MODE_SYS) { llListenRemove(gnListen2); gnListen2 = 0; if (message == "Send") { llMessageLinked(LINK_THIS, 504, "", NULL_KEY); } else if (message == "Save") { llSensor("", NULL_KEY, SCRIPTED, 8.0, 2 * PI); } else if (message == "AutoOn") { integer i; for (i=0; i<gnCurrCountBall; ++i) { llWhisper(gnChnToBall, "Ball" + (string)(i + 1) + "|Auto|On"); } } else if (message == "AutoOff") { integer i; for (i=0; i<gnCurrCountBall; ++i) { llWhisper(gnChnToBall, "Ball" + (string)(i + 1) + "|Auto|Off"); } } else if (message == "Texture") { llMessageLinked(LINK_THIS, 701, "", NULL_KEY); } } else if (gnDiaMode == DIA_MODE_MOVEBALL) { llListenRemove(gnListen2); gnListen2 = 0; integer i; for (i=0; i<gnCurrCountBall; ++i) { if (message == llGetSubString(llList2String(glsBallNames, i), 2, -1)) { gbMoving = TRUE; gnMoveBall = i; llWhisper(gnChnToBall, "Ball" + (string)(gnMoveBall + 1) + "|Move"); } } } } else // message from ball or rug { //Ball1|Sit|b85e0cdf-4fb2-4383-8b0f-7ff15d01c427 if (llGetSubString(message, 0, 3) == "Ball") { integer n = (integer)llGetSubString(message, 4, 4); if (n > gnCurrCountBall) return; if (llGetSubString(message, 5, 9) == "|Sit|") { key kNew = (key)llGetSubString(message, 10, -1); if (kNew != NULL_KEY) {//llSay(0, "glnCmd_Ball_ixAnim=" + llList2CSV(glnCmd_Ball_ixAnim));//llSay(0, "glnCmd_Ball_NPose=" + llList2CSV(glnCmd_Ball_NPose));//llSay(0, "glnCmd_Ball_ixPose=" + llList2CSV(glnCmd_Ball_ixPose));//llSay(0, "glsCmd_Ball_Pose=" + llList2CSV(glsCmd_Ball_Pose));//llSay(0, "glsCmd_Ball_Anim=" + llList2CSV(glsCmd_Ball_Anim)); SetOccupied(n, 1); llMessageLinked(LINK_THIS, 20 + n, "", kNew); if (gbOvertaken) return; string sNewAnim; string sPose = llList2String(glsCmd_Ball_Pose, n - 1); if ((gnOccupied < 2) && (sPose != "")) { sNewAnim = sPose; llSetTimerEvent(0.0); } else { integer nBallIndex = (n - 1 + gnBallOffset) % gnCurrCountBall; sNewAnim = llList2String(glsCmd_Ball_Anim, nBallIndex * gnSpeeds + gnCurrSpeed); if (llList2Integer(glnCmd_Ball_NFace, n - 1) > 0) llSetTimerEvent(2.0); }//llWhisper(0, "Sit ball " + (string)n + ": anim " + sNewAnim); llMessageLinked(LINK_THIS, n, sNewAnim, NULL_KEY); if (gnOccupied == 2) { integer i; for (i=1; i<=gnCurrCountBall; ++i) { if ((i != n) && ((gabOccupied & (1 << i)) != 0)) { if (llList2String(glsCmd_Ball_Pose, i - 1) != "") { integer nBallIndex = (i - 1 + gnBallOffset) % gnCurrCountBall; sNewAnim = llList2String(glsCmd_Ball_Anim, nBallIndex * gnSpeeds + gnCurrSpeed); llMessageLinked(LINK_THIS, i, sNewAnim, NULL_KEY);//llWhisper(0, "Sit other ball " + (string)i + ": anim " + sNewAnim); } } } } } else { SetOccupied(n, 0); llMessageLinked(LINK_THIS, 10 + n, "", NULL_KEY); llMessageLinked(LINK_THIS, 20 + n, "", NULL_KEY); if ((gnOccupied == 1) && (!gbOvertaken)) { integer i; for (i=1; i<=gnCurrCountBall; ++i) { if ((gabOccupied & (1 << i)) != 0) { string sNewAnim = llList2String(glsCmd_Ball_Pose, i - 1); if (sNewAnim != "") llMessageLinked(LINK_THIS, i, sNewAnim, NULL_KEY); } } } } } } else if (llGetSubString(message, 0, 5) == "Remote") { list lsMsg = llParseStringKeepNulls(message, [ "|" ], []); if (llList2String(lsMsg, 1) == "Click") { gvBasePos = (vector)llList2String(lsMsg, 3); gvBaseRot = (rotation)llList2String(lsMsg, 4);//llOwnerSay("gvBasePos=" + (string)gvBasePos);// if (gnCurrCountBall > 0) ActivateNew(); llMessageLinked(LINK_SET, 1401, "", (key)llList2String(lsMsg, 2)); } else if (llList2String(lsMsg, 1) == "Dclick") { llMessageLinked(LINK_SET, 1402, "", (key)llList2String(lsMsg, 2)); } else if (llList2String(lsMsg, 1) == "Pos") { gvLocBasePos = (vector)llList2String(lsMsg, 2); gvBasePos = gvLocBasePos; gvLocBaseRot = (rotation)llList2String(lsMsg, 3); gvBaseRot = gvLocBaseRot; llMessageLinked(LINK_SET, 802, llList2String(lsMsg, 2), (key)llList2String(lsMsg, 3)); if (gnCurrCountBall > 0) ActivateNew(); } } } } touch_start(integer num_detected) { gvBasePos = gvLocBasePos; gvBaseRot = gvLocBaseRot; } link_message(integer sender_num, integer num, string str, key id) {//llWhisper(0, "Master got LinkMsg " + (string)num + ": " + str);// llSleep(0.1); if (num < 400) { if ((num == 201) || (num == 202)) { if (num == 201) { if (gnCurrSpeed < gnSpeeds - 1) ++gnCurrSpeed; } else { if (gnCurrSpeed > 0) --gnCurrSpeed; } integer i; for (i=0; i<gnCurrCountBall; ++i) { integer nBallIndex = (i + gnBallOffset) % gnCurrCountBall; string sNewAnim = llList2String(glsCmd_Ball_Anim, nBallIndex * gnSpeeds + gnCurrSpeed); llMessageLinked(LINK_THIS, i + 1, sNewAnim, NULL_KEY);//llWhisper(0, "Speed change (" + (string)gnCurrSpeed + ") ball " + (string)i + ": ixball=" + (string)gnIndexBall + ",anim " + sNewAnim); } } else if ((num >= 303) && (num <= 349)) { list lsCmd = llParseString2List(str, [ "~" ], []); gnCmdCnt += llGetListLength(lsCmd); integer nNext = num - 302;// llSay(0, "Updatepack animations loaded"); if (nNext <= gnMaxDataStore) llMessageLinked(LINK_SET, 302, (string)nNext, (key)((string)gnCmdCnt)); else llMessageLinked(LINK_THIS, 901, (string)gnCmdCnt, NULL_KEY); } } else if (num < 1000) { if (num == 400) { list lData = llParseString2List(str, [ "," ], []); gnCountBall = llList2Integer(lData, 0); gnSpeeds = llList2Integer(lData, 1); } else if ((num == 401) || (num == 411)) { if ((num == 401) && (gbPosOverridden)) return; if (num == 411) gbPosOverridden = TRUE; glvCmd_Ball_Pos = []; list lsNew = llParseString2List(str, [ "~" ], []); integer i; for (i=0; i<llGetListLength(lsNew); ++i) glvCmd_Ball_Pos += [ (vector)llList2String(lsNew, i) ]; } else if ((num == 402) || (num == 412)) { if ((num == 402) && (gbRotOverridden)) return; if (num == 412) gbRotOverridden = TRUE; glrCmd_Ball_Rot = []; list lsNew = llParseString2List(str, [ "~" ], []); integer i; for (i=0; i<llGetListLength(lsNew); ++i) glrCmd_Ball_Rot += [ (rotation)llList2String(lsNew, i) ]; } else if (num == 403) { glsCmd_Ball_Pose = llParseString2List(str, [ "~" ], []); } else if (num == 404) { glsCmd_Ball_Anim = llParseString2List(str, [ "~" ], []); } else if (num == 405) { glnCmd_Ball_NFace = llParseString2List(str, [ "~" ], []); glnCmd_Ball_ixFace = [ ]; integer nCnt = 0; integer nMax = llGetListLength(glnCmd_Ball_NFace); integer i; for (i=0; i<nMax; ++i) { glnCmd_Ball_ixFace += [ nCnt ]; nCnt += llList2Integer(glnCmd_Ball_NFace, i); } } else if (num == 406) { glsCmd_Ball_Face = llParseString2List(str, [ "~" ], []); } else if (num == 407) { glnCmd_Ball_FacePct = llParseString2List(str, [ "~" ], []); } else if ((num == 418) || ((num == 419) && (!gbHasMemory))) { gnBallOffset = 0; ActivateNew(); }// else if (num == 810)// {// integer n = (integer)str;// if (n > gnMaxDataStore) gnMaxDataStore = n;// } } else { if (num == 1102) // *Move* { StartBallMove(); } else if (num == 1103) // *Swap* { ++gnBallOffset; ActivateNew(); } else if (num == 1104) // -None- { llMessageLinked(LINK_THIS, 301, "9999", NULL_KEY); gnCountBall = 0; ActivateNew(); } else if (num == 1105) // *EndMove* { gbMoving = FALSE; llWhisper(gnChnToBall, "Ball" + (string)(gnMoveBall + 1) + "|EndMove"); llSensor("", NULL_KEY, SCRIPTED, 8.0, 2 * PI); } else if (num == 1202) // No Facials { gbFacialBlocked = TRUE; } else if (num == 1203) // Allow Facials { gbFacialBlocked = FALSE; } else if (num == 1204) // Taken over { if (!gbOvertaken) { integer nBall; for (nBall = 0; nBall < gnCurrCountBall; ++nBall) { llMessageLinked(LINK_THIS, 11 + nBall, "", NULL_KEY); // stop anim } gbOvertaken = TRUE; } gnCurrCountBall = (integer)str; } else if (num == 1402) // maintenance menu { if ((gbIsDemo) || (id == llGetOwner())) { gkToucher = id; ShowMaintainDlg(); } } } } sensor(integer total_number) {// integer nIndexBall = llList2Integer(glnCmd_Ball_ixBall, gnCmd); integer i; list lfDist = []; list lvPos = []; list lrRot = []; for (i=0; i<gnMaxBalls; ++i) { lfDist += [ 9.9 ]; lvPos += [ ZERO_VECTOR ]; lrRot += [ ZERO_ROTATION ]; } for (i=0; i<total_number; ++i) { string sName = llDetectedName(i); integer n = llListFindList(glsBallNames, [ sName ]); if (n >= 0) { vector vTgt = (llDetectedPos(i) - llGetPos() - gvOffset) / llGetRot(); rotation rTgt = llDetectedRot(i) / llGetRot(); float fDist = llVecMag(vTgt); if (fDist < llList2Float(lfDist, n)) { lfDist = llListReplaceList(lfDist, [ fDist ], n, n); lvPos = llListReplaceList(lvPos, [ vTgt ], n, n); lrRot = llListReplaceList(lrRot, [ rTgt ], n, n); } } } for (i=0; i<gnCurrCountBall; ++i) { if (llList2Float(lfDist, i) < 9.0) { llMessageLinked(LINK_THIS, 510+i, (string)llList2Vector(lvPos, i), (key)((string)llList2Rot(lrRot, i))); } }// llMessageLinked(LINK_THIS, 503, "", NULL_KEY); } on_rez(integer start_param) { llResetScript(); }} ~MenuMaster v5.01 integer gnChnDialog;integer gnHUDChannel;integer gnTouchNum;integer gnState;integer STATE_INIT = 0;integer STATE_RUN = 1;integer gbIs2Go;key gkToucher;list glCatGrpAnim;string gsCurrCat;integer gnCatIndex;integer gnGrpIndex;integer gnAnimIndex;integer gbErrorReported;integer gnCurrAnim;string gsCurrAnim;integer gnCurrLvl;integer gnTopLvl;integer gbHasLvl1;integer gnCmdDiaOffset;integer gnCurrCountBall;integer gbMoving;integer gnListen2;integer gnMenuSpace;list glsPlugins;list glnPluginLink;list glsOptions;integer HasInv(integer nType, string sName){ integer L = llStringLength(sName) - 1; integer N = llGetInventoryNumber(nType); integer i; for (i=0; i<N; ++i) if (llGetSubString(llGetInventoryName(nType, i), 0, L) == sName) return TRUE; return FALSE;}Increment(integer n){ glCatGrpAnim = llListReplaceList(glCatGrpAnim, [ llList2Integer(glCatGrpAnim, n) + 1 ], n, n);}integer GetCatSize(integer nCatIndex){ return (2 * llList2Integer(glCatGrpAnim, nCatIndex + 1) + llList2Integer(glCatGrpAnim, nCatIndex + 2) + 3);// integer n = nCatIndex + 3;// integer nGrp = llList2Integer(glCatGrpAnim, nCatIndex + 1);// integer i;// for (i=0; i<nGrp; ++i)// n += (llList2Integer(glCatGrpAnim, n+1) + 2);// return n + nCatIndex;}SayReady(){ if (gbIs2Go) llOwnerSay("/me is ready to be used (" + (string)llGetFreeMemory() + " bytes free)"); else llSay(0, "/me is ready to be used (" + (string)llGetFreeMemory() + " bytes free)");}ShowCmdDlg(){ if (gnListen2 != 0) llListenRemove(gnListen2); gnListen2 = llListen(gnChnDialog, "", gkToucher, ""); glsOptions = []; if (gnCurrCountBall != 0) { if (gkToucher == llGetOwner()) { if (gbMoving) glsOptions += [ "*EndMove*" ]; else glsOptions += [ "*Move*" ]; } glsOptions += [ "*Swap*", "-None-" ]; } glsOptions += glsPlugins; if (gnCurrLvl > gnTopLvl) glsOptions += [ "-Level Up-" ]; gnMenuSpace = 12 - llGetListLength(glsOptions);//llOwnerSay("Menu lvl " + (string)gnCurrLvl); if (gnCurrLvl == 0) { integer i = 0; integer nSkip = gnCmdDiaOffset; while (i < llGetListLength(glCatGrpAnim)) { if (nSkip > 0) --nSkip; else glsOptions += llList2List(glCatGrpAnim, i, i); i += (2 * llList2Integer(glCatGrpAnim, i+1) + llList2Integer(glCatGrpAnim, i+2) + 3); } if ((gnCmdDiaOffset == 0) && (gnMenuSpace + llGetListLength(glsOptions) <= 13)) // one cat { gnCurrLvl = 1; gnTopLvl = 1; gnCatIndex = 0; ShowCmdDlg(); return; } gnTopLvl = 0; } else if (gnCurrLvl == 1) {//llOwnerSay("gnCatIndex=" + (string)gnCatIndex); integer i = gnCatIndex + 3; integer n = llList2Integer(glCatGrpAnim, gnCatIndex+1); gbHasLvl1 = (n > 1); if (!gbHasLvl1) // one group { gnCurrLvl = 2; if (gnTopLvl == 1) gnTopLvl = 2; gnGrpIndex = gnCatIndex + 3; ShowCmdDlg(); return; } integer nSkip = gnCmdDiaOffset; integer j; for (j=0; j<n; ++j) { string sGrp = llList2String(glCatGrpAnim, i); if (sGrp == "") sGrp = "*"; if (nSkip > 0) --nSkip; else glsOptions += [ sGrp ]; i += (llList2Integer(glCatGrpAnim, i+1) + 2); } } else { integer nMax = llList2Integer(glCatGrpAnim, gnGrpIndex+1); if (gnCmdDiaOffset >= nMax) gnCmdDiaOffset = 0; if (nMax > gnMenuSpace) { glsOptions += [ "-More-" ]; --gnMenuSpace; } if (nMax > gnCmdDiaOffset+gnMenuSpace) nMax = gnCmdDiaOffset+gnMenuSpace; llMessageLinked(LINK_THIS, 1430, llDumpList2String( llList2List(glCatGrpAnim, gnGrpIndex+gnCmdDiaOffset+2, gnGrpIndex+nMax+1), ","), NULL_KEY); return; } if (llGetListLength(glsOptions) > 12) // too many { glsOptions = llList2List(glsOptions, 0, 11 - gnMenuSpace) + [ "-More-" ] + llList2List(glsOptions, 12 - gnMenuSpace, 10); } string sText = "Select an animation"; if (gnCurrCountBall != 0) sText += "\nCurrent anim: " + gsCurrAnim; llDialog(gkToucher, sText, glsOptions, gnChnDialog);}default{ state_entry() { gnState = STATE_INIT; gbErrorReported = FALSE; gbIs2Go = (llGetSubString(llGetObjectName(), 0, 8) == "SexGen2Go"); if (HasInv(INVENTORY_SCRIPT, "~MenuAccess")) gnTouchNum = 1403; else gnTouchNum = 1401; glCatGrpAnim = []; gsCurrCat = ""; glsPlugins = []; glnPluginLink = []; } listen (integer channel, string name, key id, string message) { if (((channel == gnChnDialog) && (id == gkToucher)) || (channel == gnHUDChannel)) { if (llGetSubString(message, 0, 0) == "[") { integer n = llSubStringIndex(message, "]"); if (n > 0) { gkToucher = (key)llGetSubString(message, 1, n - 1); message = llGetSubString(message, n + 1, -1); } } if (message == "-More-") { gnCmdDiaOffset += gnMenuSpace; ShowCmdDlg(); return; } llListenRemove(gnListen2); gnListen2 = 0; if (message == "*Move*") { gbMoving = TRUE; llMessageLinked(LINK_THIS, 1102, "", NULL_KEY); return; } if (message == "*EndMove*") { gbMoving = FALSE; llMessageLinked(LINK_THIS, 1105, "", NULL_KEY); return; } if (message == "*Swap*") { llMessageLinked(LINK_THIS, 1103, "", NULL_KEY); return; } if (message == "!Menu") { if (gnState == STATE_RUN) { gnCurrLvl = 0; gnCmdDiaOffset = 0; ShowCmdDlg(); } return; } if (message == "-Level Up-") { --gnCurrLvl; if ((gnCurrLvl == 1) && (!gbHasLvl1)) gnCurrLvl = 0; gnCmdDiaOffset = 0; ShowCmdDlg(); return; } if (message == "-None-") { gnCurrCountBall = 0; llMessageLinked(LINK_SET, 1104, "", NULL_KEY); return; }// if (message == "?MDATA?")// {// llSay(gnHUDChannel, "MDATA1|" + (string)gnCurrCountBall + "|" + (string)gbHasCyber +// "|" + (string)llGetListLength(glsAnims));// integer i;// for (i=0; i<llGetListLength(glsAnims); i+=15)// llSay(gnHUDChannel, "MDATA2|" + llDumpList2String(llList2List(glsAnims, i, i+14), "|"));// for (i=0; i<llGetListLength(glCatGrpAnim); i+=15)// llSay(gnHUDChannel, "MDATA3|" + llDumpList2String(llList2List(glCatGrpAnim, i, i+14), "|"));// llSay(gnHUDChannel, "MDATA9");// return;// } integer n = llListFindList(glsPlugins, [ message ]); if (n >= 0) { llMessageLinked(LINK_THIS, llList2Integer(glnPluginLink, n), (string)gnCurrCountBall, gkToucher); return; } n = llListFindList(glCatGrpAnim, [ message ]); if (n >= 0) { if (gnCurrLvl == 0) { gnCurrLvl = 1; gnCatIndex = n; } else if (gnCurrLvl == 1) { gnCurrLvl = 2; gnGrpIndex = n; } gnCmdDiaOffset = 0; ShowCmdDlg(); return; } gsCurrAnim = message; n = llListFindList(glsOptions, [ gsCurrAnim ]); if (n >= 0) {//llOwnerSay("Options: " + llDumpList2String(glsOptions, ", ") + "; anim = " + gsCurrAnim + " => " + (string)n); n -= (12 - gnMenuSpace); gnCurrAnim = llList2Integer(glCatGrpAnim, gnGrpIndex+gnCmdDiaOffset+2+n);//llOwnerSay("Index = " + (string)n + ", anim index = " + (string)gnCurrAnim);//llWhisper(0, "Selected anim " + (string)n); llMessageLinked(LINK_THIS, 301, (string)gnCurrAnim, NULL_KEY); return; }//llOwnerSay("Unknown cmd " + message); } } link_message(integer sender_num, integer num, string str, key id) {//llOwnerSay("Got linkmsg " + (string)num + ", Touch=" + (string)gnTouchNum); if (num == gnTouchNum) { gkToucher = id; if (gnState != STATE_RUN) llOwnerSay("Please wait, the menu isn't ready yet"); else { gnCurrLvl = 0; gnCmdDiaOffset = 0; ShowCmdDlg(); } } else if (num == 400) { list lData = llParseString2List(str, [ "," ], []); gnCurrCountBall = llList2Integer(lData, 0); } else if (num == 801) { gnChnDialog = (integer)str + 1; gnHUDChannel = gnChnDialog + 4; llListen(gnHUDChannel, "", NULL_KEY, ""); } else if (num == 811) { glsPlugins += [ str ]; glnPluginLink += [ (integer)((string)id) ]; } else if (num == 1204) // Taken over { gnCurrCountBall = (integer)str; } else if (num == 1205) // Balls occupied { if ((integer)str == 0) llSetTimerEvent(600.0); else llSetTimerEvent(0.0); } else if (num == 1420) { if (str != gsCurrCat) { gnCatIndex = llListFindList(glCatGrpAnim, [ str ]); if (gnCatIndex == -1) // new cat { gnCatIndex = llGetListLength(glCatGrpAnim); glCatGrpAnim += [ str, 0, 0 ]; } gsCurrCat = str; }// else if ((string)id == llList2String(glCatGrpAnim, gnGrpIndex))// {// return;// } integer n = GetCatSize(gnCatIndex); if (n > 3) gnGrpIndex = llListFindList(llList2List(glCatGrpAnim, gnCatIndex + 3, gnCatIndex + n - 1), [ (string)id ]); else gnGrpIndex = -1; integer bNewGrp = (gnGrpIndex == -1); if (bNewGrp) gnGrpIndex = gnCatIndex + n; else gnGrpIndex += (gnCatIndex + 3); gnAnimIndex = gnGrpIndex + 2; if (bNewGrp) { Increment(gnCatIndex + 1); glCatGrpAnim = llListInsertList(glCatGrpAnim, [ (string)id, 0 ], gnGrpIndex); } else { gnAnimIndex += llList2Integer(glCatGrpAnim, gnGrpIndex + 1); }//llOwnerSay(str + " & " + (string)id + " => " + llDumpList2String(glCatGrpAnim, ","));//llOwnerSay("Cat=" + (string)gnCatIndex + ", Grp=" + (string)gnGrpIndex + ", Anim=" + (string)gnAnimIndex); } else if (num == 1421) { Increment(gnCatIndex + 2); Increment(gnGrpIndex + 1); glCatGrpAnim = llListInsertList(glCatGrpAnim, [ (integer)str ], gnAnimIndex); ++gnAnimIndex; } else if (num == 1422) { integer n = (integer)str; glCatGrpAnim = [ "*", 1, n, "*", n ]; integer i; for (i=0; i<n; ++i) glCatGrpAnim += [ i ]; } else if (num == 1423) { gnState = STATE_RUN; SayReady(); } else if (num == 1431) {//llOwnerSay("Option list = " + llDumpList2String(glsOptions, ", "));//llOwnerSay("Anim list = " + str); glsOptions += llParseString2List(str, [ "," ], []); string sText = "Select an animation"; if (gnCurrCountBall != 0) sText += "\nCurrent anim: " + gsCurrAnim; llDialog(gkToucher, sText, glsOptions, gnChnDialog); } else if (num == 1504) { list lsMissing = llParseString2List(str, [ "," ], []); integer n = llGetListLength(lsMissing); if (n > 0) { glCatGrpAnim += [ "Unlisted", 1, n, "*", n ] + lsMissing; } } } timer() { llSetTimerEvent(0.0); gnCurrCountBall = 0; llMessageLinked(LINK_SET, 1104, "", NULL_KEY); } on_rez(integer start_param) { llResetScript(); }}