blob: eaa885b7f32d5933063da070879750a6d738e0b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
vector startPosition;
float groundLevel;
default
{
state_entry()
{
// get permission to take over the avatar's control inputs.
llRequestPermissions( llGetOwner(), PERMISSION_TAKE_CONTROLS );
startPosition = llGetPos();
groundLevel = llGround( startPosition );
}
run_time_permissions( integer perm ) // event for processing
// permission dialog.
{
if ( perm & PERMISSION_TAKE_CONTROLS ) // permission has been given.
{
// go ahead and take over the forward and backward controls.
llTakeControls( CONTROL_FWD | CONTROL_BACK, TRUE, FALSE );
}
}
control( key id, integer held, integer change ) // event for processing
// key press.
{
vector position = llGetPos();
if ( change & held & CONTROL_FWD )
{ // the "move forward" control has been activated.
if( position.z < (startPosition.z + 10.0) )
{
llSetPos( llGetPos() + < 0, 0, 1.0 >); // move up
}
}
else if ( change & held & CONTROL_BACK )
{ // the "move backward" key has been activated.
if( position.z > groundLevel + 1.0 )
{
llSetPos( llGetPos() + < 0, 0, -1.0 >); // move down
}
}
}
}
|