Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Elevators (fixed pose)

DS2K Gasser
Registered User
Join date: 17 Sep 2006
Posts: 7
01-30-2007 00:54
First off I like to say I script coding is all greek to me :)

I'm tying to make a lift that can carry more then one person at a time.

So far I using Ingie Bach script (thanks mate)

/54/4c/58432/1.html

and twig it abit, but as the lift goes up and down the av 'walks'
How to do make them stand (without asking)??
as I wish to use the impatient pose

so far I added.
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
llStartAnimation("impatient";);

I get the 'do you want' menu but even if I say yes it this doesn't work.
do I have to put a wait until permission is given loop in somewhere??
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-30-2007 02:23
From: DS2K Gasser
First off I like to say I script coding is all greek to me :)

I'm tying to make a lift that can carry more then one person at a time.

So far I using Ingie Bach script (thanks mate)

/54/4c/58432/1.html

and twig it abit, but as the lift goes up and down the av 'walks'
How to do make them stand (without asking)??
as I wish to use the impatient pose

so far I added.
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
llStartAnimation("impatient";);

I get the 'do you want' menu but even if I say yes it this doesn't work.
do I have to put a wait until permission is given loop in somewhere??



You need to handle the runtime_permissions event and start the animation at that point.

leave your request where it is and then add a new event handler
This needs to be in the same state but not inside any existing event.

CODE

run_time_permissions(integer perm)
{
PlayAnimation("impatient");
}
DS2K Gasser
Registered User
Join date: 17 Sep 2006
Posts: 7
01-30-2007 17:50
From: Newgate Ludd
You need to handle the runtime_permissions event and start the animation at that point.

leave your request where it is and then add a new event handler
This needs to be in the same state but not inside any existing event.

CODE

run_time_permissions(integer perm)
{
PlayAnimation("impatient");
}


I'm sorry I don't understand what the { and } do??

Let me see if I understand

llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); (ask permisson)
{ (wait for yes/no??)
llStartAnimation("impatient";); (run pose)
} (next step??)
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
01-30-2007 18:34
I can't comment on the logic, but I assume this is the way to go

CODE

//Elevator Script

vector start_pos;
default
{
state_entry()
{
llSetStatus (STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE);
start_pos=llGetPos();
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(start_pos,1.5);
key id ="";
llListen(3,"",id,"");//choose a different channel for your elevator to listen to other than 0, which would be "audiable" I chose 3 here
}

listen(integer a, string n, key id, string m)
{
vector move_pos;
if (m=="two")//This is for the second floor level
{
move_pos=start_pos+<0,0,1>;//exparament to set the hight just right, usually around 6 meters per floor, but of course that can very, plus you want to get it just right.
llMoveToTarget(move_pos,0.2);//this is set so that the elevator does not colide with the floor (and cause it to wiggle, giggle and jerk)
}
if (m=="three")//this is the third floor
{
move_pos=start_pos+<0,0,2>;//This would normally be set around 12 meters. The settings could also be set for sideways elevators, like on the Enterprise ;P go to exact locations!
llMoveToTarget(move_pos,0.2);
}
if (m=="one")
{
llMoveToTarget(start_pos,0.2);//we go home here to where the elevator was created or the script was started.
}

llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);


}

run_time_permissions(integer perm)
{
PlayAnimation("impatient");
}



}
DS2K Gasser
Registered User
Join date: 17 Sep 2006
Posts: 7
01-30-2007 19:52
ok this is how I have the script so far.

//Elevator Script

vector start_pos;
vector pos;
default
{
state_entry()
{
llSetStatus (STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE);
start_pos=llGetPos();
pos=start_pos;
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(start_pos,1.5);
key id ="";
llListen(3,"",id,"";);
}
listen(integer a, string n, key id, string m)
{
vector move_pos;
if (m=="main";)
{
move_pos=start_pos+<0,0,5>;
}
if (m=="roof";)
{
move_pos=start_pos+<0,0,10>;
}
if (m=="ground";)
{
move_pos=start_pos;
}
if (pos!=move_pos)
{
llMoveToTarget(move_pos,5);;
pos=move_pos;
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
run_time_permissions(integer perm)
{
PlayAnimation("impatient";);
}
}
}

I add 'pos' so if I press the floor its on it will not move
now when I goto save I get (37,8) : ERROR : Syntac error
which is the run_time_permissions(integer perm) line.

also PlayAnimation("impatient";); doesn't seem to be a command??
Dogthinker Lemmon
Registered User
Join date: 26 Dec 2006
Posts: 5
01-30-2007 21:40
You need another } before the run_time_permissions line

