Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scripting problems. :(

Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
01-16-2006 06:41
I am a crap scripter, and I have come up against a problem which to me seems to have no obvious solution. Well, two problems, actually. :) I wonder whether someone here will be able to help.

The script concerned is an elevator program, and in essence it takes the following form:-

vector temp;
integer speed = 0;

move(integer speed);
{
temp=llGetPos()+<0.0,0.0,speed>;
llMoveToTarget(temp,0.1);
}


Listen on channel

Accept input

If command for elevator to ascend
Set non-physical
Position elevator platform
Set physical


while(temp.z < 747)
{
if(temp.z < 40)
{
speed=1;
move(speed);
}

more stuff here if higher than 40

} end of while

} end of listen


What actually happens when the script is run is that the elevator ascends fine, with temp.z being incremented as it is supposed to be. Then the command to go down is given, and the program executes the second half, which brings it down again. The script then loops around the listen, waiting for input.

If an instruction to ascend is then given, what appears to happen is that temp.z in the move section becomes local. It is incremented within the move, but when execution goes back to the while it keeps the value it had before the call to move. And the elevator just sits there.

That is one problem.

The other is that I had various llSay commands to give me running displays throughout the script. Suddenly these stopped working at the beginning of the script, and only appear when it is halfway through. The prim which houses the script is 10x10x0.2. If I make a wooden cube and put the script in there, all the displays start working correctly, but when I transfer it back into the larger prim they do not.
I have tried copying the large prim and putting the script in there, but it made no difference.

Those are the problems which have been occupying my every waking moment. :) If anybody has any suggestions (apart from giving up scripting) I would be grateful.

_____________________
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
01-16-2006 06:58
The two speed variables are ambiguous and confusing... the parser may be being stupid (I wouldn't be surprised)...

Secondly, try llOwnerSay() instead of llSay(). It may be more reliable.
Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
01-16-2006 08:08
Not sure I understand your first comment because there is only one speed variable: integer speed.

Thanks for the tip about llOwnerSay; I'll give that a try. :)
_____________________
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
01-16-2006 15:50
Selador, what I mean is how you have one speed variable in the first few lines, and another one that's passed to the function. These are not the same variables.
Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
01-16-2006 17:24
It is *supposed* to be the same variable. I thought it was defined in the second line, passed to a function in the third line and used in the if in the bulk of the program.

What have I done wrong?
_____________________
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
01-16-2006 17:32
http://secondlife.com/badgeo/wakka.php?wakka=scope

Try setting the global "speed" variable to something like 3, then calling the function with 2. Observe the results.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
woops, sorry, my bad....
01-16-2006 22:22
Yeah, so you'd better replace your no parameter custom function, such as move();.

DELETED...Aha, sorry, I deleted here I wrote because I found this was my misunderstood. :p
From: Selador Cellardoor
The prim which houses the script is 10x10x0.2. If I make a wooden cube and put the script in there, all the displays start working correctly, but when I transfer it back into the larger prim they do not.
hmm.. not enough energy? See llMoveToTarget
_____________________
:) Seagel Neville :)
Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
01-17-2006 04:27
From: Keknehv Psaltery
http://secondlife.com/badgeo/wakka.php?wakka=scope

Try setting the global "speed" variable to something like 3, then calling the function with 2. Observe the results.


Ok, I did that, and 2 was passed to the function successfully, which is what I would have expected.
_____________________
Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
01-17-2006 04:29
From: Seagel Neville
Yeah, so you'd better replace your no parameter custom function, such as move();.

DELETED...Aha, sorry, I deleted here I wrote because I found this was my misunderstood. :p hmm.. not enough energy? See llMoveToTarget



Not sure I understand what you mean here. move() has to take a variable, because the speed changes as the elevator accelerates.
_____________________
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
01-17-2006 09:29
From: Selador Cellardoor
Not sure I understand what you mean here. move() has to take a variable, because the speed changes as the elevator accelerates.
Yes, but you'd already taken a variable to change speed as "integer speed;" at the first few lines. And I thought if you changed the value, it would be put into the variable and work in the custom function, too.
If you would take the custom function's one rather than global one, remove global one and you don't have to assign "speed" previously. And you could write like this.

move(1);

I belive that this is your function's way to describe.

But this is not the point of your trouble, you know.
_____________________
:) Seagel Neville :)
Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
01-18-2006 03:21
Yes, of course I could call the function with a literal - there's no reason why not, and it will definitely save a bit of space. So I will do that. Thank you.

No, as you say, it's not that which is causing the problem. I have no idea what is. I have reached the point where I have no more ideas, except one.

I have been assuming that temp.z, as part of temp, does not need to be globally declared. I wonder whether that is a false assumption. That is something else I will try.

Many thanks for taking the trouble to try to help. :)
_____________________
Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
01-18-2006 03:38
Ok - update.

Of course, I couldn't declare temp.z as a global variable because clearly it is a special variable pointing to part of a vector.

Ok, I have changed the script variable, and as I have now changed the coding I think I will start another thread, in case something occurs to anybody else.

Many thanks for your help.
_____________________