Change font size
It is currently Sat Feb 16, 2019 8:42 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 3   [ 21 posts ]
Go to page 1, 2, 3  Next
Author Message
 Post subject: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Sun Feb 08, 2015 6:40 pm 

Joined: Wed Dec 05, 2012 3:56 pm
Posts: 34
SCRIPTED BY Takni Miklos and Edited by Cuteulala Artis

UPDATED UPDATED UPDATED
THE PROPER UP TO DATE SCRIPTS FOR THE ROLLER COASTER HAS NOW BEEN FIXED AND ADDED HERE
LISTENS ON CHANNEL 12121212 CHANGE IT TO WHAT YOU LIKE IN THE LISTENER SCRIPT!
Impotent: Not Authorized for second life import or ANY commercial grid that deals with monetary income! Using this in a commercial grid is illegal and breaking the term and service for free use.

MAIN ENGINE:

// Scripted By Takni Miklos And Edited By Cuteulala Artis Do Not Remove Credits
// normal speed is beat 0.1 -- step 2
// ' turbo ' is step 4 -- it derails a lot

float beat = 0.05; // adjusting this below 0.05 (even below0.1) seems to have no effect
float step = 2.3 ; // can adjust this up to 4 meters, normal is 2 meters

string track="TrackYellow";//Name of the track it needs to follow

integer REVERSED=128712;
integer GEAR = 8363123;
integer ALIGN = 1290812;
integer START=7979237;
integer STOP=711237;
integer SETHOME=18271897;
integer GOHOME=18271122;
integer COME=182723;

vector home; rotation homerot;

lm(integer i, string s, key k)
{
if(REVERSED==i)
{
direction*=backward;
if(1)state rerailing;
}
else if(START==i)
{
stop_after_rerail=0;
if(1)state rerailing;
}
else if(SETHOME==i)
{
home=llGetPos();
homerot=llGetRot();
}
else if(COME==i)
{
vector p = llList2Vector(llGetObjectDetails(k,[OBJECT_POS]),0);
/*
if(

llList2String(llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_NAME]),0)
==
llList2String(llGetParcelDetails( p ,[PARCEL_DETAILS_NAME]),0)

)
{
*/
// while(llVecDist(llGetPos(),p)>0.01)
// {
llSetRegionPos(p);
// }
// llSetRot( direction*homerot );
llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POSITION,p,PRIM_ROTATION, direction * homerot ]);
if(1)state stopped;
// }
}
else if(GOHOME==i)
{
while(llVecDist(llGetPos(),home)>0.01)llSetPos(home);
llSetRot(direction*homerot);
if(1)state stopped;
}
else if(STOP==i)
{
if(1)state stopped;
}
else if(ALIGN==i)
{
stop_after_rerail=1;
if(1)state rerailing;
}
else if(GEAR==i)
{
float f=(float)s;
if(f<0.1)return;
if(f>4)return;
step = f ;
scanradius=6+1.5*step;
}
}

float scanangle=0.6; // half-angle of the scan cone
float scanradius; // 6 more than the minimum distance for target guide (1.5*step)
float rerailradius=30; // distance to look for the nearest track.

integer stop_after_rerail;

//d(string s){if(testing)llSay(0,s);}

rotation nextrot;
vector nextpos;
rotation backward=<0,0,1,0>;
rotation forward;
rotation direction ;

move()
{
vector rel=nextpos-llGetPos();
float distance=llVecMag(rel);
/*
idea here is : pos(t) = pos (0) + vel * t + 1/2 a * t * t ;
*/
float t = distance / step * beat ; // time needed to get to next track
float fraction = step / distance;// same as beat / t
rotation g=llGetRot();
vector forward = llRot2Fwd( g ) ;
vector pos = llGetPos()
+ step*forward
+ ( rel - distance*forward ) *fraction * fraction ;
rotation a = g ; a.s = - a.s; // same as a=<0,0,0,1>/llGetRot();
rotation relrot = a * nextrot ; // now llGetRot() * relrot == nextrot
float angle = llRot2Angle(relrot) ;
vector axis = llRot2Axis(relrot) ;
// if(angle>PI){axis*=-1;angle=TWO_PI-angle;} // workaround for osgrid bug: no longer needed
llSetLinkPrimitiveParamsFast(LINK_THIS,[
PRIM_POSITION,pos
,PRIM_ROTATION, g * llAxisAngle2Rot(axis,angle*fraction)
]);
}

default
{
state_entry()
{
home=llGetPos();
llSetText("",<1,1,1>,1);
scanradius=6+1.5*step;
direction=forward;;
string s=llStringTrim(llGetObjectDesc(),STRING_TRIM);
if(s)track=s;
state stopped;
}
}

state running
{
link_message(integer wh, integer i, string s, key k) { lm(i,s,k); }

state_entry() { llSensorRepeat(track,"",ACTIVE|PASSIVE, scanradius ,scanangle, beat); }

on_rez(integer x) { llResetScript(); }

sensor(integer x)
{
integer i;
for(;i<x;++i)
{
if ( llVecDist( llDetectedPos(i),llGetPos() ) > 1.5*step )
{
nextrot=direction*llDetectedRot(i);
nextpos=llDetectedPos(i);
move();
return;
}
}
llOwnerSay("bad track");
state stopped;
}

no_sensor( ){ state stopped;}
}

state stopped
{
link_message(integer wh, integer i, string s, key k){ lm(i,s,k); }
state_entry() { stop_after_rerail=0; }
on_rez(integer x) {llResetScript(); }
}