I believe PlayAnimation("impatient";); should actually be llStartAnimation("impatient";);

I think you will then need to remove a } from the end, but it's hard to tell as your code isn't tabbed.


EDIT: yeah, so the last few lines should look something like this:

CODE

llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
}
run_time_permissions(integer perm)
{
llStartAnimation("impatient");
}
}
DS2K Gasser
Registered User
Join date: 17 Sep 2006
Posts: 7
01-30-2007 23:13
Well it still don't seem to work as the lift don't wait for a yes/no anyway.
and seeing it's still being pushed (I want to be able to more more then one person)
I just have to live with the walking

I heard of something called llpush, will that do want I want??

I'm at lest leaning abit about scripting :)
DS2K Gasser
Registered User
Join date: 17 Sep 2006
Posts: 7
Waiting for set time??
01-31-2007 00:44
ok seeing I have to live with the "walking" as the lift move,
I stated to work on the next step.

I want the lift to call out the floor it goes to once it get to it

Now I set the movement for 2.5 sec
How to a set it so it will wait the 2.5 sec before it call's out the floor??

CODE

if (pos!=move_pos)
{
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(move_pos,2.5);;
pos=move_pos;

(I tried to add)..
{
llSetTimerEvent(2.5);
}

timer()
{
llOwnerSay(m);
..
}
}
}



I get a error a the timer line.

Do I have to enter a new state or something??
If so how and how I get my to the old one without reset it??
Or am I going about this the wrong way??

Should I use for/next to move the lift abit at a time.
Then add the say command after??
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-31-2007 01:32
Sorry PlayAnimation is one of my own functions that stops any running animation before playing the new one.

Your AV will always walk unless you make them sit on the lift, this is a side effect of the way the physics engine works. You AV is trying to stay in place but as the platform moves it is being 'pushed' around slightly and triggers the walk animation.

I also apologise for assuming you understood a bit more about how LSL states and events work, I had thought my explanation reasonably clear.

When you fire of the llRequestPermissions you are then basically in limbo until SL gets around to showing your AV the dialog box and you press a button. Only at this point will you get a responce. It could be a second, it could be a few minutes or it could never happen. Think of it as Posting a letter to yourself, you've no idea when it will arrive.

run_time_permissions is an event handler, it is a function call that will automatically be called on receipt of the dialog responce (you have mail!) and as such is totally outside of the sequence of your existing code.

The reason your lift isnt waiting for the yes/no is simply because it isnt being told to.

You're using an open listen which is a little bit poor, your lift doesnt need to listen until it is being used. I'd either change it to a touch activated item or may be use collision detect. Either way you can limit the time the listen is active and hence the amount of sim resources you are using.

Your code also doesnt try to stop the animation its starts.

Here's a newgy version, totally untested....

CODE

//Elevator Script

list Floors = ["ground","main","roof"]; // Floor names
list Offsets = [ 0, 5, 10 ]; // Z offsets, not really needed since all at 5m intervals

vector start_pos;
vector pos;
vector move_pos;

integer Listening = 0;
integer listenchannel = 0;

integer targetID;

ShowMenu(key id)
{
string text = "Lift Menu\nPlease Select a Floor";
UpdateListen(id);
llDialog(id,text,Floors,listenchannel);
}

UpdateListen(key id)
{
CancelListen();
listenchannel = - (integer)llFrand(2147483648);
Listening = llListen(listenchannel,"",id,"");
llSetTimerEvent(30);
}

CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}

default
{
state_entry()
{
llSetStatus (STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE);
start_pos=llGetPos();
pos=start_pos;
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(start_pos,1.5);
}

touch_start(integer num_detected)
{
key id = llDetectedKey(0);
ShowMenu(id);
}

timer()
{
CancelListen();
}

listen(integer channel, string name, key id, string message)
{
CancelListen();
integer index = llListFindList(Floors,[message]);
if (index >= 0)
{
integer x = llList2Integer(Offsets,index);
move_pos=start_pos;
move_pos.z += x;
if (pos != move_pos)
{
llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
}
}
}

run_time_permissions(integer perm)
{
llStartAnimation("impatient");
targetID = llTarget( move_pos, 0.1 );
llMoveToTarget(move_pos,5);
}

at_target( integer number, vector targetpos, vector ourpos )
{
llStopMoveToTarget();
if(targetID)
{
llStopAnimation("impatient");
llTargetRemove(targetID);
targetID = 0;
}
pos = llGetPos();
}
}
DS2K Gasser
Registered User
Join date: 17 Sep 2006
Posts: 7
01-31-2007 02:14
*Look's up as something just flew over my head"

