//Redesign of the Moving Ship Script (also by Derek Jones)
//Revised by Kaihn Fhang to fix all compiling errors 11/22/2012
//Script to move non-physical objects via control inputs
//idk why it dont work please someone fix it
//Original Script created by Derek Jones on 08/05/03
//Variations by Jericho Powers, Christopher Omega and Nick Fairlight
//Newly Modified Version created 6/24/04
//Say "Engage" to start the script, "Disengage" to stop, and click the object for control. Say "stop" to stop all movement.
//Some code has been edited out for the open source release, including speed, which was controlled by other objects in my custom ship
//To use, drop on any object, preferably one with no rotation for best effect.
rotation grot; //The current Rot
rotation gtarrot; //Destination rot (steps)
vector gcurpos; //Current position
vector gtopos; //Target position
vector increment = <1, 0, 0>; //Forward steps per interval
vector increment2 = <0, 0, 1>; //Steps for vertical movement per interval
float interval = 0.1; //Time between steps
key gowner; //Key of pilot (used for recodnizing the owner from another)
string copilot; //Name of co-pilot
vector currentpos; //Vector currently located
vector setposz; //Vertical increment going up
vector setposaz; //Vertical increment going down
string speed; //The Speed Setting
integer LEVELS = 0; //Levels (duh lol)
default
{
state_entry()
{
?
gowner=llGetOwner();//gowner is default as the owner.
copilot = ""; //Fill the name of the co-pilot
//llMessageLinked(LINK_SET, 0, speed, "a");
state enginesoff;
}
}
state enginesoff
{
state_entry()
{
llReleaseControls();
llSay(0, "Engines offline.");
llListen(0, "", gowner, "");
llListen(0, copilot, "", "");
}
listen(integer channel, string name, key id, string message)
{
if(message=="Engage")
{
llSay(0, "Script engaging...");
state engineson;
}
}
}
state engineson
{
state_entry()
{
LEVELS = CONTROL_FWD | CONTROL_BACK? ? | CONTROL_UP | CONTROL_DOWN | CONTROL_LEFT | CONTROL_RIGHT;
speed = "Default Speed: No Control";
llSay(0, "Script on and idle");
//llSay(0, "Speed set to "+speed);
llListen(0, "", gowner, "");
llListen(0, copilot, "", "");
?
}
?
touch_start(integer total)
{
integer perms = llGetPermissions();
if((llDetectedKey(0)==gowner))
{
if (perms)
{
llReleaseControls();
}
else
{
llRequestPermissions(llDetectedKey(0), PERMISSION_TAKE_CONTROLS);
}
if((llKey2Name(llDetectedKey(0))==copilot))
{
?
perms = llGetPermissions();
if (perms)
{
llReleaseControls();
}
else
{
llRequestPermissions(llDetectedKey(0), PERMISSION_TAKE_CONTROLS);
}
}
}
} ?
run_time_permissions(integer perm)
{
if (perm == PERMISSION_TAKE_CONTROLS)
{
llSay(0, "Permissions granted.");
//speed = "Default Speed";
//llMessageLinked(LINK_SET, 0, "Speed: "+speed, "a");
llTakeControls(LEVELS, TRUE, FALSE);
}
else
{
state engineson;
}
}
?
listen(integer channel, string name, key id, string message)
{
if(message == "stop")
{
llSay(0, "Halting movement...");
llSetTimerEvent(0);
}
if(message == "Disengage")
{
llSay(0, "Script Shutdown Beginning");
llSleep(3);
llResetScript();
}
?
//if(message=="Default Speed"){
// llSay(0, "Switching to default speed of ship");
//speed = "Default Speed";
//llMessageLinked(LINK_SET, 0, "Speed: "+speed, "a");
//increment = <1,0,0>;
//increment2 = <0, 0,1>;
//interval = .10;
//}
?
//if(message=="Low Speed"){
// llSay(0, "Switching to lowest speed of ship");
//speed = "Low Speed";
//llMessageLinked(LINK_SET, 0, "Speed: "+speed, "a");
//increment = <.1,0,0>;
//increment2? = <0, 0,.1>;
//interval = .20;
//}
//if(message=="High Speed"){
// llSay(0,"Switching to highest speed of ship");
//speed = "High Speed";
//llMessageLinked(LINK_SET, 0, "Speed: "+speed, "a");
//increment = <3,0,0>;
//increment2? = <0, 0,3>;
//interval = .10;
//}
//if(message=="Ludicrus Speed"){
//? llSay(0, "Sir, we've never gone that fast before. I'm not sure if the ship can take it! Ah hell I'll do it anyways :-p");
//speed = "Ludicrus Speed";
//llMessageLinked(LINK_SET, 0, "Speed: "+speed, "a");
//increment = <10,0,0>;
//increment2? = <0, 0,10>;
//interval = .1;
//}
//if(message=="superup")
//{
//? currentpos=llGetPos();
//llSay(0,"The ship will now go to the set height of 477 Meters. Please sit down and remained seated until notified to get up.");
//llSleep(2);
//state superup;
//}
//if(message=="Default Level")
//{
// currentpos=llGetPos();
//setposaz=<currentpos.x, currentpos.y, llGround(llGetPos())>+<0, 0, 50>;
//llSay(0, "The ship will now go to the height of "+(string)setposaz.z+" Meters. ");
//llSleep(2);
// state defaultlevel;
//}
//if(message=="Water Level")
//{
//currentpos=llGetPos();
//setposz=<currentpos.x, currentpos.y, llWater(llGetPos())>+<0, 0, 9.018>;
//llSay(0, "The ship will now go to the height of "+(string)setposz.z+" Meters. Please sit down and remained seated until notified to get up.");
//llSleep(2);
//state waterlevel;
//}
?
?
}
control(key id, integer level, integer edge)
{
if(level & CONTROL_FWD)
{
llSetTimerEvent(0);
llSay(0, "Cruising Forward");
increment.x = llFabs(increment.x);
llSetTimerEvent(interval);
}
if(level & CONTROL_BACK)
{
llSetTimerEvent(0);
llSay(0, "Cruising Backward");
increment.x = -1*llFabs(increment.x);
llSetTimerEvent(interval); ?
}
if(level & CONTROL_UP)
{
llSetTimerEvent(0);
llSay(0, "Increasing Altitude");
state goingup; ?
?
}
if(level & CONTROL_DOWN)
{
llSetTimerEvent(0);
llSay(0, "Decreasing Altitude");
state goingdown;
}
if(level & CONTROL_LEFT)
{
llSetTimerEvent(0);
llSay(0, "Shifting Left");
integer i = 0;
while(i<9)
{
grot = llGetRot();
gtarrot = grot*<0.00000, 0.00000, 0.08716, 0.99619>;
llSetRot(gtarrot);
i++;
}
}
if(level & CONTROL_RIGHT)
{
llSetTimerEvent(0);
llSay(0,? "Shifting Right");
integer i = 0;
while(i<9)
{
grot = llGetRot();
gtarrot = grot*<0.00000, 0.00000, -0.08716, 0.99619>;
llSetRot(gtarrot);
i++;
}
}
}
?
?
?
?
timer()
{
grot = llGetRot();
gcurpos = llGetPos();
gtopos = increment*grot + gcurpos;
llSetPos(gtopos);
}
?
?
}
//state superup
//{
// state_entry()
//{
//? llSetTimerEvent(.1);
// }
//timer()
//{
//? if(llGetPos()!=<currentpos.x, currentpos.y, 477>)
//{
//llSetPos(<currentpos.x, currentpos.y, 477>);
// }
//else if(llGetPos()==<currentpos.x, currentpos.y, 477>)
//? {
//llSay(0, "It is now safe to stand up.");
//? ? ? llSetTimerEvent(0);
// state engineson;
//}
//}
//}
//state defaultlevel
//{
//? state_entry()
// {
//? ? ? llSetTimerEvent(.1);
// }
//timer()
//{
//? if(llGetPos()!=setposaz)
// {
// llSetPos(setposaz);
//}
//else if(llGetPos()==setposaz)
//? {
//llSay(0, "Reached height");
//llSetTimerEvent(0);
// state engineson;
//}
//}
//}
//state goingup
//{
// state_entry()
//{
//? increment2.z = llFabs(increment2.z);
// llSetTimerEvent(interval);
// llListen(0, "", gowner, "");
// llListen(0, copilot, "", "");
//}
//listen(integer channel, string name, key id, string message)
//{
//? ? if(message=="status")
// {
//? ? vector currentpos=llGetPos();
//llSay(1431, "We are currently located at "+(string)currentpos.x+" -- "+(string)currentpos.y+" -- "+(string)currentpos.z+".");
//llSleep(1);
//}
//if(message=="stop"){
//? ? ? ? llShout(1431, "Stopping altitude increasment");
//? ? llSetTimerEvent(0.0);
// state engineson;
//}
//}
// timer()
//{
//? ? grot = llGetRot();
//gcurpos = llGetPos();
//gtopos = increment2*grot + gcurpos;
//llSetPos(gtopos);
//}
//}
//state goingdown
//{
// state_entry()
//{
//? llListen(0, "", gowner, "");
//llListen(0, copilot, "", "");
// increment2.z = -1*llFabs(increment2.z);
//llSetTimerEvent(interval);
//}
//listen(integer channel, string name, key id, string message)
//{
?
//? if(message=="status")
// {
//? vector currentpos=llGetPos();
//llSay(1431, "We are currently located at "+(string)currentpos.x+" -- "+(string)currentpos.y+" -- "+(string)currentpos.z+".");
//llSleep(1);
//}
//else if(message=="stop")
//{
//? ? ? ? llShout(1431, "Stopping altitude decreasment");
//? llSetTimerEvent(0.0);
// state engineson;
//}
//}
?
//timer()
//{
//? ? grot = llGetRot();
// gcurpos = llGetPos();
//gtopos = increment2*grot + gcurpos;
//llSetPos(gtopos);
//}
//}
//state waterlevel
//{
//? state_entry()
//{
//? llSetTimerEvent(.1);
// }
// timer()
//{
//? if(llGetPos()!=setposz)
// {
//llSetPos(setposz);
//}
// else if(llGetPos()==setposz)
//? ? ? {
//llSay(0, "It is now safe to stand up.");
//? ? ? llSetTimerEvent(0);
// state engineson;
//}
//}
//}