Jump to content

Ruthven Ravenhurst

Resident
  • Posts

    491
  • Joined

  • Last visited

Posts posted by Ruthven Ravenhurst

  1. I'm starting to work on a snippet of a script for clicking a texture on a mesh object (i didn't make the mesh, so I can't re-map it to suit). It's a single mesh with a single face, but looks like multiple items, with each item being textured by a different part of the whole texture. the problem is, the defined areas aren't the same size. and there are multiple mesh items, and they  aren't mapped the same way on each of them. I hope this makes sense. What I'm trying to do is use llDetectedTouchUV to determine where on the texture it was clicked (llDetectedTouchST seemed more trivial with how it's mapped) and test the coordinates to determine which part of the mesh was clicked. I'm thinking I would need to run a test for each area until a matching one is found with something like: 

    touch_start(integer total_number)
        {
            vector UV = llDetectedTouchUV(0);
            if(UV.x >= 0.0 && UV.y <= 0.57 && UV.x <=0.563 && UV.y >= 0.0)//item 1
            {
                llSay(0,"1");
            }
            else if(UV.x >= 0.565 && UV.y <= 0.4116 && UV.x <= 1.0 && UV.y >= 0.0)//item 2
            {
                llSay(0,"2");
            }
            else
            {
                llSay(0,"Nope");
            }
        }

    Can anyone recommend a better way?

  2. 1 minute ago, Rachel1206 said:

    Precision of the LSL colors entries are 3 digits, so yu need to round the float values according to this.

     

     

    ah ok, did not know that. works beautifully now

    list colors = [<1.000000, 0.000000, 0.000000>, <0.000000, 1.000000, 0.000000>, <0.000000, 0.000000, 1.000000>, <1.000000, 1.000000, 0.000000>, <1.000000, 0.000000, 0.501961>, <0.000000, 1.000000, 1.000000>, <0.000000, 0.000000, 0.000000>, <1.000000, 1.000000, 1.000000>];
    
    float scale = 0.15;
    default
    {
        state_entry()
        {
            llSetColor(<1.0,1.0,1.0>,ALL_SIDES);
        }
    
        touch_start(integer total_number)
        {
            integer link = llDetectedLinkNumber(0);
            if(link > 1)
            {
                integer face = llDetectedTouchFace(0);
                vector c1 = llGetColor(0);
                vector c2 = llList2Vector(colors,face);
                vector newcolor = (c1*(1-scale)) + (c2*scale);
                if(newcolor.x < 0.001)newcolor.x = 0.00;
                if(newcolor.x > 0.999)newcolor.x = 1.00;
                if(newcolor.y < 0.001)newcolor.y = 0.00;
                if(newcolor.y > 0.999)newcolor.y = 1.00;
                if(newcolor.z < 0.001)newcolor.z = 0.00;
                if(newcolor.z > 0.999)newcolor.z = 1.00;
                llSay(0,(string)newcolor);
                llSetColor(newcolor,ALL_SIDES);
            }
            else
            {
                llResetScript();
            }
        }
    }

     

  3. I'm working on a theoretical approach to blending LSL color vectors, and saw what I think is strange behavior in the float value test, maybe I'm wrong?

    In the test for each element of the vector, I have it check if the value is more than 0.99, change it to 1.00, and if it's less than 0.00 change it to 0.00 (0.00743453 should convert to 0.00). It seems to be working on the 0.99 test, but not the 0.00 test. Script below, and text below that to show how many times I had to click the face representing black to get it to change the vector fully to black

    list colors = [<1.000000, 0.000000, 0.000000>, <0.000000, 1.000000, 0.000000>, <0.000000, 0.000000, 1.000000>, <1.000000, 1.000000, 0.000000>, <1.000000, 0.000000, 0.501961>, <0.000000, 1.000000, 1.000000>, <0.000000, 0.000000, 0.000000>, <1.000000, 1.000000, 1.000000>];
    
    float scale = 0.15;
    default
    {
        state_entry()
        {
            llSetColor(<1.0,1.0,1.0>,ALL_SIDES);
        }
    
        touch_start(integer total_number)
        {
            integer link = llDetectedLinkNumber(0);
            if(link > 1)
            {
                integer face = llDetectedTouchFace(0);
                vector c1 = llGetColor(0);
                vector c2 = llList2Vector(colors,face);
                vector newcolor = (c1*(1-scale)) + (c2*scale);
                if(newcolor.x < 0.00)newcolor.x = 0.00;
                if(newcolor.x > 0.99)newcolor.x = 1.00;
                if(newcolor.y < 0.00)newcolor.y = 0.00;
                if(newcolor.y > 0.99)newcolor.y = 1.00;
                if(newcolor.z < 0.00)newcolor.z = 0.00;
                if(newcolor.z > 0.99)newcolor.z = 1.00;
                llSay(0,(string)newcolor);
                llSetColor(newcolor,ALL_SIDES);
            }
            else
            {
                llResetScript();
            }
        }
    }
    Object: <0.01056, 0.01056, 0.01056>
    Object: <0.00898, 0.00898, 0.00898>
    Object: <0.00763, 0.00763, 0.00763>
    Object: <0.00649, 0.00649, 0.00649>
    Object: <0.00551, 0.00551, 0.00551>
    Object: <0.00469, 0.00469, 0.00469>
    Object: <0.00398, 0.00398, 0.00398>
    Object: <0.00339, 0.00339, 0.00339>
    Object: <0.00288, 0.00288, 0.00288>
    Object: <0.00245, 0.00245, 0.00245>
    Object: <0.00208, 0.00208, 0.00208>
    Object: <0.00177, 0.00177, 0.00177>
    Object: <0.00150, 0.00150, 0.00150>
    Object: <0.00128, 0.00128, 0.00128>
    Object: <0.00109, 0.00109, 0.00109>
    Object: <0.00092, 0.00092, 0.00092>
    Object: <0.00078, 0.00078, 0.00078>
    Object: <0.00067, 0.00067, 0.00067>
    Object: <0.00057, 0.00057, 0.00057>
    Object: <0.00048, 0.00048, 0.00048>
    Object: <0.00041, 0.00041, 0.00041>
    Object: <0.00035, 0.00035, 0.00035>
    Object: <0.00030, 0.00030, 0.00030>
    Object: <0.00025, 0.00025, 0.00025>
    Object: <0.00021, 0.00021, 0.00021>
    Object: <0.00018, 0.00018, 0.00018>
    Object: <0.00015, 0.00015, 0.00015>
    Object: <0.00013, 0.00013, 0.00013>
    Object: <0.00011, 0.00011, 0.00011>
    Object: <0.00009, 0.00009, 0.00009>
    Object: <0.00008, 0.00008, 0.00008>
    Object: <0.00007, 0.00007, 0.00007>
    Object: <0.00006, 0.00006, 0.00006>
    Object: <0.00005, 0.00005, 0.00005>
    Object: <0.00004, 0.00004, 0.00004>
    Object: <0.00004, 0.00004, 0.00004>
    Object: <0.00003, 0.00003, 0.00003>
    Object: <0.00003, 0.00003, 0.00003>
    Object: <0.00002, 0.00002, 0.00002>
    Object: <0.00002, 0.00002, 0.00002>
    Object: <0.00002, 0.00002, 0.00002>
    Object: <0.00001, 0.00001, 0.00001>
    Object: <0.00001, 0.00001, 0.00001>
    Object: <0.00001, 0.00001, 0.00001>
    Object: <0.00001, 0.00001, 0.00001>
    Object: <0.00001, 0.00001, 0.00001>
    Object: <0.00001, 0.00001, 0.00001>
    Object: <0.00001, 0.00001, 0.00001>
    Object: <0.00000, 0.00000, 0.00000>

     

  4. 18 minutes ago, sgtmarkoes said:

    alright, so if I want to start creating a HUD in mesh, should I use a program like blender for it? or do you guys have other software recommendations ? :) 

    i have mesh studio, which allows you to build a prim set and convert it to mesh. I can build the hud, attach it, change things around to perfect it. then mesh it

  5. 1 minute ago, Rolig Loon said:

    So you write
     

    
    on_rez (integer startup)
    {
        if (startup)
        {
            llSetTimerEvent(5.0);  
           // or llSetLinkPrimitiveParams (LINK_THIS,[PRIM_TEMP_ON_REZ,TRUE]); 
           // or change state to a new state with a collision_start event in it.
           // or whatever other trick strikes your fancy.
        }
    }

    And then be sure that you pass the object a non-zero startup parameter from the llRezAtRoot statement in your rezzer script.  That way, your object disappears in a flash if it's rezzed from the script but it lasts forever if you rez it from inventory.

    true, but sometimes I forgot to not use a 0 in that lol. or if i'm using a rez script that i can't mod and they do use a 0, like a wand I have, that i can put my own spells into, so i use

    on_rez(integer start_params)
    {
        list details = llGetObjectDetails(llGetKey(),[OBJECT_REZZER_KEY]);
        if(llList2Key(details,0) != llGetOwner())//makes sure it was rezzed by an object, and not the owner
    	{
            //do stuff if rezzed by object
        }
    	else
    	{
    		//do stuff if rezzed by owner
    	}
    }

     

    • Like 1
    • Haha 1
  6. list details = llGetObjectDetails(llGetKey(),[OBJECT_REZZER]);

    key rezzer = llList2Key(details,0);

    if(rezzer != llGetOwner())//object was rezzed by a script

    this is useful when working on something that is only meant to be rezzed for a short time, such as ammo, but you need to disable the timer or collision event so it doesn't die while you're working on it

    • Like 3
  7. Another "How does this work?" Question. I'm messing with a script that will have a customizable timer and wanted to play with casting some strings to a float

    So how does this work? It's returning 10.000000, when i figured it would just return 0 because of the non-number text in the string. I even tried casting to integer and it works too, and changing the plus sign to minus makes it a negative number

    default
    {
        state_entry()
        {
            float number = (float)"+10.0sec";
            llSay(0, (string)number);
        }
    }

     

  8. Perhaps try a new system? I have the personal version of Sun Rezzer and like it. I'm sure the only difference in the commercial version is the transferability

    2 hours ago, Benji Sorbet said:

     

  9. Another idea I had, is if it is the mesh items that don't seem to be rezzing is it may still be loading. Try right-clicking and Editing about where the item should be. If you're able to select something, but it's invisible. It could be the mesh isn't fully loaded and you'll see a torus made up of a bunch of triangles but not texture layers on it. I have this happen sometimes with meshes I've recently acquired and didn't previously view in world, or sometimes ones I haven't rezzed in a while. Sometimes they take seconds, sometimes several minutes to load depending on lag and how complex the mesh is.

    Another thing is, make sure you don't have duplicated names in the contents, like a texture or notecard with the same name as an object. I think it only appends numbers to the items with the same name if they are of the same asset type.

  10. 5 hours ago, Rolig Loon said:

    Renting won't do it.  You have to own it, or you have to be working for the owner, who is a Premium member and has set up an Experience there.  I'm non-Premium too, so I work as an Experience Contributor and I script for someone else.

    I think she meant rent in the "I take ownership of the parcel, but pay rent on it" sense. I have a parcel that I "own" that i rent from Azure, and can enable my experience on it

  11. Just now, Rolig Loon said:

    That's a peculiar one.  My guess is that it relies on implicit typecasting of thenumbers != [] to a float, and therefore equal to 1.0 unless the list doesn't exist.  It's clever, but I'm not sure whether to give it points for much more than cleverness.  It's on;y mild advantage over llFrand(1.0) is that it yields 0 if the list is empty -- perhaps an important failsafe in the context of the script where you found it.bu

    But it's not changing it to 1, it's resulting in a random number between 0 and the length of the list, but no where in theirs or my script is it using llGetListLength 

  12. I was looking at the group chat for the Scripting group and someone was having trouble with a script.

    I noticed they were using what looked like an odd way of getting a random number

    list thenumbers = [(area of texture uuids)];

    integer which = llFloor(llFrand(thenumbers != []));//This right here, how does it work?

    From looking at it, I would have guessed llFrand would be fed a True/False making it choose a number between 0 and 1, and then llFloor would round that down to 0 every time.

    But when I tested it with 10 entries as they were doing, it was working as they intended which was giving a random integer between 0 and 9

  13. Once you've got it set up, you need to also give a time limit for them to answer, and a minimum amount a time so they have time to read the terms before accepting. Perhaps have a landing point in a minimum sized parcel where they won't be ejected, and give them time to read the terms before giving them access to the rest of the sim

  14. 12 hours ago, Necati Millet said:
    
    integer listdist(string check)
    {
        integer idx = llListFindList(test, [check]);
        if(idx == -1){ return -2; } //if there is none to start with: return -2 then it will not run the rest.
        
        list temp = test; //Make a list that is the copy of the actual list
        temp = llDeleteSubList(temp, 0, idx); //Delete all the entries from start to first one found.
    
        idx = llListFindList(temp, [check]);
        if(idx == -1){ return -1; } //if there is no more left in the temp list after we took the first one found: return -1.
        return idx;
    }

    Should do what you wanted.

    Not quite, what I'm wanting is from the end of the list, not the beginning of this. The reason is because users can add themselves to the list, and I want them to be able to add themselves more than once with a threshold of a minimum number of other users between each of their entries. So what I want this to do is find the LAST 2 times (if there is more than one) and tell me how many entries are between them.

     

    Now that I think about it, I guess I don't need to do all that, I just need to find their latest entry, subtract that index from the list length and if the returned amount is more than the threshold, they can be added again

  15. I'm trying to develop this little snippet for a test for a bigger script. I can't see what's wrong with it, but it gives me the error, "Not all code paths return a value" when I try to save it. Can you point it out, or show me a better way? Thanks

    //Find the last 2 instances of a duplicate item in a list and tells the distance between them. returns -1 if there is only 1 instance of it and -2 if there are no instances
    
    list test = ["test1","test2","test3","test4","test5","test6","test7","test8","test9","test10","test11","test12","test13","test14","test15","test16","test17","test18","test19","test20","test21","test22","test1","test2","test3","test4","test5","test6","test7","test8","test9","test10","test11","test12","test13","test14","test15","test16","test17","test18","test19","test20"];
    
    integer listdist(string check)
    {
        integer idx = llListFindList(test,[check]);
        integer int;
        if(idx == -1){int = -2;return int;}
        else
        {
            integer len = llGetListLength(test)-1;
            integer first;
            integer foundfirst = FALSE;
            for(len;len > -1; --len)
            {
                if(llList2String(test,len) == check)
                {
                    if(!foundfirst){first = len; foundfirst = TRUE;}
                    else{return first - len;}
                }
            }
            if(foundfirst){int = -1; return int;}
        }
    }
    default
    {
        state_entry()
        {
            llSay(0,(string)listdist("test20"));
        }
    
        touch_start(integer total_number)
        {
            llSay(0, "Touched.");
        }
    }

     

  16. Another good use for this, even if you don't have it swing away from the avatar, it's a good way to determine if they are coming or going from a store through the door. So instead of welcoming them when they are walking out, the greeter could instead say something like, "I hope you enjoyed your stay, please come again!"

  17. So you're wanting to rez a chair and make sure it is set to a specific group? I'm wondering what purpose you would have for that. As said, the script you posed worked fine for me, before and after i changed it up a bit. If you're set on it not working if it's not set to the right group, you could have it say an error like "Wrong group set. Please set to *group name* to use this chair." And disable the functionality of the the script until it is set to the right group, perhaps checking on changed link event for what group it is set to. What I gathered from your original post, was that it is being rezzed from avatar's inventory, and not from a rezzer

  18. Is it not working for you? it seems to be working for me just fine.but a couple things, you could turn the function GroupCheck into an integer returning function, and instead resetting the script on rez to run the state entry, just move it to the on_rez event like so:

    string My_Group = "96ed751f-2855-66c7-cf99-3d40459f1143"; // change the UUID to your Group UUID
    
    integer groupSame()
    {
        list details = llGetObjectDetails(llGetKey(), ([OBJECT_GROUP]) );
        string myGroup = llList2String(details, 0);
        return( myGroup == My_Group);//one function to return the result of the test
    }
    
    default
    
    {
        on_rez(integer start_param)
        {
            if(groupSame())
            {
                llSay(0," Approved ");
            }
            else
            { 
                llSay(0," Wrong Group Self Deleting "); 
                llDie();
            }
        }
    }

     

×
×
  • Create New...