Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////////////////
- // //
- // Script made by Kadai Flanagan //
- // //
- // For use with the VLC Train Script 2.6.0 //
- // //
- // This is an experimental implementation, so be fair. //
- // //
- // If you come with any modification or enhancement, //
- // please share it with everyone. //
- // //
- // //
- // Last Revised 12-January-2011 //
- // //
- // //
- ///////////////////////////////////////////////////////////////
- string MACHINE_NAME = "Maquina";
- string FOLLOW_GUIDE = "Guide";
- vector lastmachinepos = <0,0,0>;
- integer WE_KNOW_POS = FALSE;
- integer RE_RAIL_WAGON = TRUE;
- integer DESTINE_RAIL = FALSE;
- string locationrecived = "";
- rotation wagonrotation = ZERO_ROTATION;
- //vector vDestine = <0,0,0>;
- LocomotiveMoveTo(vector vWaypointNext, rotation rAttitudeNext)
- {
- //llOwnerSay((string)vWaypointNext);
- //vector vWaypointNext = vWaypointNext + <0, 0, 0.5>;
- if (llGetStatus(STATUS_PHYSICS))
- {
- //llSay(0, (string)llGetVel());
- llRotLookAt(rAttitudeNext, 1 / llVecMag(llGetVel()), 1);
- llMoveToTarget( vWaypointNext, 1.0);
- }
- else
- {
- llSetLinkPrimitiveParamsFast(LINK_ROOT,
- [PRIM_POSITION, vWaypointNext,
- PRIM_ROTATION, rAttitudeNext]);
- }
- } // LocomotiveMoveTo
- default
- {
- state_entry()
- {
- vector pos = llGetPos();
- llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
- llSleep(0.1);
- llSensor(FOLLOW_GUIDE, NULL_KEY, PASSIVE | ACTIVE, 20.0, PI);
- llListen(-16,MACHINE_NAME,"","");
- llListen(-15,MACHINE_NAME,"","");
- //llGetObjectDetails();
- }
- sensor(integer total_number)
- {
- if (RE_RAIL_WAGON){
- vector pos = llDetectedPos(0);
- wagonrotation = llDetectedRot(0);
- vector offset = <0,0,0.5>;
- pos+=offset;
- LocomotiveMoveTo(pos, wagonrotation);
- //llOwnerSay((string)llDetectedPos(1));
- RE_RAIL_WAGON = FALSE;
- }
- }
- listen(integer channel, string name, key id, string message)
- {
- if(channel==-16){
- if(DESTINE_RAIL != FALSE){
- //llOwnerSay("--Ajuste--" + (string)vDestine);
- RE_RAIL_WAGON = TRUE;
- llSensor(FOLLOW_GUIDE, NULL_KEY, PASSIVE | ACTIVE, 20.0, PI);
- }
- //vDestine = (vector)message;
- DESTINE_RAIL = TRUE;
- }
- if(DESTINE_RAIL && channel==-15){
- locationrecived = message;
- //vector nuevolocationrecived = (vector)locationrecived;
- if (WE_KNOW_POS == FALSE){
- lastmachinepos = (vector)locationrecived;
- WE_KNOW_POS = TRUE;
- //llOwnerSay("Entre");
- } else {
- //falta = distancia-movimiento;
- //vector calculateddistance = vDestine-llGetPos();
- //llOwnerSay("Distancia: " + (string)distancia);
- vector movement = (vector)locationrecived-lastmachinepos;
- vector newposition = llGetPos()+movement;
- //vector nuevapos = distancia-movimiento;
- lastmachinepos = (vector)locationrecived;
- //llOwnerSay("Movimiento: " + (string)movimiento);
- LocomotiveMoveTo(newposition, wagonrotation);
- }
- }
- }
- on_rez(integer iRezParameter)
- {
- llResetScript();
- } // on_rez
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement