Jump to content
MIVIMEX

Temporary Demo :: llSleep or llSetTimerEvent ::

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@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!

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
7 minutes ago, Fenix Eldritch said:

Granted, the feature was accepted back in 2014...

And implemented, I thought, in December 2017 with the addition of OBJECT_SIT_COUNT as a flag for llGetObjectDetails.

  • Like 1
  • Thanks 1

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

llDie kills the object and doesn't care for sitters. I observe it regularly since I have some interior that is hosted in rezzers. (NOT temp rezzers)
I'd wish the avatar would crash to the ground when the couch vanishes but SL is pretty unspectacular here. :)

  • Like 2
  • Thanks 1

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×