state rerailing
{
link_message(integer wh, integer i, string s, key k) { lm(i,s,k); }

on_rez(integer x) { llResetScript(); }

state_entry(){ llSensor(track,"",ACTIVE|PASSIVE, rerailradius ,PI); }

sensor(integer x)
{
nextrot=direction*llDetectedRot(0);
nextpos=llDetectedPos(0);
llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POSITION,nextpos,PRIM_ROTATION,nextrot]);
if(llVecDist(llGetPos(),nextpos)<0.01)
{
if(stop_after_rerail) state stopped;
state running;
}
// d("align didnt get exactly on target - trying to sensor again");
llSensorRepeat(track,"",ACTIVE|PASSIVE, rerailradius ,PI,0.2);
}

no_sensor( )
{
llSensorRemove();
llOwnerSay("No '"+track+"s' nearby. Rez some!");
}
}







LISTENER SCRIPT:



integer REVERSED=128712;
integer GEAR = 8363123;
integer ALIGN = 1290812;
integer START=7979237;
integer STOP=711237;
integer SETHOME=18271897;
integer GOHOME=18271122;
integer COME=182723;

integer N;

integer running;

default
{
state_entry()
{
N=llGetNumberOfPrims();
llListen(1212121212, "", "", "");
}

timer()
{
llSetTimerEvent(0);
llMessageLinked(LINK_THIS, GOHOME, "" ,"");
}

listen(integer total_number, string n, key k, string m)
{
if(llGetOwner()!=llGetOwnerKey(k))return;
// if(llGetAgentSize(k)); else return;
if("sethome"==m)llMessageLinked(LINK_THIS, SETHOME, "" ,"");
else if("come"==m)llMessageLinked(LINK_THIS, COME, "" ,k);
else if("start"==m)
{
running=1;
llMessageLinked(LINK_THIS, START, "" ,"");
}
else if("gohome"==m)
{
running=0;
llMessageLinked(LINK_THIS, GOHOME, "" ,"");
}
else if("stop"==m)
{
running=0;
llMessageLinked(LINK_THIS, STOP, "" ,"");
}
else if("align"==m)llMessageLinked(LINK_THIS, ALIGN, "" ,"");
else if("reverse"==m)llMessageLinked(LINK_THIS, REVERSED, "" ,"");
else if("gear"==llGetSubString(m,0,3))
{
llMessageLinked(LINK_THIS, GEAR, llStringTrim(llDeleteSubString(m,0,3),STRING_TRIM) ,"");
if(0==running)
{
running=1;
llMessageLinked(LINK_THIS, START, "" ,"");
}
}
else return;
llSetTimerEvent(300);
}

changed(integer what)
{
if(what & CHANGED_LINK)
{
if( N < llGetNumberOfPrims() ) // if anyone new sat on us
{
//llSay(0,"type start / stop");
}
N=llGetNumberOfPrims();
}
}
}


Last edited by Cuteulala Artis on Fri Apr 10, 2015 2:42 pm, edited 5 times in total.

Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Mon Feb 09, 2015 12:44 pm 

Joined: Thu Feb 07, 2013 3:39 pm
Posts: 15
Sweet gift!

Thanks Cuteulala, always been envious of how smooth your roller coasters work :)


Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Thu Feb 19, 2015 9:29 am 
Furious Typer

Joined: Tue Mar 06, 2012 3:57 pm
Posts: 102
Hello,

done : http://vartown-grid.ddns.net:8002/

:lol: :lol: :lol:


Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Wed Mar 04, 2015 12:00 am 

Joined: Mon Nov 24, 2008 5:14 pm
Posts: 10
Thanks Cuteulala, I can't wait to try to build my own coaster, but I'm not sure how to start. I would love it if you would provide some basic instructions, just enough to get me started.


Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Thu Mar 05, 2015 5:08 pm 

Joined: Mon Nov 24, 2008 5:14 pm
Posts: 10
Hi Cuteulala,

I made some progress, Yay!
I built an ugly test track and added a taurus with both scripts.
The listener script seems to have a syntax error on line 51: "channel=0x7fffffff-2*(integer)llFrand(2.1e9)-(integer)llFrand(2e5);".
If I comment out the line, the scripts run, but I'm pretty sure that commenting out the line breaks something. I can use the menu to set home positions and to go to the home positions, but nothing else.
I've been Googling for 2 days, but have not found any useful information.


Brittany


Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Thu Mar 05, 2015 5:40 pm 

Joined: Thu Feb 07, 2013 3:39 pm
Posts: 15
change the last part from llFrand(2e5); to llFrand(2.0e5);
That should do the trick for the script.


Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Thu Mar 05, 2015 7:08 pm 

Joined: Mon Nov 24, 2008 5:14 pm
Posts: 10
Thanks Fearghus! I can't wait to give it a try. Any other tips?


Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Fri Mar 06, 2015 5:01 pm 

Joined: Wed Dec 05, 2012 3:56 pm
Posts: 34
All scripts here shouldn't syntax unless something pasted wrong i will check it


Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Sun Mar 08, 2015 12:31 pm 

Joined: Wed Dec 05, 2012 3:56 pm
Posts: 34
Fearghus McMahon that wa sa good catch and its odd that it did synthax considering its been working forever lol i will update it!


Top
 Profile  
 
 Post subject: Re: ROLLER COASTERS FOR EVERYONE!!!!!
PostPosted: Sun Mar 08, 2015 2:25 pm 

Joined: Mon Nov 24, 2008 5:14 pm
Posts: 10
Thanks again Cuteulala, the scripts seem to work, but now what? Besides setting and going to home positions, how does it work? What makes it go? How do I change speeds (up hills, down, etc.)?
I know that you don't want to write a tutorial, but now you've got me so excited. I just have to build a working coaster. Just a few more hints please.

XOXO,
Brittany


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 3   [ 21 posts ]
Go to page 1, 2, 3  Next


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net