Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help Sensor Script

Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
03-14-2005 19:04
I need some help on a sensor. I want a prim to be able to when it bumps into something, know what the name of that is or something like that. Here's what I have so far. I'm new with sensors so it could all be wrong.

key player;

default
{
on_rez(integer start_params)
{
player = llGetOwner();
llInstantMessage(player, "Suit loaded";);
llRequestPermissions(player, PERMISSION_TAKE_CONTROLS);
}

state_entry()
{
}

control(key id, integer level, integer edge)
{
if (id == player)
{
llSensor("", NULL_KEY, SCRIPTED, 10, PI / 4);
}
}

sensor(integer detected)
{
llWhisper(0, "" + (string) detected + "";);
}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
}
}

this is for object to object interactions, not avatars, however an avatar wears the object with this script on it.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
03-14-2005 19:08
CODE
collision_start(integer total_number)
{
llWhisper(0,llDetectedName(0));
}
_____________________
---
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
03-14-2005 19:57
collision_start(integer detected)
{
if ( llDetectedName(0) == "Ladder";);
{
llWhisper(0, "ladder";);
llSetPos(<2.0,2.0,2.0>;);
}
}

I want it to move the object up when it comes in contact with an object named ladder
McWheelie Baldwin
Registered User
Join date: 9 Apr 2004
Posts: 154
03-15-2005 09:01
From: Douglas Callahan
collision_start(integer detected)
{
if ( llDetectedName(0) == "Ladder";);
{
llWhisper(0, "ladder";);
llSetPos(<2.0,2.0,2.0>;);
}
}

I want it to move the object up when it comes in contact with an object named ladder


If you're using this script in an attachment, you need to do something like this....

CODE

collision_start(integer detected)
{
if ( llDetectedName(0) == "Ladder");
{
llWhisper(0, "ladder");
llMoveToTarget(llGetPos() + <0, 0, 5>, 1.0);
llSleep(1.0);
llStopMoveToTarget();
}
}


Granted this is some really really basic code, and you would probably want to use at_target(), but this should get you going down the right path.

McW
_____________________