Files
LSL-Scripts/Script Tests/Script tests/Object/KanEd-Test12.lsl
Fred Beckhusen 3c57d863af Sync
2019-03-21 14:35:28 -05:00

62 lines
1.7 KiB
Plaintext

// :SHOW:
// :CATEGORY:Scripting
// :NAME:Script Tests
// :AUTHOR:Justin Clark-Casey (justincc)
// :KEYWORDS:Opensim
// :CREATED:2019-03-18 23:44:21
// :EDITED:2019-03-18 22:44:21
// :ID:1116
// :NUM:1933
// :REV:1
// :WORLD:Opensim
// :DESCRIPTION:
// One of many tests for Opensim
// :CODE:
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
}
}
}
}