Jump to content

AlduousMcBurlington

Resident
  • Posts

    19
  • Joined

  • Last visited

Posts posted by AlduousMcBurlington

  1. I'm surprised no one caught my error; apparently llGetGMTclock() does return a float but it's truncated to the nearest second, making this function unusable lol

     

    I'm working on a fix, and if anyone's interested I can reply the corrected function to this thread or make a new post when I'm done.

  2. If it's in a HUD, only the wearer can hear it.

     

    EDIT: Another hack / workaround would be to play the sound at a very low volume and position the sounding object as close to the agent's camera as possible, although that requires you know where their camera is, which you'll need permissions for.

  3. 17 minutes ago, Innula Zenovka said:

    Depends on the use case, but I still think I'd work hard to avoid both extended llSleep calls and attempts to emulate them.  

    All I can say is that whenever someone asks me to help fix a script and I find either a long llSleep or a loop involving while (TRUE), the problem is almost invariably to do with that.   I'm not saying that long sleeps or potentially infinite loops are automatically going to break a script, but they are so likely to break something that I'm scared of using them and will work hard to find a safer alternative. 

    Yes; this was more for a simple way to save time while iterating loops than anything else. For example...

     

    default
    {
    
    	state_entry()
    	{
    
    		integer SE_placeholder = 0;
    
    		while(SE_placeholder < 100)
    		{
            	
    			DoSomethingTimeSensitive();
    			llWait(0.001);
    			SE_placeholder += 1;
                                       
    		}
    
    	}
    
    }

    ... especially since timers raise event queues, which can be hard on the sim (at very low values).

  4. 2 hours ago, Nova Convair said:

    The script does the same as llSleep.

    Just one difference - llSleep uses a cpu time of 0 and this script uses alot of cpu time.

    LSL scripts are single threaded - there is no multitasking! While an event handler or a function is executing no events can trigger and so they are queued up.

    But the idea of this script is based of the wrong assumption that events will trigger in the background. That is NOT the case.

    I never said it was multi-threaded, nor was I under that impression. I simply said it was a good way to prevent event queues from being dropped in cases where you would have otherwise used llSleep().

    To Innula: I'd tend to agree wholeheartedly, except in cases where you want to confine wait times to a single event or method without having to worry about saving the current data being used in a global variable (i.e. a loop). Also, timers can be hard on the simulator depending on the floated time, so this is a viable alternative for practical purposes. 

     

  5. Maybe something like...

     

    float meters_per_second = 3.2; // change this to set max speed of avatar
    
    
    //--------------------------------------------------------------------------------
    
    float step;
    
    vector pos;
    
    key attacher;
    
    default
    {
    
    	state_entry()
    	{
    
    		step = meters_per_second * 0.1;
    
    	}
    	
    	attach(key attach_id)
    	{
    		
    		if(attach_id != NULL_KEY && llGetAttached() > 0)
    		{
    			pos = llGetPos();
    			attacher = attach_id;
    			llSetTimerEvent(0.1);
    		}
    
    	}
    
    	timer()
    	{
    
    		vector current_pos = llGetPos();
    
    		if( llVecDist(current_pos, pos) > step )
    		{
    
    			integer agent_info = llGetAgentInfo();
    
    			if( (agent_info & AGENT_WALKING) || (agent_info & AGENT_ALWAYS_RUN) )
    			{
    
    				vector direction = current_pos - pos;
    
    				if(direction.x > step)
    					direction.x = step;
    				else if(direction.x < -step)
    					direction.x = -step;
    
    				if(direction.y > step)
    					direction.y = step;
    				else if(direction.y < -step)
    					direction.y = -step;
    
    				if(direction.z > step)
    					direction.z = step;
    				else if(direction.z < -step)
    					direction.z = -step;
    
    
    				pos += direction;
    
    				llSetLinkPrimitiveParamsFast(0, [PRIM_POSITION, pos]);
    
    			}
    
    			else
    				pos = llGetPos();
    
    		}
    
    		else
    			pos = llGetPos();
    
    	}
    
    
    }

     

    Keep in mind that this does not account for agents crossing sim/region boundaries, and may cause a jerking motion when they're corrected; it's a decent example albeit written from scratch, so I have no idea about how compile-able it is.

    • Like 1
  6. If anyone's looking for a way to llSleep() their script, but don't want to prevent event queues from mounting up during this time-period, I made a function that you can just plop into your code and use in the same way as llSleep() and it'll get rid of the nastiest part of that function.

    It'll also work over midnight time crossings, so you can use it at any time, anywhere, and it'll function exactly as expected, to a very accurate measurement (less than 0.00000001 seconds inaccuracy).

    llWait(float wait_time)
    {
        
        float start_time = llGetGMTclock();
        
        while(TRUE)
        {
            
            float current_time = llGetGMTclock();
            
            if(current_time >= start_time)
            {
                
                if(current_time - start_time >= wait_time)
                    return;
            }
            
            else
            {
                
                if( (86400.0 - start_time) + current_time >= wait_time )
                    return;
                
            }
            
        }
        
    }

     

  7. So a little while back, while the forums were offline for the new site update, I had a question I wanted answered: what loops are fastest in mono, and what stipulations should be taken into account when scripting them?

    As it turns out, this is quite an interesting topic that has a lot of commentators scratching their heads. Well, I'm not here to talk about efficiency, but I am here to definitively conclude which loops appear to be fastest (and when they usually are). Using a simple script that can be found below, I conducted some tests (in mono) to see what loops finish fastest with no arguments inside of them to test the true speed of the loop itself, from a practical approach without considering the theory behind it.

    My results could be considered a little odd, as the answer of 'fastest' actually appears to vary based on how many iterations you happen to be looping through. 

    The results of my particular test are printed below, as concluded by the script found at the end of the page:

     

    'for' loop time to 100: 0.000000
    'for' loop time to 1,000: 0.024513
    'for' loop time to 10,000: 0.044505
    'for' loop time to 100,000: 0.596119
     'for' loop time to 1,000,000: 6.318980
     
    'do-while' loop time to 100: 0.000000
    'do-while' loop time to 1,000: 0.030374
    'do-while' loop time to 10,000: 0.114235
    'do-while' loop time to 100,000: 1.198419
    'do-while' loop time to 1,000,000: 12.739420
     
    'while' loop time to 100: 0.000000
    'while' loop time to 1,000: 0.014845
    'while' loop time to 10,000: 0.116710
    'while' loop time to 100,000: 1.200627
    'while' loop time to 1,000,000: 12.317580

    loop time to 100:

    All loops evenly matched for practical purposes.

     

    loop time to 1,000:

    'while' loops beats all; 0.015529 seconds faster than 'do-while', and 0.009268 seconds faster than 'for'.

     

    loop time to 10,000:

    'for' loop beats all; 0.06973 seconds faster than 'do-while', and 0.072205 seconds faster than 'while'.

     

    loop time to 100,000:

    for loop beats all; 0.6023 seconds faster than 'do-while', and 0.604508 seconds faster than 'while'.

     

    loop time to 1,000,000:

    for loop beats all; 6.42044 seconds faster than 'do-while', and 5.9986 seconds faster than 'while'.

     

     

    In simple conclusion, loops are a funny business and they can vary based on many probably factors. Please use the script to do the experiment yourself, as learning is always a personal endeavour!

    I hope this was helpful at least to someone, and that it might lead to better scripting habits in the future for all. Have a good one!

     

    default
    {
    
        touch_start(integer total_number)
        {
            
            if(llDetectedKey(0) == llGetOwner())
            {
            
                llOwnerSay("Beginning loop test.\n ");
                
                integer i = 0;
                
                llResetTime();
                
                for(i; i < 100; i += 1){}
                
                llOwnerSay("'for' loop time to 100: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                for(i; i < 1000; i += 1){}
                
                llOwnerSay("'for' loop time to 1,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                for(i; i < 10000; i += 1){}
                
                llOwnerSay("'for' loop time to 10,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                for(i; i < 100000; i += 1){}
                
                llOwnerSay("'for' loop time to 100,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                for(i; i < 1000000; i += 1){}
                
                llOwnerSay("'for' loop time to 1,000,000: "+(string)llGetTime()+"\n ");
                
                //-----------
                llSleep(2.0);
                //-----------
                
                i = 0;
                
                llResetTime();
                
                do{i += 1;} while(i < 100);
                
                llOwnerSay("'do-while' loop time to 100: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                do{i += 1;} while(i < 1000);
                
                llOwnerSay("'do-while' loop time to 1,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                do{i += 1;} while(i < 10000);
                
                llOwnerSay("'do-while' loop time to 10,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                do{i += 1;} while(i < 100000);
                
                llOwnerSay("'do-while' loop time to 100,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                do{i += 1;} while(i < 1000000);
                
                llOwnerSay("'do-while' loop time to 1,000,000: "+(string)llGetTime() + "\n ");
                
                //-----------
                llSleep(2.0);
                //-----------
                
                i = 0;
                
                llResetTime();
                
                while(i < 100){i += 1;}
                
                llOwnerSay("'while' loop time to 100: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                while(i < 1000){i += 1;}
                
                llOwnerSay("'while' loop time to 1,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                while(i < 10000){i += 1;}
                
                llOwnerSay("'while' loop time to 10,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                while(i < 100000){i += 1;}
                
                llOwnerSay("'while' loop time to 100,000: "+(string)llGetTime());
                
                
                i = 0;
                
                llResetTime();
                
                while(i < 1000000){i += 1;}
                
                llOwnerSay("'while' loop time to 1,000,000: "+(string)llGetTime());
                
            }
            
        }
    }

     

  8. Try saving the responses to two seperate variables in the timer script and using their data to verify if the timer function should be called.

    integer seen_CommandOne = FALSE;integer seen_CommandTwo = FALSE;default{    state_entry()    {        llListen(1, "", "", "");    }    listen( integer channel, string name, key id, string message )    {        if(message == "command one") seen_CommandOne = TRUE;        else if(message == "command two") seen)CommandTwo = TRUE;        if(seen_CommandOne == TRUE && seen_CommandTwo == TRUE)        {            llSetTimerEvent(10);        }    }    timer()    {        //start event    }}

    You can always reset the "seen_*" variables to both FALSE again whenever you wish to open the script to be triggered again (possibly at the end of the timer event).

     

    Hope this helps.

    • Like 1

  9. _COSMOS MASTER_

    A UNIVERSE WITHIN WORLDS



    For over a year and a half, a team of highly selected programmers, graphic artists
    and marketers have come together to create a game unlike no other.

    A game that until now has remained largely hidden;
    one that hopes to change the way games are played in the
    virtual world.

    A game to learn, to play, to earn and get paid.

    A game that's finally ready
    to be revealed to the public.


    Official SLUrl to Space Station [CMOSS]:
    http://maps.secondlife.com/secondlife/Cadillac%20Ranch%20TX/202/181/2008

    SLUrl to Official Game Assets:

    http://maps.secondlife.com/secondlife/Cadillac%20Ranch%20TX/128/167/2002


    For the very first time ever
    you'll get the most pay at the lowest cost.
    Earn more than you thought possible,
    and drive high volumes of player traffic.

    Use your BX-Z 42 interstellar class starship to harvest resources and sell them
    for guaranteed cash.
    Refine them to materials and make fuel for things like combat,
    cloaking, repairing and more.

    Place resource prims on your land and feel the
    power of community run through you.

    Join us on our land for a copy of a ship, HUD
    and resource prims for parcel owners to use
    for driving traffic to their land,
    at the lowest cost.

    So we all hope to see you there.

    And always remember Initiates:

    Beware the umber;
    be one with
    the light.

  10. For over a year and a half, a team of highly selected programmers, graphic artists
    and marketers have come together to create a game unlike no other.

    A game that until now has remained largely hidden;
    one that hopes to change the way games are played in the
    virtual world.

    A game to learn, to play, to earn and get paid.

    A game that's finally ready
    to be revealed to the public.


    Febrary 23rd, 2016

    http://maps.secondlife.com/secondlife/Cadillac%20Ranch%20TX/132/125/39

    3PM - 8PM SLT
    Convention starts at 3, Q&A @ 6 and afterparty 8PM +


    For the very first time ever
    you'll get the most pay at the lowest cost.
    Earn more than you thought possible,
    and drive high volumes of player traffic.

    Use your BX-Z 42 interstellar class starship to harvest resources and sell them
    for guaranteed cash.
    Refine them to materials and make fuel for things like combat,
    cloaking, repairing and more.

    Place resource prims on your land and feel the
    power of community run through you.

    Join us for our convention center launch,
    followed by Q&A about the game,
    which precedes the launch of the official game
    to be announced moments before the official after party.

    We all hope to see you there.

    And always remember Initiates:

    Beware the umber;
    be one with
    the light.

  11. Hey there, from what you discribed in your post I am quite sure I can do it. If you were still in need of a professional scripter, drop me a line at 'alduousmcburlington.resident' in NC and ill check it out as soon as I'm in.

    Have a good one,

    Alduous

  12. Hello,

     

    I am seeking a person who hopefully has experience with SL realty (although it's not actually a prerequisite) who might be able to look after a flow of plots to be purchased and rented as soon as the job begins. While the rental area will be relatively low, the realtor would be expected to be acting landlord/HR personnel for Ventrium Security (subsection of Ventrium Entertainment), managing the plots/group and tier, profits and cuts. 

     

    If you are interested in the discription please give me a heads up in game with a notecard or an IM and I'll try to get back to you as soon as possible.

    Thanks for your interest, 

    Alduous McBurlington

  13. Hello, I've been scripting in SL and C# for a few years now and am highly confident in my logistical/written capabilities. Currently I am working on an MMO in SL to which will be released in the coming months and am looking for something to feed a little $L into the project. 

    My experience in C# is mostly oriented around mesh manipulation and polygonal alteration so my understanding of this aspect should be greatly comforting.

    Within SL I've created things like chatbots, broker/auction scripts, HUDs, interactive scenery and really too much else to name.

    I'm basically looking for anything that might bring in some income and that which I could build a professional relationship. If this sounds like you, gimme a shout in game via message (AlduousMcBurlington).

    Thanks

×
×
  • Create New...