Jump to content

Wandering Soulstar

Resident
  • Posts

    421
  • Joined

  • Last visited

Posts posted by Wandering Soulstar

  1. Having just got home and being able to take another look at the code I discovered the problem. Though it is interesting what the result on the processed code was. At the beginning of my include file I had a #define, which I had accidentally placed a semi-colon after. The 'interesting' part is that the #define variable was 'replaced' correctly, and that the semi-colon was dumped at the end of the included functions.

    Back to the path, I see that it works if I put the path to the file, i.e. the sub-folder trail from the root. This though is not, at least to me, what I read on the Firestorm page:

    Quote

    You can also include files inside of subfolders. If you are compiling your script from your inventory, the Preprocessor will search the inventory path you are working in, descending into any subfolders, to find the referenced include file.

    Reading this it seems to say that the preprocessor will check the subfolders on it's own, without me having to specify ...

  2. @Wulfie Reanimator As to the file itself, each function is defined as it would be in a normal Script, i.e.

    function (params)

    {

    code

    }

    (sorry for not putting in a code window, but am on my phone)

    And for the path, have seen that, and not clear (at least for me). Question is, if folder ‘x’ is designated as the location for includes, and the file is in x\a, do I need to write:

    #include “\a\name.lsl”

    in other words, it will not automatically look in subfolders?

  3. Hi All .. this is going out to anyone that uses the Firestorm Preprocesor functionality ...

    I have just started to use this, and seem to be having some problems that I could use some help with. The first comes from the preprocessor, correctly inserting used functions from my 'common_funtions' file. But it is inserting a semi-colon ( ; ) after the bracket of the last function. Any ideas of what I am not doing in my function file that would cause this? Second question is actually finding the file. On the Firestorm page is says it can check sub-folders of the designated #include directory, my qustion is do I have to actually specify the sub-folder path in the #include directive line?

    Thanks in advance!!!!

  4. 26 minutes ago, steph Arnott said:

    Using integers as float saves nothing because when the script is run they are converted to floats which can cause issues. 

    Actually Steph, as it states above, it does reduce the the memory used, i.e. smaller byte code. In the Wiki as well, under the definition of Float:

    Quote

    If a function requires a float as a parameter, and the number is an integer (e.g. 5), you can add the .0 to clearly indicate it's a float, but omitting the .0 is equally valid and actually saves bytecode space in the compiled code.

    What's more ... when the script is 'run' as you state, it has already been compiled and the 'conversion' completed, at run time just executing the byte code. Finally .. would be interested in understanding what issues you are referring to .. have not seen any reference to this before.

  5. While having my morning coffee I was browsing around the Wiki, as one does, and came across THIS PAGE from @Omei Qunhua  that I had not seen before. The really interesting section for me came at the bottom:

    Quote

    Auto-casting of integers to floats (Mono)

    
      llSetTimerEvent(0)  is 3 bytes shorter than llSetTimerEvent(0.0)
      llSetText(message, <1, 1, 1>, 1) is 12 bytes shorter than llSetText(message, <1.0, 1.0, 1.0>, 1.0)
    


    Adding single items to a list (Mono) For ByteCode space-saving, don't form the new item into a list itself before adding.

    example:

    
      list MyList;
      MyList += "a";   is  10 bytes shorter than     MyList += ["a"];
      MyList += 1;     is  15 bytes shorter than     MyList += [1];
      15 byte savings also apply when adding floats, vectors and rotations.
    

    Counter intuitive, but good to know and something to take into account I would think. Also was intrigued by the last statement:

    Quote

    I've just developed a means of storing an avatar key losslessly in a quarternion, with help from work by Strife and Pedro. So that gives the chance to hold keys accurately in a list at just 28 bytes per key. Watch this space!

    Since the wiki page has not been updated since May of 2014 .. would be very interested in seeing what came of this ... Omei, @Strife Onizuka, Pedro  .... are you there?

  6. Not the same, but similar to your issue @Melkanea I have seen, on occasion, when I copy code from the forum and paste into LSL Editor that some of the words change to a different font, and the line acts weird (hard to explain) in the editor .. and definitely won't compile. Only way to clean it up has been delete and re-write. I'm using Firstorm & FireFox (on Win10). Next time it happens will try to investigate more, for curiosities sake.

    • Like 1
  7. Since the time has past for me to be able to edit it, please ignore the above post. I had tested this out, but only briefly and must have hit the one scenario/time it was right. I have just these past days been finally in full testing of the system where this code was .. and found out that it did not work at all. After struggling with it for much longer than I should have (being stubborn) .. I went back to @animats code .. and wouldn't you know it .. worked perfectly. For my scenario though there was one problem ... llGetBoundingBox returns for the whole linkset, whilst I need it for the specific prim ... but actually calculating the prim's bounding box is fairly simple .. at least I believe so .. basically it is just the prim scale vector with each xyz divided by 2 (max) and -2 (min) ... if this is not always correct please let me know ...

    My final version is as follows .. mainly animat's code .. with formating changes based on how I like it (to each their own style) , the bounding box change, passing in the values as I do need this code to get these values for other prims as well and llGetObjectDetails does not bring back scale, and as well I have scenarios where I need to call this passing a scale that the prim does not have ... and then finally removing the pathMax, pathMin functions (again personal preference).

     

    vector div_vector_num(vector dividend, float divisor)
    {
        dividend.x = dividend.x/divisor;
        dividend.y = dividend.y/divisor;
        dividend.z = dividend.z/divisor;
    
        return dividend;
    }
    
    //find the global positions of the max and min corners of a prim
    //developed by animats
    //minor modifications by Wanda Soulstar 
    list get_corners(vector pos, rotation rot, vector size)
    {
        // bounds in local dist from center, min & max
        list bound = [div_vector_num(size, -2), div_vector_num(size, 2)];
        
        //resulting corner positions
        vector minCorner;                               
        vector maxCorner;
        //loop through the x,y,z vertices
        //ctrs
        integer ix;
        integer iy;
        integer iz;
        //vertices
        vector vx;
        vector vy;
        vector vz;
        //calculations
        vector pt;
        vector ptWorld;
        
        for (ix = 0; ix < 2; ix++)                          
        {
            vx = llList2Vector(bound, ix);        
            for (iy = 0; iy < 2; iy++)
            {
                vy = llList2Vector(bound, iy);          
                for (iz = 0; iz < 2; iz++)
                {
                    vz = llList2Vector(bound, iz);
                    //now get the corner ... in obj coords
                    pt = <vx.x, vy.y, vz.z>;
                    //translate to world coords     
                    ptWorld = pt * rot + pos;
    
                    //first time through set base
                    if ((ix + iy + iz) == 0)
                    {
                        minCorner = ptWorld;
                        maxCorner = ptWorld;
                    }                
                    else
                    {                    
                        //calc min corner
                        if (ptWorld.x < minCorner.x){minCorner.x = ptWorld.x;}
                        if (ptWorld.y < minCorner.y){minCorner.y = ptWorld.y;}
                        if (ptWorld.z < minCorner.z){minCorner.z = ptWorld.z;}
                        //and then max corner
                        if (ptWorld.x > maxCorner.x){maxCorner.x = ptWorld.x;}
                        if (ptWorld.y > maxCorner.y){maxCorner.y = ptWorld.y;}
                        if (ptWorld.z > maxCorner.z){maxCorner.z = ptWorld.z;}
                    }
                }
            }
        }
        return([minCorner, maxCorner]);                 
    }

     

  8. I think your question was more along the lines of pre-rental of the skybox .. no? I don't have a specific answer for you, mainly as I do not tend to use security orbs. I would think though from my experience with them in the wild, that you can set the amount of time before the orb ejects someone. So you could set this to a reasonable period for potential renters .. but finding that right period could be hard and you'll certainly end up ejecting real customers .. and personally I'd be turned off by a place that ejected me.

    To be honest I really do not think you have much to worry about, no one is going to squat. There are tonnes of rental places all over SL, none of which have security orbs to eject squaters.

    • Like 1
  9. @steph Arnott I think you are missing the point here. Independent of how the scripts get into the prim .. the fact is

    Scenario A - Scripts are already loaded, the prim is a copy made using viewer build tools. The name has been checked using llGetInventoryType, so it 'exists' in the Prim's inventory, yet throws an error (occasionally .. not all the time) when setting the state

    Scenario B - The name of the script is retrieved using llGetInventoryName, so again it 'exists', and again throws an occasional error.

  10. 2 minutes ago, steph Arnott said:

    Try pasting the script code into a fresh script and use that as the usage script. An edited script can retain corruped data.

    Have done that, multiple times .. this is not occuring in a single script, and has occured in other scripts I have in the past that do something similar. I raised this on the forum some years ago, and at the time was told that there is some delay between what the Inventory 'contents list' has and the items actually being fully loaded to inventory. Putting in the llSleeps where I have reduces the occurrences of this, but still can occur.

  11. @steph Arnott  Just to be clear, Scenario B occurs when dropping scripts into a prim. Scenario A is the one when copying prims. And whilst my HUD as well contains primswith the scripts, when building you more often than not want to make a copy of an existing prims, that has already been made to a size, textured, etc.

  12. Hi All,

    I have a re-occuring error, though not one that happens constantly. I believe I know the reason, and have a clunky work around, but was hoping someone might have a better solution. What happens is on two scenarios I have either of the following Code Snippets that at times shout an error on Debug that file 'x' was not found

    A)

        listen(integer channel, string name, key id, string message)
        {
            list params = llParseString2List(message, [FUNC_SEP], [EMPTY_STR]);
            string function = llList2String(params, 0);
    
            if (function == F_SCR_DATA)
            {
                gScripts = llParseString2List(llList2String(params, 1), [DATA_SEP], [EMPTY_STR]);
                //disable them
                integer num = llGetListLength(gScripts);
                string script;
                //need to wait a moment to allow inventory lists to catch up <sigh>
                llSleep(2.0);
                while (num-- > 0)
                {
                    script = llList2String(gScripts, num);
                    if (llGetInventoryType(script) != INVENTORY_NONE){llSetScriptState(script, FALSE);}
                }
            }
        } 

    This one gives the error occasionally when I make a copy of the object this code is in. The start of the script makes a call to another object (HUD) to get the list of scripts, so you would think that the prim has loaded everything .. but no. Even dropping an llSleep before the While does not avoid this error 100%.

     

    B)

        changed(integer change)
        {
            if (change & CHANGED_INVENTORY)
            {
                //need to wait a moment to allow inventory lists to catch up <sigh>
                llSleep(2.0);
                //check if a change in the scripts
                integer curNum = llGetInventoryNumber(INVENTORY_SCRIPT);
                integer scrNum = llGetListLength(gScripts);
                string name;
    
                //if added
                if (curNum > scrNum)
                {
                    gScripts = [];               
                    //get the name(s) and add to the list, stopping them
                    while (curNum-- > 0)
                    {
                        name = llGetInventoryName(INVENTORY_SCRIPT, curNum);
                        if (name != ME){gScripts += [name]; llSetScriptState(name, FALSE);}
                    }
                    
                }
                //or removed
                else if (curNum < scrNum)
                {
                    while (scrNum-- > 0)
                    {
                        if (llGetInventoryType(llList2String(gScripts, scrNum)) == INVENTORY_NONE){gScripts = llDeleteSubList(gScripts, scrNum, scrNum);}
                    }
                }
                
            }
        }

    Here it comes, as you can see, when scripts are dropped into the object. Again, not continually happening, but just once in a while. 

    In summary, although using LLGetInventoryType to check, or actually pulling the name from llGetInventoryName, calling the LLSetScriptState on occasion fails. I do not want to be putting the script to sleep for ages .. and so was hoping someone had a solution.

    Thanks!

    Wanda

  13. All .. just was finally debugging inworld an realised I had, by the example given, not fully explained what I am trying to do. The previous answers around EulertoRot and back helped .. but I realised that I need to calculate the actual value I need to add .. it is not 180 as I gave in the example.

    What I want to do is mirror an angle ... this means if base x is 300 .. mirror x is 60; if base x is 330 .. mirror x is 30.; etc ....

    Does anyone know of a formula to be able to calculate this? I only want to change the selected axis rotation ...

  14. Thanks @Wulfie Reanimator ... had missed that line in the Wiki .. and  @steph Arnottyou were correct as well .. see the solution they provide in the wiki ..

    Quote

    If name is a new empty notecard (never saved) then an error "Couldn't find notecard ~NAME~" (~NAME~ being the value of name) will be shouted on the DEBUG_CHANNEL. This is because until a notecard is saved for the first time, it does not exist as an asset only as an inventory placeholder.

    If the notecard is full-perms you can check for this with llGetInventoryKey which will return NULL_KEY in this case. However if notecard is not full-perms, there is no way to avoid the error message.

     

    • Thanks 1
  15. Hi all,

    After all these years of using notecards in scripts I have just come across a small issue and was wondering if someone had an answer.

    What is happening is, after checking that the notecard actually exists, and I call llGetNotecardLine (or llGetNumberOfNotecardLines same result). I was then getting a debug error that the Notecard did not exist, whilst it actually did exist in the inven. After a bit I was able to isolate the problem: the notecard had not been initialised. What I mean by this is that I had created a new notecard in inven, and as there is a scenario where the notecard could exist, but be empty, I left it as that without opening. Apparently the system does not like this. If you open the note card make changes, but leave it with no lines and save .. you are fine. My question is, does anyone know of a way to protect against this, i.e. avoid code breaking?

    Thanks ... Wanda

×
×
  • Create New...