Jump to content

Failure in simplicity


steph Arnott
 Share

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

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

Recommended Posts

What am i missing here? It stops at the next line past 'if'. It was working just fine. And i have been changing things out of shear irritation.

key ownerid;
vector startPos;

default
{
    state_entry()
    {
        llListen(10," ", NULL_KEY, "starboard");
        startPos = llGetPos();
    }
    listen(integer channel, string name, key id, string message)
    {
        ownerid = llGetOwnerKey(id);
        llSetPos(startPos);
        if (message == "starboard")
        {
            llTriggerSound("Machine_sound2", 1.0);
            llSleep(1.5);
            llTriggerSound("tardis door", 1.0);
            integer i;
            do
            {
                llSetPos(llGetPos()+ <0.2,0.0,0.0>);
                llSleep(0.1);
            }
            while(++i < 25);
            state closed;
        }
    }
    changed(integer change)
    {
        if(change & CHANGED_OWNER)
            llResetScript();
    }
}
state closed
{
    state_entry()
    {
        llListen(0,"", NULL_KEY, "starboard");
    }
    listen(integer channel, string name, key id, string message)
    {
        if (message == "starboard")
        {
            llTriggerSound("tardis door", 1.0);
            integer i;
            do
            {
                llSetPos(llGetPos()- <0.2,0.0,0.0>);
                llSleep(0.1);
            }
            while(++i < 25);
            llTriggerSound("Machine_sound2", 1.0);
            llSetPos(startPos);
            state default;
        }
    }
}

Edited by steph Arnott
typo
Link to comment
Share on other sites

I don't see an LSL error in the script, but I notice that your llListen statement in state_entry is already filtering out any incoming messages except ones that have message == " starboard".  Since that's the case, you don't need those if statements at all.  In fact, it could be that the reason things stop at that point is that the script is only listening for "starboard".  Does it behave properly when the message is "starboard"?

Edited by Rolig Loon
Link to comment
Share on other sites

Your StartPos variable should set itself to llGetPos() in state_entry, but you might check to be sure that it is doing that.  If it believes StartPos == ZERO_VECTOR or someplace else that's more than 10m away, it might stall while trying to reach it.  If that's the problem, you may be able to figure out where it's getting the bad value for StartPos.  In any case, you should probably use llSetRegionPos to cover cases when the start position really is more than 10m away.

I'm really grasping at straws.  I don't see anything that jumps out as "wrong".

Oh, you should probably put an on_rez event ion state closed to throw execution back to state default in the unlikely case that the script is in state closed when you rez it.

Edited by Rolig Loon
  • Like 1
Link to comment
Share on other sites

1 minute ago, Rolig Loon said:

Your StartPos variable should set itself to llGetPos() in state_entry, but you might check to be sure that it is doing that.  If it believes SetPos == ZERO_VECTOR or someplace else that's more than 10m away, it might stall while trying to reach it.  If that's the problem, you may be able to figure out where it's getting the bad value for SetPos.  In any case, you should probably use llSetRegionPos to cover cases when the start position really is more than 10m away.

I'm really grasping at straws.  I don't see anything that jumps out as "wrong".

Oh, you should probably put an on_rez event ion state closed to throw execution back to state default in the unlikely case that the script is in state closed when you rez it.

I will try the regionPos. I even checked that it was not black listed by me. I did have an on_rezz but removed it to see what the heck the issue was.It is only a use very rarely hanger shuttle door but sheesh it is doing my head in.

Link to comment
Share on other sites

2 minutes ago, steph Arnott said:

It is only a use very rarely hanger shuttle door but sheesh it is doing my head in.

