Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetPos

Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
04-30-2008 20:15
Hi all.

Hit another wall:) sensor is done and it works great. now I'm trying to make it where I can rez an object over the selected person's head.

I've worked with it and I can make it drop on my head no matter who I choose or it will make the attached prim, the script is in shoot up the z axis or when I have it as a HUD it will shoot off my screen to points unknown but still show as attached.

I've attached the part I'm working on, any help would be greatly appreciated.

Thx Lyndz



PHP
sensor(integer num)
{
list targets;
integer i;
if(num > 12)
num = 12;
for(i=0;i<num;i++)
{
if (llDetectedKey(i) != owner)

targets += [llGetSubString(llDetectedName(i), 0 ,23)];
}
llDialog(llGetOwner(),"Who gets to lick the Bowl?",targets,channel);
}

listen(integer channel, string name, key id, string vic)
{

llOwnerSay(vic +" gets to lick the bowl " + (string)(llDetectedPos(i) );
vector vicPos=llDetectedPos(i)+<0,0,1>;
while(llVecDist(llGetPos(), vicPos))
llSetPos(vicPos);




llRezObject("Bowl", vicPos ,ZERO_VECTOR,ZERO_ROTATION,0);


}

/PHP
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter."
—Dr. Seuss
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-30-2008 20:32
The llDetected*() functions don't work from 'listen' handlers. You'll have to use llGetObjectDetails() instead, probably keeping the target keys from the sensor event. That or remember all their positions as well. Remember too that you can only rez objects within 10m of the current object's position (for attachments, withing 10m of the wearer).
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
05-01-2008 08:07
I think you need to use llRezAtRoot if this script is attached or a HUD, too..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-02-2008 01:56
You have to perform a sensor sweep, and use llDetectedPos() inside the sensor. (Everyone pointed out what u did wrong, but not the solution... :) )
Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
05-02-2008 06:52
Thanks every one for your help, though I think I'm just as confused :D

From: Johan Laurasia
You have to perform a sensor sweep, and use llDetectedPos() inside the sensor. (Everyone pointed out what u did wrong, but not the solution... :) )


Johan I think I understand what you are saying but just to make sure I'm posting the full code so far, since I already have a Sensor sweep earlier, I don't know if that is what you mean or if I need another one.

php
//Bowl dropper


integer channel;
integer i;
string owner;
string targets;
string vic;
vector targetPos;

default
{
state_entry()
{
// Create random channel
channel= (integer)(llFrand(-1000000000.0));
owner = llGetOwner();
llListen(channel, "", llGetOwner(), targets);
}

touch_start(integer num_detected)
{
if (llDetectedKey(0) == llGetOwner())
{
llSensor("",NULL_KEY,AGENT,10,PI);
}
}

sensor(integer num)
{
list targets;
integer i;
if(num > 12)
num = 12;
for(i=0;i<num;i++)

{
if (llDetectedKey(i) != owner)
targets += [llGetSubString(llDetectedName(i), 0 ,23)];
}

llDialog(llGetOwner(),"Who gets to lick the Bowl?",targets,channel);
}

listen(integer channel, string name, key id, string vic)
{

llSay(0, vic +"gets to lick the bowl";);
vector targetPos=llDectedPos(i) + <0,0,3>;
while(llVecDist(llGetPos(),targetPos)>0.5)
llSetPos(targetPos);
llRezObject("Bowl", llGetPos(),ZERO_VECTOR,ZERO_ROTATION,0);

}
}



/php

Thanks Again
Lyndz~
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter."
—Dr. Seuss
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
05-02-2008 08:02
You can't use the llDetected stuff in a listen event, Lyndzay - it just doens't work. What you need is to do the sensor twice. Once to build a list of targets then again to find get the position of the victim..
From: Johan Laurasia
Everyone pointed out what u did wrong, but not the solution... :)

I'll take that as a challange..

How does this work, Lyndzay? I haven't tested it in-world but it should be close.
CODE

//Bowl dropper

integer gChannel;
string gVictim;

default
{
state_entry()
{
// Create random channel
gChannel = (integer)(llFrand(-1000000000.0));

llListen(gChannel, "", llGetOwner(), "");
}

changed(integer change)
{
if ((change & CHANGED_OWNER) != 0)
{
llResetScript();
}
}

touch_start(integer num_detected)
{
if (llDetectedKey(0) == llGetOwner())
{
gVictim = "";
llSensor("", NULL_KEY,AGENT, 10.0, PI);
}
}

sensor(integer num)
{
if(num > 12)
{
num = 12;
}

if (gVictim == "")
{
// don't have a victim yet - ask the owner to pick one
list targets;
integer i;

for(i = 0; i < num; ++i)
{
if (llDetectedKey(i) != llGetOwner())
{
targets = (targets = []) + targets + [llDetectedName(i)];
}
}

if (num != 0)
{
llDialog(llGetOwner(),"Who gets to lick the Bowl?", targets, gChannel);
}
else
{
llOwnerSay ("no targets found!!");
}
}
else
{
// found our victim.. move over him and drop a bowl
vector dest = llDetectedPos(0) + <0.0, 0.0, 3.0>;
vector norm = llVecNorm(dest - llGetPos());
float dist = llVecDist (llGetPos(), dest);

while (dist > 10.0)
{
llSetPos (norm * 9.0);
dist = llVecDist (llGetPos(), dest);
}

llSetPos (dest);

llRezObject ("Bowl", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, 0);

gVictim = "";
}
}

listen(integer channel, string name, key id, string vic)
{
// owner picked a victim from the menu. Do another sensor
// to find out where our target is
llSay(0, vic + "gets to lick the bowl");

gVictim = vic;

llSensor (gVictim, "", AGENT, 20.0, PI);
}
}
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
05-02-2008 08:43
From: Meade Paravane
You can't use the llDetected stuff in a listen event, Lyndzay - it just doens't work. What you need is to do the sensor twice. Once to build a list of targets then again to find get the position of the victim..

I'll take that as a challange..

How does this work, Lyndzay? I haven't tested it in-world but it should be close.

//Bowl dropper



***Winner Winner Chicken Dinner *** :D

Thanks Meade That works Great.
Does just what it's suppose to... but (there's always a but haha) after dropping the bowl the HUD disappears/or the prim Moves a some spot over the target avatar to drop the bowl.

SO... that makes me think I've been thinking about this all wrong... I guess I need to rez an invisaprim that would then go over the target ,drop the bowl then die. (which is what every body has probably been telling me HAHAHA)

Thanks for your Help I appreciate it and have learned a lot :D

~Lyndz
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter."
—Dr. Seuss