Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Phys based Prim Placement XYZ Script

TXGorilla Falcone
KWKAT Planetfurry DJ
Join date: 4 May 2004
Posts: 176
04-11-2005 13:18
Ok I know I just requested a non phys placement script just friday but I now need something to go heigher than 500z
I know that Phys elevators can go to the height I need... Wich is roughly 750z
can anyone make me a script that I can tell it the XYZ that I need it to go to that is phys based?
Also need it to be phantom when moveing
I believe this is how I would like the script to work

<REZ>
Phantom on------>Can be cut out possably
Physics on------>Can be cut out possably
Move to XYZ
Physics off
Phantom off
Script off

Yet agine this is to be used in a sandbox on a large build of sorts and I have the ground work of the Rezzing scripts done already... just need the stupid parts to go heigher than 500z to 750z

EDIT: To save trouble I can have prim Phys and Phantom set to start with at rez so we can cut out both if needed
_____________________
Drunken Monkeys danceing on the tables.
Falling from the sky just like in a fable.
TXGorilla Falcone
KWKAT Planetfurry DJ
Join date: 4 May 2004
Posts: 176
04-11-2005 14:57
ok after a bit of searching I think I got a script we can work from

I know that what I am lookin for is basicly gonna be an elevator script
I just dont need all the commands/touch to start it and text saying all the stuff out loud
all I need it to do is when rezzed go to the designated XYZ and stop all functions leaveing the prims its in... in its spot and able to walk on

think anyone can eather modify this or build the script I need?

From: someone

// Shack's Ferry Script
// Version 0.1
//
// Copyright 2004 Shack Dougall
//
// Licensed under the Apache License, Version 2.0 (the "License";);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// DATE: 12-28-2004

// DESCRIPTION: The prim containing this script will move to position1 the
// first time that it is touched. Thereafter, touching it will cause it to
// ferry between position1 and position2.

// Position1 and Position2 can be anywhere in the same sim, but there must
// be an unobstructed, straight-line path between them. However, there is
// no limit to how high or how far apart the points are. This script is not
// limited to up/down or left/right motion. Any two points will work.

// NOTE: Unattached objects disappear above z=4096. Also, the script uses
// physics, so mass/energy limitations apply. That is, the prim containing
// this script will not move if it does not have sufficient energy to move
// both itself and anything standing on it.
// It uses llMoveToTarget, so the prim should be at least as massive as
// everything else it is moving. But if it is too massive, then it won't
// have enough energy to move the mass.

// If you have problems, experiment with small unattached prims first.

// You could modify this to use llSetPos instead of llMoveToTarget if you
// would prefer a different set of limitations :)

// *********************************************
// YOU MUST SET THE TWO POSITION VARIABLES!

vector position1 = ZERO_VECTOR;
vector position2 = ZERO_VECTOR;

// for example, < X, Y, Z >
// vector position1 = <10, 10, 50>;
// vector position2 = <20, 20, 60>;

// *********************************************

// YOU MAY PLAY WITH THE VARIABLES BELOW

//Small TAU means faster movement. min: 0.032 good: > 0.2
//STEP_SIZE is the amount of distance that we will try to travel with one
//call to llMoveToTarget. Necessary because llMoveToTarget
//damps to the current position if this distance is > 64m.
float TAU = 2.0;
float STEP_SIZE = 63.0;

//STEP_TARGET_RANGE is how close to a move target we go before
//we issue a new move target. The idea is that we don't want to slow down
//too much, so we set a new target before we get to the first one.
float STEP_TARGET_RANGE = 10.0;

// &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// DON'T TOUCH ANYTHING BELOW THIS UNLESS YOU KNOW WHAT YOU'RE DOING ;-)
// danger Will Robinson

// where we are going
vector destCoords;

integer NULL_TARGET = -1;

//targetID is the ID returned by the last call to llTarget if one is active.
integer targetID = NULL_TARGET;

//Vector of length STEP_SIZE that points in the direction
//we want to go. Add this to the current position to get the coords of
//where we want to go next to get us closer to our goal.
//Calculated at the start and cached for use during the trip.
vector deltaVector;

init()
{
if (position1 == ZERO_VECTOR || position2 == ZERO_VECTOR)
{
llSay(0, "You must set the values of both: position1, position2.";);
return;
}
llStopMoveToTarget();
llSetStatus(STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS _ROTATE_Z,FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);
llMoveToTarget(llGetPos(), TAU);

llSay( 0, "Touch me to make me move.";);
}

//Removes the llTarget. Does nothing with movement.
clearTarget()
{
if (targetID != NULL_TARGET)
{
llTargetRemove( targetID );
targetID = NULL_TARGET;
}
}

//Returns the displacement vector between two coordinates.
//That is, returns the vector you need to add to the start location to get the
//destination location.
vector calcDeltaVector( vector destPos, vector startPos )
{
vector coordsDelta = destPos - startPos;

return coordsDelta;
}

//Stores our destination and calculates the initial deltaVector that will
//get us there.
setDestination( vector newCoords )
{
clearTarget();

// get current position info and store dest info
vector currCoords = llGetPos();
destCoords = newCoords;

// Calculate the total displacement vector
// then, normalize it to get a unit vector (vector of length 1)
// then, multiply it by the STEP_SIZE to get a displacement vector of
// length STEP_SIZE
deltaVector = calcDeltaVector(destCoords, currCoords);
deltaVector = STEP_SIZE * llVecNorm(deltaVector);
}