Sorry Newgate but that was just way over my head.

I can only just understand the script I been using.
What you make is just to complex for me.
Forget about the pose for now.

What I want is for the lift to say "open" on channel 3 once is get to the floor
(once it has make all the way.)

That way the door will open (I set it to open on hearing "open" on channel 3)
(more on the door once I get the lift working)

Only thing is it say this as soon so the lift starts to move.
I want it to wait until it stops moving before it says 'open'

Also I read about emailing, why is that better then just saying/listening??
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-31-2007 02:59
From: DS2K Gasser
*Look's up as something just flew over my head"

Sorry Newgate but that was just way over my head.

I can only just understand the script I been using.
What you make is just to complex for me.
Forget about the pose for now.

What I want is for the lift to say "open" on channel 3 once is get to the floor
(once it has make all the way.)

That way the door will open (I set it to open on hearing "open" on channel 3)
(more on the door once I get the lift working)

Only thing is it say this as soon so the lift starts to move.
I want it to wait until it stops moving before it says 'open'

Also I read about emailing, why is that better then just saying/listening??


Ahhh sorry :( .
Which bits have you confused?

The 3 functions I defined are purely to handle the dialog box,
ShowMenu - Shows the dialog box to the user
CancelListen - Remove any existing listener
UpdateListen - Creates a new Listen

In side the default state we have the following event handlers
state_entry - Your initialisation code
touch - Used to activate the dialog when touched
timer - used to Auto cancel the listen after 30 seconds
listen - Used to process the dialog input
run_time_permissions - Used to request to start the animation and start the lift moving.
at_target - Used to stop the animation when we reached the target floor.

Rather than have multiple if's I've used a simple list look up to decide which floor we are going to and calculate the offset.

I do notice a problem in my code, if the user says no to the animation then the lift wont move!

You havent posted your script but i'm willing to bet you have something like this

CODE

llMoveToTarget(move_pos,5);
llSay(3,"Open");


You're requesting a move to the target position over 5 seconds and then immediately saying Open. Try this instead


CODE

llMoveToTarget(move_pos,5);
llSleep(5.5);
llSay(3,"Open");



chat based communications are limited by distance, 10m for a whispher, 20m for Say and 100m for chat. Email on the other hand has no distance limit but does impose a time penalty.
DS2K Gasser
Registered User
Join date: 17 Sep 2006
Posts: 7
01-31-2007 05:05
ok so far I using the following

CODE

//Elevator Script

vector start_pos;
vector pos;
default
{
state_entry()
{
llSetStatus (STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE);
start_pos=llGetPos();
pos=start_pos;
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(start_pos,1.5);
llSetStatus(STATUS_PHYSICS,FALSE);
key id ="";
llListen(3,"",id,"");
}
listen(integer a, string n, key id, string m)
{
vector move_pos;
if (m=="Main")
{
move_pos=start_pos+<0,0,10>;
}
if (m=="Roof")
{
move_pos=start_pos+<0,0,20>;
}
if (m=="Ground")
{
move_pos=start_pos;
}
if (pos!=move_pos)
{
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(move_pos,2.5);;
pos=move_pos;
llSleep(2.5);
llSay(3,"Open");
if (m=="Roof")
{
llSay(0,m+" Floor");
}
else
{
llSay(0,m+" Floor");
}
llSetStatus(STATUS_PHYSICS,FALSE);
}
}
}


Not I'm going to try to link the doors,
open when the life comes,
close as it goes.

After which the hard part, putting a lock on the outside call buttons
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-31-2007 05:41
A couple of more things for you, I promise not to be too confusing :).
Several workable locks in the library or scattered through the forums. But since you are hard coding your listen as channel 3 anyone can use the lift at anytime just by typeing /3Roof, by passing the buttons you are going to create.

Your best bet is to lock the lift not the buttons, i.e. the button sends the key of the user to the lift which then validates authority. Use Keys not names as anyone can fake a name if they can guess the name of any authorised user. Again this is why Touch rather than chat is best.

I still think you would be better of using a list but if not at least use Else if's

CODE


if (m=="Main")
{
move_pos=start_pos+<0,0,10>;
}
else if (m=="Roof")
{
move_pos=start_pos+<0,0,20>;
}
else if (m=="Ground")
{
move_pos=start_pos;
}