Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

test whether an object is a light source

Para Actor
Registered User
Join date: 15 May 2009
Posts: 12
05-17-2009 23:21
From: Jesse Barnett
Are you allowed to script the barrier objects?


I don't know ... I guess so ... what good would that do me?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-18-2009 03:10
From: Para Actor
I don't know ... I guess so ... what good would that do me?

you'd automatically know where they are, because they could pass their positions and sizes to the object that needs to navigate around them.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
05-18-2009 03:33
I was playing with this some yesterday. Not meaning to help you cheat but hoping this might give a couple of options to you. Btw it is a fun project. The left/right algorithm works when hitting a barrier but the direction to turn needs some more work:

CODE

integer target;
vector robotPos;
float timeToTarget;
vector tempTargetVec;
vector lightSourcePos;
vector startPos;
//Follow the bouncing ball

default {
state_entry() {
llSetStatus(STATUS_PHYSICS,FALSE);
llSetStatus(STATUS_ROTATE_X |STATUS_ROTATE_Y, FALSE);
}
touch_start(integer n) {
startPos = llGetPos();
llSetStatus(STATUS_PHYSICS,TRUE);
//1 find the object named lightSource
llSensor("lightSource", "", PASSIVE, 96.0, PI);
}
sensor(integer tn) {
//2 Found the lightSource
lightSourcePos = llDetectedPos(0);
target = llTarget(lightSourcePos, 0.1);
llLookAt(lightSourcePos, 0.1, 1);
timeToTarget = llVecDist(llGetPos(), lightSourcePos)/4;
//3 Moving towards the lightSource
llMoveToTarget(lightSourcePos, timeToTarget);
}
collision_start(integer tn) {
//4 Bumped into something
llTargetRemove(target);
llStopMoveToTarget();
//5 If we bumped into the lightSource then we are finished
if(llDetectedName(0) == "lightSource"){
llOwnerSay("WooHoo!");
llSetStatus(STATUS_PHYSICS,FALSE);
//This is just for the benefit of troubleshooting and is not necessary
while(llVecDist(llGetPos(), startPos) > 0.1)
llSetPos(startPos);
}
}
else{
//6 Ooops it was not the lightSource we bumped into
robotPos = llGetPos();
list bBox = llGetBoundingBox(llDetectedKey(0));
vector bBoxPos = llDetectedPos(0);
vector bBoxMin = bBoxPos + llList2Vector(bBox, 0);
vector bBoxMax = bBoxPos + llList2Vector(bBox, 1);
//7 This tells which was is the closest, left or right
if (llVecDist(bBoxMin, robotPos) <= llVecDist(bBoxMax, robotPos)) {
vector norm = llVecNorm(bBoxMin);
if(norm.x >= norm.y){
//The logic is wrong here. This only works right moving in two directions
norm = <0,1,0>;
}
else{
norm = <1,0,0>;
}
tempTargetVec = robotPos - norm;
}
else {
vector norm = llVecNorm(bBoxMin);
if(norm.x >= norm.y){
norm = <0,1,0>;
}
else{
norm = <1,0,0>;
}
tempTargetVec = robotPos + norm;
}
llLookAt(tempTargetVec, 0.1, 1);
target = llTarget(tempTargetVec, 0.1);
//8 Trying to move around the barrier
llMoveToTarget(tempTargetVec, 1.0);
}
}
at_target(integer targetInt, vector targetPos, vector currentPos) {
//9 the spot defined above to move around the barrier
llTargetRemove(target);
llStopMoveToTarget();
target = llTarget(lightSourcePos, 0.1);
llLookAt(lightSourcePos, 0.1, 1);
timeToTarget = llVecDist(llGetPos(), lightSourcePos)/4;
//10 Back on course to the lightSource
llMoveToTarget(lightSourcePos, timeToTarget);
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
1 2