//Returns the distance to between two coordinates.
float distance( vector startCoords, vector destCoords )
{
vector curDelta = calcDeltaVector(destCoords, startCoords);
return llVecMag(curDelta);
}

// low-level workhorse of movement.
// It calls llMoveToTarget to move us and llTarget to detect when we are there.
// Each call to this function moves us a distance of STEP_SIZE toward our
// eventual destination. Don't call this directly.
moveToNextTarget()
{
vector nextTargetCoords;

vector currCoords = llGetPos();
float distToDestination = distance( currCoords, destCoords );

if (distToDestination > STEP_SIZE) {
nextTargetCoords = currCoords + deltaVector;
} else {
nextTargetCoords = destCoords;
}

targetID = llTarget( nextTargetCoords, STEP_TARGET_RANGE );
llMoveToTarget( nextTargetCoords, TAU );
}

toggleDestination()
{
vector newDest;
if( destCoords == position1 )
newDest = position2;
else
newDest = position1;

setDestination( newDest );
}

default
{
state_entry()
{
init();
}

touch_start(integer total_number)
{
toggleDestination();
moveToNextTarget();
}

at_target( integer targetID, vector targetPos, vector ourPos )
{
float distanceToDestination = distance( ourPos, destCoords );
integer nearDestination = distanceToDestination <= STEP_TARGET_RANGE;
if (! nearDestination)
{
clearTarget();
moveToNextTarget();
}
}

}
_____________________
Drunken Monkeys danceing on the tables.
Falling from the sky just like in a fable.
TXGorilla Falcone
KWKAT Planetfurry DJ
Join date: 4 May 2004
Posts: 176
Bump
04-13-2005 11:59
Ok that script dident quite work as well as planed...
Can anyone please help me out with a what I can simply can puy it a:

Physics Elevator that moves to a given XYZ Cord. when rezzed.
Needs to go up to 750z while phantom from 500z and turns off phantom and dosent move any more.

reason Phantom is needed so the pieces dont bump each other
_____________________
Drunken Monkeys danceing on the tables.
Falling from the sky just like in a fable.
TXGorilla Falcone
KWKAT Planetfurry DJ
Join date: 4 May 2004
Posts: 176
Bump and update
04-13-2005 16:23
Ok I have been talking to Tiger Crossing via IM and Im quite shure this will be needed

llSetPrimitiveParams([PRIM_POSITION, <128, 128, 750>]);

I just need to get this as a phys mover that will stay in place when done now... at least I am in a step in the right direction...

also will try another method but not happy with it becouse I cant just add items to my rezzer and set the cords where needed
_____________________
Drunken Monkeys danceing on the tables.
Falling from the sky just like in a fable.
TXGorilla Falcone
KWKAT Planetfurry DJ
Join date: 4 May 2004
Posts: 176
a frustrated bump
04-14-2005 16:08
Guah! This is getting on my nerves... all the lil scrpts I got eather have quit working or when they attempt to go up they fall back down and spaz out...

I guess I will have to go back to usen the Rezzer idea... just have to make it spawn the whole thing from 1 object from the rezzer in the correct spot and send that up manualy however much I hate that Idea... please I really dont wana have to do that
Here me beg scripters I know your out there
_____________________
Drunken Monkeys danceing on the tables.
Falling from the sky just like in a fable.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-14-2005 19:38
Well... answering one's own questions makes it hard for us to post. :D

Let's see... physical movement to a location... that's easy.

CODE
vector location = <128,128,128>; // Place local or global location here
float speed = 3; // Speed of placement
integer global = FALSE; // Is this global? Set it or the script can automatically.

default
{

touch_start(integer total_number)
{
if(location.x > 256 || location.y > 256 || location.z > 256) // If location is too large
global = TRUE; // Try a global so we don't loop forever

llSetTimerEvent(0.2); // Fire up the timer
llMoveToTarget(llGetPos(),0.3); // Move here to start
llSetStatus(STATUS_PHYSICS | STATUS_PHANTOM, TRUE); // Set our states:
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
}

timer()
{
llSetTimerEvent(0.2); // Refresh timer just in case
if((global && llVecMag(llGetPos() + llGetRegionCorner() - location)) || (!global && llVecMag(llGetPos() - location))) // Lots of gibberish saying:
{ // We're close enough.
if(global) llMoveToTarget(location - llGetRegionCorner(),0.3); // Go there
else llMoveToTarget(location,0.3);

llSleep(2);
llSetStatus(STATUS_PHYSICS | STATUS_PHANTOM, FALSE); // Set our states:
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llStopMoveToTarget(); // Stop the movement
llSetTimerEvent(0.0);
}

else // We're not there yet
{ // Move closer based on where we are
if(global) llMoveToTarget(llGetPos() + (llVecNorm(location - llGetPos() + llGetRegionCorner()) * speed),0.3);
else llMoveToTarget(llGetPos() + (llVecNorm(location - llGetPos()) * speed),0.3);
}
}
}

Anyway, that's the simpler version. This is untested, so it may have an error or two.
_____________________
---
TXGorilla Falcone
KWKAT Planetfurry DJ
Join date: 4 May 2004
Posts: 176
delayed responce
04-18-2005 18:23
*blush* Sorry about the delay... TY for the script. It works on sum of the smaller objects but cant use it on the full structure... I found a way to get it up there thou. TY agine and I have learned dum stuff from it in the process
_____________________
Drunken Monkeys danceing on the tables.
Falling from the sky just like in a fable.