Jump to content

Lilac Melodious

Resident
  • Posts

    10
  • Joined

  • Last visited

Posts posted by Lilac Melodious

  1. I've been working on this particular script for a while now, however in a recent addition to add a status var of "Crashed", "Normal Restart" or "Unknown", the dataserver works as intended, however the while loop for sending the message over llInstantMessage seems to not work for some reason.

    integer mem = 16384;
    integer gNotify = 0;
    integer listinc;
    key query = "NULL_KEY";
    string sData = "";
    string ver = "v1.1.0 b2";
    string time = "No restart last recorded.";
    list lNotify = [ // Comment out or remove NULL values. e.g: "" -> //"" or /*""*/
    //"", // 
    //"", // 
    "ea95c22c-834b-4e01-8833-988caacc8dc6", // Lilac.Melodious
    "972520cd-4c9f-4f42-83f3-041873c4e0ef"//, // kalacorad
    //"", // 
    //"" //
    ]; // UUIDs only.
    
    ///////// Get PDT/PST by Omei.Qunha
    
    list weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    
    string Unix2PST_PDT(integer insecs)
    {
        string str = Convert(insecs - (3600 * 8) );   // PST is 8 hours behind GMT
        if (llGetSubString(str, -3, -1) == "PDT")     // if the result indicates Daylight Saving Time ...
            str = Convert(insecs - (3600 * 7) );      // ... Recompute at 1 hour later
        return str;
    }
    
    // This leap year test is correct for all years from 1901 to 2099 and hence is quite adequate for Unix Time computations
    integer LeapYear(integer year)
    {
        return !(year & 3);
    }
    
    integer DaysPerMonth(integer year, integer month)
    {
        if (month == 2)      return 28 + LeapYear(year);
        return 30 + ( (month + (month > 7) ) & 1);           // Odd months up to July, and even months after July, have 31 days
    }
    
    string Convert(integer insecs)
    {
        integer w; integer month; integer daysinyear;
        integer mins = insecs / 60;
        integer secs = insecs % 60;
        integer hours = mins / 60;
        mins = mins % 60;
        integer days = hours / 24;
        hours = hours % 24;
        integer DayOfWeek = (days + 4) % 7;    // 0=Sun thru 6=Sat
    
        integer years = 1970 +  4 * (days / 1461);
        days = days % 1461;                  // number of days into a 4-year cycle
    
        @loop;
        daysinyear = 365 + LeapYear(years);
        if (days >= daysinyear)
        {
            days -= daysinyear;
            ++years;
            jump loop;
        }
        ++days;
    
        for (w = month = 0; days > w; )
        {
            days -= w;
            w = DaysPerMonth(years, ++month);
        }
        string str =  ((string) years + "-" + llGetSubString ("0" + (string) month, -2, -1) + "-" + llGetSubString ("0" + (string) days, -2, -1) + " " +
        llGetSubString ("0" + (string) hours, -2, -1) + ":" + llGetSubString ("0" + (string) mins, -2, -1) );
    
        integer LastSunday = days - DayOfWeek;
        string PST_PDT = " PST";                  // start by assuming Pacific Standard Time
        // Up to 2006, PDT is from the first Sunday in April to the last Sunday in October
        // After 2006, PDT is from the 2nd Sunday in March to the first Sunday in November
        if (years > 2006 && month == 3  && LastSunday >  7)     PST_PDT = " PDT";
        if (month > 3)                                          PST_PDT = " PDT";
        if (month > 10)                                         PST_PDT = " PST";
        if (years < 2007 && month == 10 && LastSunday > 24)     PST_PDT = " PST";
        return (llList2String(weekdays, DayOfWeek) + " " + str + PST_PDT);
    }
    
    /////////// End of borrowed function
    
    notifyonRestart() // There is no state detection for crashes, yet.
    {
        string status;
        if (sData == "up")
        {
            status = "Normal Restart";
        }
        else
        {
            status = sData;
        }
        string region  = llGetRegionName();
        //string status;
        string channel = llGetEnv("sim_channel");
        string version = llGetEnv("sim_version");
        string message = "The sim has restarted. Give 15-60 seconds for the sim to be fully ready before teleporting.\n Simulator info: \n"+region+"\n"+channel+"\n"+version+"\nRestarted: "+time+"\nCause of restart"+status+"\nScript Version "+ver;  
        integer pos = gNotify;
        while (++pos > -1)
        {
            llInstantMessage((key)llList2Key(lNotify, pos), message);
            llSetTimerEvent(0.2);
            if(llGetListLength(lNotify) < pos)
            {
                return;
            }
        }
    }
    
    clickinfo(key dKey)
    {
        string region  = llGetRegionName();
        string channel = llGetEnv("sim_channel");
        string version = llGetEnv("sim_version");
        string message = "\n Simulator info: \n"+region+"\n"+channel+"\n"+version+"\nRestarted: "+time+"\nScript Version "+ver;
        llInstantMessage(dKey, message);
    }
    
    default
    {
        on_rez(integer start_param)
        {
            llResetScript();
            llSetTimerEvent(2);
        }
    
        state_entry()
        {
            //llSetMemoryLimit(16384);
            if (llGetListLength(lNotify) < 1) // If list empty, use Object Owner UUID.
            {
                lNotify = [(string)llGetOwner()];
            }
            
            state Run;
        }
    }
    
    state Run
    {
        state_entry()
        {
            llSetMemoryLimit(mem);
            llSetObjectName(llGetRegionName()); 
        }
    
        changed(integer Changed)
        {
            if(Changed & CHANGED_REGION_START)
            {
                query = llRequestSimulatorData(llGetRegionName(), DATA_SIM_STATUS);
                notifyonRestart();
            }
        }
        dataserver(key qID, string data)
        {
            if (qID = query);
            {
                llInstantMessage(llGetOwner(), data); // Debug
                if (data)
                {
                    sData == data;
                }
            }
        }
        touch(integer total_number)
        {
            clickinfo(llDetectedKey(0));
        }
    }

    Should something stick out, please let me know. Currently the dataserver call is only for DATA_SIM_STATUS, and nothing else for memory reasons. This is because there is otherwise no other reliable way to implement the crashed/normal restart bit of information i wish to add, and it is not quite optimized yet. That will follow at a later date.

  2. Just now, Rolig Loon said:

    Get rid of 

    key id = llGetOwner;

    and rewrite your start function as

    start(integer inputInteger)
    {
        key id = llGetOwner();
        lstHandle = llListen(4, "", id, trgr);
        llSetMemoryLimit(inputInteger);
        llOwnerSay("Script has started.");
        llListen(4, "", id, "");
    }

     

    Thanks! That worked. This was done late at night and I only just got around to testing it. lol

    • Like 1
  3. Alright, here I am again with an odd issue. I'm working on a script that rezs an object on keyword, for roleplay purposes. I keep getting a compile error from the internal server. I have looked at a few topics and have tried a few sims, both on the main channel, one a homestead, and the other being the mainland. Nothing new, but largely in-progress, and i stopped at object_rez to test to see if it compiled, hence why it's commented out here. Here's the script:

    ////////////
    ////VARS////
    ////////////
    key id = llGetOwner;
    string trgr = "poops"; // Word to trigger.
    string objName = "test"; // Name of the object to be rezed.
    //integer lstChannel = 4; // Channel to listen for the trigger word on 
    integer mem = 32768; // Memory limit for the script.
    integer lstHandle;
    //----------//
    
    start(integer inputInteger)
    {
        lstHandle = llListen(4, "", id, trgr);
        llSetMemoryLimit(inputInteger);
        llOwnerSay("Script has started.");
        llListen(4, "", id, "");
    }
    
    orez()
    {
        llOwnerSay("Object is rezzed. Restarting.");
        llResetScript();
    }
    
    default
    {
        state_entry()
        {
            start(mem);
            
            llGetAttached();
            if (llGetAttached() != 40)
            {
                llOwnerSay("Please add me to Avatar Center before use.");
            }
        }
        listen(integer channel, string name, key id, string message)
        {
            if (message == trgr)
            {
                llRezAtRoot(objName, (vector)llGetPos(), ZERO_VECTOR, ZERO_ROTATION, 1);
            }
        }
        /*object_rez(key id)
        {
            ;
        }
    */}

     

  4. 2 minutes ago, Wulfie Reanimator said:

    There are a few odd things about the code you've posted.

    Firstly, your indentation/braces are very hard to follow because it's not entirely consistent. You've also got a lot of redundant returns in your code an if-else tree won't test the remaining conditions if one of them passes.

    Your first if-check also has this line:

    
    if(message == "Chest")
    {
        open_menu(id, abrvC, menuSelectC); return;
        {
            ...

    This means that it will open a menu, and then exit the event. The following braces (which don't mean anything) are dead code -- never executed.

    In the other conditions, the braces still mean nothing. They're executed immediately after the open_menu function is called, it's impossible to receive any input from the dialog that was opened during the current event.

    Noted. I'll fiddle around with the hierarchy of these starements.

  5. 7 hours ago, SimplifyKidd said:

    Hm... I see. It's not that straight forward...

    Scaling will only get me so far, as my prims have very different sizes.

    So, moving the linked prims might be a better way.

    You can use a very simple rotation script to rotate the object, keeping the root prim static while everything else rotates beyond the screen, given the script is in the root prim.

    • Like 1
  6. Evening everyone,

    I've recently ran into a problem creating the following script.

    The else/if logic is mostly unresponsive, other than the main and cancel segments. No llRegionSayTo calls (or even llSay) are being executed. See below;

    //=================================//
    //============Variables============//
    //=================================//
    integer gListener; //Don't change
    integer dialogChannel; //Don't change
    integer dialogHandle; //Don't change
    integer rstChannel = 99; //llRegionSayTo channel for communication to the slave scripts.
    integer mem = 16384; /*Reccommended value 16384; Lower values may not work, causing the script to take 64k (65536) instead of your limited amount, or to shout "Stack Heap Collision".*/
    string abrv = "\nWhat part would you like to hide?";
    string abrvA = "\nWhat arm would you like to hide?";
    string abrvA1 = "\nWhat would you like to do with 'RightArm'?";
    string abrvA2 = "\nWhat would you like to do with 'LeftArm'?";
    string abrvC = "\nWhat would you like to do on 'Chest'?";
    string abrvW = "\nWhat would you like to do on 'Waist'?";
    //string abrvL = "\nWhat leg would you like to hide?";
    list menuSelect = ["Chest", "Arms", "Waist", "Cancel"];
    list menuSelectA = ["Show RArm", "Hide RArm", "Show LArm", "Hide LArm", "Main"];
    list menuSelectC = ["ShowC", "HideC", "Main"];
    list menuSelectW = ["ShowW", "HideW", "Main"];
    //list menuSelectL = ["Right", "Left", "Main"];
    key id;
    /*
    ===================================
    ===========STATE CONFIG============
    ===================================
    */
    memory()
    {
        llSetMemoryLimit(mem);
        llOwnerSay("DEBUG; MEMORY: "+(string)llGetUsedMemory()+" used of "+(string)llGetMemoryLimit());
    }
    
    open_menu(key inputKey, string inputString, list inputList){
        dialogChannel = (integer)llFrand(DEBUG_CHANNEL)*-1;
        dialogHandle = llListen(dialogChannel, "", inputKey, "");
        llDialog(inputKey, inputString, inputList, dialogChannel);
        llSetTimerEvent(45.0);} //Time in Seconds before listen timeout.
        
    close_menu(){
        llSetTimerEvent(0); //0 is used here in place of 0.0 to save memory.
        llListenRemove(dialogHandle);}    
    /*
    ===================================
    ===============CODE================
    ===================================
    */
    
    
    default{
        on_rez(integer start_param){
            llResetScript();}
        state_entry(){
            memory();
            llOwnerSay("DEBUG: Memory allocated; Script booted.");
            llOwnerSay("I'm in JoMo Griffin mode...");}
            touch_end(integer total_number){
                key id = llDetectedKey(0); //Find who touched me.
                //key id = llGetOwner();
                llListen(dialogChannel, "", llGetOwner(), "");
                close_menu(); //Destroys my active ears.
                open_menu(id, abrv, menuSelect);}
            listen(integer channel, string name, key id, string message){
                //if(channel != dialogChannel)
                    //return;
                //close_menu();
                
                if(message == "Chest")
                {
                    open_menu(id, abrvC, menuSelectC); return;
                    {
                        if(message == "ShowC")
                        {
                            llRegionSayTo(llGetOwner(), 99, "topon");
                        }
                        else if (message == "HideC")
                        {
                            llRegionSayTo(llGetOwner(), 99, "topoff");
                            llOwnerSay("touched.."); //debug, where the problem was noticed.
                        }
                    return;}
                }
                else if (message == "Arms")
                {
                    open_menu(id, abrvA, menuSelectA);
                    {
                       if (message == "Show RArm")
                       {
                            llRegionSayTo(llGetOwner(), 99, "armRoff");
                        }
                        else if (message == "Hide RArm")
                        {
                            llRegionSayTo(llGetOwner(), 99, "armRoff");
                        }
                        else if (message == "Show LArm")
                        {
                            llRegionSayTo(llGetOwner(), 99, "armLoff");
                        }
                        else if (message == "Hide LArm")
                        {
                            llRegionSayTo(llGetOwner(), 99, "armLoff");
                        }return;
                    }
                }
                else if (message == "Waist")
                {
                    open_menu(id, abrvW, menuSelectW);
                    {
                        if(message == "ShowW")
                        {
                            llRegionSayTo(llGetOwner(), 99, "waiston");
                        }
                        else if(message == "HideW")
                        {
                            llRegionSayTo(llGetOwner(), 99, "waistoff");
                        }
                    return;}
                }           
                else if(message == "Main"){
                        open_menu(id, abrv, menuSelect); return;}
                }
                timer()
                {
                    close_menu();
                }
    }

    To answer any common questions, yes, I am on land that has scripts enabled, and it does compile. I've also read around on some similar problems on here.

    If anyone can help out, that'll mean a lot! Also, this is interfacing Alpha slave scripts, which I've already checked, and tested in local using /(channel)(message) format, like everything else, as well as using with other scripts like togglers that also use llRegionSayTo. they indeed work.

×
×
  • Create New...