Jump to content

Temporary Demo :: llSleep or llSetTimerEvent ::


MIVIMEX
 Share

You are about to reply to a thread that has been inactive for 1959 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello! help please to sort out! I'm trying to create a script for the 10 minutes demo rezzed object. what is better to use llSleep or llSetTimerEvent? and what's the difference basically in this case? llSleep seems shorter and simpler. thanks!

default
{
    state_entry()
    {
        llSleep(600);
        llDie();
    }


}

or

default
{
    state_entry()
    {
        llSetTimerEvent(600);

    }
 
 
    timer()
    {
        llDie();
    }
}

 

Edited by MIVIMEX
Link to comment
Share on other sites

The difference is basically that llSleep does exactly what it says -- it makes your scripted object go to sleep for the period, so that it cannot receive messages or respond to them, or much else, for that matter. The script remains in the event where you placed the llSleep statement, waiting ... and waiting.. and waiting.  In contrast, llSetTimerEvent sets a trigger that will be activated at the end of the set period.  Until then, the script is fully awake and able to do anything that you want until the trigger is fired.  Generally speaking, it's wiser to use a timer event than to use llSleep unless you really do want the script to stop in its tracks for a short time.  I'd use llSleep, for example, in a object_rez event, to force the script to wait for 0.3 seconds before sending a message to a newly-rezzed object.  I would not use llSleep usually for more than a few seconds unless the script has absolutely nothing else to do and can afford to be incommunicado for that long.

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

When doing this be careful of permissions. Make your script copy/nomod and make the object rezed nomod as well.

It's rather easy to strip out kill scripts if the script is nocopy

 

Test and test again with a friend, make sure the friend also tries to open the object and copy the contents out.

Edited by Callum Meriman
  • Thanks 1
Link to comment
Share on other sites

2 hours ago, MIVIMEX said:

@Rolig Loon @Callum Meriman

Thank you very much for the answers! this raises the issue of permissions. in this case it is a vehicle. would it be enough just to put this script in it and what permissions would be better to use? It contains several scripts and animations. please advise! thank you very much!

Make everything copy/nomod/notrans and you're effectively set. (Except animations can be copied out of the vehicle but they would be notrans.) The big question here is who owns the vehicle rezzer, or are you giving the demo through marketplace?

10 minutes is a long time and an object can't die if an avatar is sitting on it (it will die when they stand up), so you should also add an llUnSit before llDie. If they can rez a new copy from their inventory, the timed death is pretty pointless.

What I would do is make the object temporary and die as soon as someone has sat on it, that way the demo only stays around until they stand up or gets cleaned up by the sim if nobody sits on it and it won't count towards a parcel's prim limit. Demo should also be all nocopy/nomod or preferably only given through an inworld rezzer they can't own.

Edited by Wulfie Reanimator
  • Thanks 1
Link to comment
Share on other sites

1 minute ago, MIVIMEX said:

@Wulfie Reanimator

thank you very much for the answer! This is a very interesting point. I really like your version, but I didn’t quite catch how to make the object temporary and so that you couldn’t use a new copy? going to distribute demo through the market. please help me figure it out! thank you!

In the edit window, there's a checkmark in the Object tab to make the object temporary. This means the sim will clean it up automatically after about a minute.

Similarly, there's permission checkmarks in the first tab for "next owner." You can also go into the Contents tab and set the permissions for all items in there at once (but if those items also have contents, they won't be changed).

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, Wulfie Reanimator said:

What I would do is make the object temporary and die as soon as someone has sat on it,

Calling llDie() as soon as someone sits on the object does what it sounds like -- the object vanishes as soon as you try to sit.   It needs to die as soon as the sitter stands up (you must realise this, but it might not be clear to less experienced scripters).

21 minutes ago, MIVIMEX said:

I didn’t quite catch how to make the object temporary and so that you couldn’t use a new copy?

I would do it something like this

	on_rez(integer start_param)
	{
		llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_TEMP_ON_REZ,TRUE]);//Safest to specify LINK_THIS since it will work on both unlinked objects and link sets
	}

	changed(integer change){
		if(change & CHANGED_LINK){ //When an avatar sits on something or stands up, it's treated as if you link/unlink another prim to the object
			if(llGetNumberOfPrims()==llGetObjectPrimCount(llGetKey())){//llGetNumberOfPrims() returns the number of prims, plus number of seated avatars (if any).
				//llGetObjectPrimCount ignores seated avatars.   So if the two functions return the same number, the sitter has stood up and no one is seated
				llDie();
			}
		}

	}

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

A little off topic, but Innula's code to test whether the object is being sat upon reminded me of this accepted feature request for adding new flags to llGetObjectDetails() to test whether an object is sat upon or selected. If implemented, it could prove to be a simpler way of doing the above test. Granted, the feature was accepted back in 2014...

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Innula Zenovka said:

Calling llDie() as soon as someone sits on the object does what it sounds like -- the object vanishes as soon as you try to sit.   It needs to die as soon as the sitter stands up (you must realise this, but it might not be clear to less experienced scripters).

Does llDie unsit avatars before deleting the object? I'm not home to test and I can't remember.. My memory tells me that object can't die while sat on, but I might be confounding that with being set to temporary (which definitely works this way).

  • Thanks 1
Link to comment
Share on other sites

7 minutes ago, Wulfie Reanimator said:

Does llDie unsit avatars before deleting the object?

You are correct, of course, about TEMP_ON_REZ not killing the object while you are seated, but I did test llDie before posting, because I wasn't sure, either, and the object vanished as soon as I tried to sit on it.

  • Thanks 2
Link to comment
Share on other sites

@Wulfie Reanimator @Innula Zenovka

@Fenix Eldritch @Nova Convair

Thank you very much for the answers!

Did I understand correctly that i can do it without a script at all, just make the object temporary? but then what is better permissions on the object itself and all that is inside? (I guess there is no way to make it no copy/no mod/no trans at all?) I can for example make the object transfer and the content only copy?

Edited by MIVIMEX
Link to comment
Share on other sites

7 hours ago, Innula Zenovka said:

 

I would do it something like this


	on_rez(integer start_param)
	{
		llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_TEMP_ON_REZ,TRUE]);//Safest to specify LINK_THIS since it will work on both unlinked objects and link sets
	}

	changed(integer change){
		if(change & CHANGED_LINK){ //When an avatar sits on something or stands up, it's treated as if you link/unlink another prim to the object
			if(llGetNumberOfPrims()==llGetObjectPrimCount(llGetKey())){//llGetNumberOfPrims() returns the number of prims, plus number of seated avatars (if any).
				//llGetObjectPrimCount ignores seated avatars.   So if the two functions return the same number, the sitter has stood up and no one is seated
				llDie();
			}
		}

	}

 

Thanks a lot for the script!

Edited by MIVIMEX
Link to comment
Share on other sites

Sleep is a user defined time penalty which can not be changed even on reset. It should only be used on short time liimits of a few seconds max. The timer does not disable the script. Personally i use unix time in the situation you describe, but 'sleep' is definitely not the one to use. Bad spelling.

Edited by steph Arnott
  • Thanks 1
Link to comment
Share on other sites

On 12/12/2018 at 1:53 PM, steph Arnott said:

Sleep is a user defined time penalty which can not be changed even on reset. It should only be used on short time liimits of a few seconds max. The timer does not disable the script. Personally i use unix time in the situation you describe, but 'sleep' is definitely not the one to use. Bad spelling.

There is not a right or wrong way to do it and I have yet to see any evidence anywhere that states you cant use a sleep for longer than a few seconds. As for UNIX time, your just over complicating the matter. llSetTimerEvent(600) would work perfectly fine. Simple solutions are the best answers, otherwise you end up giving yourself more work for the same result.

Edited by chibiusa Ling
Link to comment
Share on other sites

chibiusa, I never stated anywhere that one can not use llSleep for longer than a few seconds.  It does not state anywhere in my TV user manual that i can not mount my TV on the wall upside down either. llSleep was only ever ment for short halts and primarily to be used in cunjuction with LSL functions with inbuilt time penalties. And secondly to introduce ones own short time penalties. The llSleep function was never intend for long period script freezing.

As for unix time. I stated that is what i use under the usage the OP described. It was not complicating anything.  Unix time is used for valid reasons and is the third function that was not mentioned in the thread.

And yes there is a right and wrong way to do it, and llSleep is the WRONG way.

Link to comment
Share on other sites

3 hours ago, steph Arnott said:

chibiusa, I never stated anywhere that one can not use llSleep for longer than a few seconds.  It does not state anywhere in my TV user manual that i can not mount my TV on the wall upside down either. llSleep was only ever ment for short halts and primarily to be used in cunjuction with LSL functions with inbuilt time penalties. And secondly to introduce ones own short time penalties. The llSleep function was never intend for long period script freezing.

As for unix time. I stated that is what i use under the usage the OP described. It was not complicating anything.  Unix time is used for valid reasons and is the third function that was not mentioned in the thread.

And yes there is a right and wrong way to do it, and llSleep is the WRONG way.

I have to disagree. I prefer to view it as there being more and less efficient ways of doing things as opposed to right and wrong. Using a sleep whilst less efficient as it will lock up the script if it has other tasks to perform is still a perfectly legitimate way to achieve what the OP was originally asking. I also never stated that using UNIX time was invalid I use it myself to create a faux multi timer as well as create delays on how often you can activate certain features in hud I create, as opposed to using more sections of a faux multi timer, and for plenty of other reasons. All I was stating was that in the case of having a script wait 10 minutes before simply dying, as the OP seemed to be originally trying to do, then going all out with unix time checks to do that is like using a hammer to pick a daffodil. Completely unnecessary. Calm yourself

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1959 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...