Unlikely, but is this part of a linkset? If so, it could fail to move if by doing so it exceeded the total limit of link separation. (This wouldn't explain the script actually halting, though; I only thought of it because "door".)

Link to comment
Share on other sites

1 minute ago, Qie Niangao said:

Unlikely, but is this part of a linkset? If so, it could fail to move if by doing so it exceeded the total limit of link separation. (This wouldn't explain the script actually halting, though; I only thought of it because "door".)

No, there is no need under the curcumstances. The friends ship is static.

Link to comment
Share on other sites

I got it!

Look at your llListen statement.  It says

1 hour ago, steph Arnott said:

llListen(10," ", NULL_KEY, "starboard");

so it will only listen for messages from something with name == " " (notice the blank space).  If you write it as

llListen (10, "", "", "starboard");

it will work.  😉

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

3 minutes ago, Rolig Loon said:

I got it!

Look at your llListen statement.  It says

so it will only listen for messages from something with name == " " (notice the blank space).  If you write it as

llListen (10, "", "", "starboard");

it will work.  😉

I can not believe it is a damned space. Thank you Rolig.

  • Like 1
Link to comment
Share on other sites

This is usable by anyone. I will point out that the loop is pushing the limit. In a sim with lag it is likely to stutter with twenty five and 0.2. It would have to be adjusted to suit. in that case.

//////////////////////////////////////////////////////////////////////////////////////////////////
// by Steph Arnott. 2018                                                                       ///
// NOTE: This script is licenced using the Creative Commons Attribution-Share Alike 3.0 license///
//////////////////////////////////////////////////////////////////////////////////////////////////
vector startPos;
float x = 0.2;//assigned veriables. chang to suit
float y = 0.0;
float z = 0.0;


default
{
	state_entry()
	{
		llSetMemoryLimit(llRound(llGetUsedMemory( ) * 1.10) );//no need for 64k. 10% added.
		llListen(2019,"", NULL_KEY, "port");//"port" can be whatever suits you
		startPos = llGetPos();
	}
	listen(integer channel, string name, key id, string message)
	{
		llSetPos(startPos);
		llTriggerSound("Machine_sound2", 1.0);//name these to whatever is your invent sound file is
		llSleep(1.5);
		llTriggerSound("tardis door", 1.0);
		integer i;
		do
		{
			llSetRegionPos(llGetPos()- <x,y,z>);
			llSleep(0.1);
		}
		while(++i < 25);//loop and add 0.2 twenty five times. change to suit for length object needs to move
		state closed;
	}
	changed(integer change)
	{
		if(change & CHANGED_OWNER)
			llResetScript();
	}
}
state closed
{
	state_entry()
	{
		llListen(2019,"", NULL_KEY, "port");
	}
	listen(integer channel, string name, key id, string message)
	{
		llTriggerSound("tardis door", 1.0);
		integer i;
		do
		{
			llSetRegionPos(llGetPos()+ <x,y,z>);
			llSleep(0.1);
		}
		while(++i < 25);
		llTriggerSound("Machine_sound2", 1.0);
		llSetRegionPos(startPos);
		state default;
	}
}

 

Edited by steph Arnott
changed it to conform with axis assignment
Link to comment
Share on other sites

5 hours ago, Wandering Soulstar said:

This is one reason that I declare a constant:


string EMPTY_SPACE = "";

and then use this constant wherever I need "", keeps these hard to find errors from happening 🙂

Would still have happened. It was a minor error that anyone could have done. I do not usually have it undefined but as the script was to help out a ST RP group it had to be simple. The contorted shape of the ships hanger door made it difficult  not to induce lag and that loop was the only way i could get around it. That made me complacent with a minor  pirece of code. And that monor piece of code payed me back in kind. BTW you are not declaring a constant.

Edited by steph Arnott
typo
Link to comment
Share on other sites

@steph Arnott

I realise that it is not a true constant as LSL does not provide that functionality. In coding though I treat it as such, i.e. by the fact that the variable name is in CAPS it means the value will not (should not) be changed once set the first time, i.e. in the header declarations. My point was that by declaring such a 'Constant' and then using it when we need to pass "" we ensure that we do not, by simple slip of the keys, pass a space by mistake.

On another note ... I noticed the following line in your code:

llSetMemoryLimit(llRound(llGetUsedMemory( ) * 1.10) );//no need for 64k. 10% added.

I understand that this limits the amount of memory the script is allowed to use, but not clear on what that means at the sim level? If I have a bunch of small scripts, which I know will not ever exceed a certain k of memory, does setting this 'free up' additional space on the server for other scripts?

Link to comment
Share on other sites

36 minutes ago, Wandering Soulstar said:

@steph Arnott

 


llSetMemoryLimit(llRound(llGetUsedMemory( ) * 1.10) );//no need for 64k. 10% added.

I understand that this limits the amount of memory the script is allowed to use, but not clear on what that means at the sim level? If I have a bunch of small scripts, which I know will not ever exceed a certain k of memory, does setting this 'free up' additional space on the server for other scripts?

Okay, well basically it asks the server to allocate an up usage limit. That allows the server to use the rest for other code. On a script that does not vary its memory usage it is a waste of valuable available resources. Most code in SL never exceeds 10k. The above script is set to 7k, that is 57k that can be used elsewhere. Times that 57 by a hundred that is ni on 5.5MB of dead usage. The server at stress levels will start dropping scripts run time. Though someone far smarter on server memory allocation would give better informed answer. Simply fact is that a door script does not need 64k allocted to the script.

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

Setting a memory limit could be helpful potentially in reducing your personal script load, in items in various attachments.  There's a lot of hype about people wearing dramatically high numbers of scripts.  Most of it is grossly overstated and has been used to shame people in busy regions unfairly.  It is true, however, that a region can take a significant performance hit as someone with a high script load teleports or walks in.  In some RP or combat areas, that hit can affect other players, so using llSetMemoryLimit may be wise.   That said, though, I very rarely use the function myself because most regions where I place scripts have a comfortable margin of free time and usable script memory.  I think that's probably true for most scripters.

Link to comment
Share on other sites

2 minutes ago, Rolig Loon said:

Setting a memory limit could be helpful potentially in reducing your personal script load, in items in various attachments.  There's a lot of hype about people wearing dramatically high numbers of scripts.  Most of it is grossly overstated and has been used to shame people in busy regions unfairly.  It is true, however, that a region can take a significant performance hit as someone with a high script load teleports or walks in.  In some RP or combat areas, that hit can affect other players, so using llSetMemoryLimit may be wise.   That said, though, I very rarely use the function myself because most regions where I place scripts have a comfortable margin of free time and usable script memory.  I think that's probably true for most scripters.

Retailers are the offenders, not average Jane or Joe.

Link to comment
Share on other sites

2 minutes ago, Rolig Loon said:

True.  There's plenty of opportunity for many people to get confused, or share the blame, or whatever.  This one's not very high on my personal list of serious scripting issues, but your mileage may vary.  😉

Well script counters only do number of scripts x 64k. Is not even valid information. And i really detest scanners, they have a usage but not for something like a simple door.

Link to comment
Share on other sites

@steph Arnott @Wandering Soulstar @Rolig Loon Regarding script memory usage and limiting it..

Script that run in Mono, which is the default mode, use a dynamic amount of memory at all times. A script with a memory limit of 64KB is actually using only the amount of memory it actually needs. (That is one of the big features of Mono, besides being faster and sharing their bytecode with other identical scripts.) Things like OBJECT_SCRIPT_MEMORY cannot find out how much memory a script is actually using, which is why all of the "script meters" (and Firestorm's Script Info) will give inflated results.

In LSO, the old script runtime, all scripts use 16KB of memory no matter how little code is in the scripts, like @steph Arnott  stated. The unused memory is "padded" with empty bytes and consumed from the sim.

I believe there is a benefit to setting memory limits, though. Whenever a script is rezzed or moved between regions, the script's active memory must be stored and transferred between the servers. For Mono scripts, this means calculating the exact amount of memory that needs to be sent and freed, because the memory space is dynamically sized. LSO scripts are much better in this regard, because they are a set size, continuous block of memory. LSO may be slow, and it has its advantages over Mono, but memory is not one of them.

Edited by Wulfie Reanimator
  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1948 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...