Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can I make a follower... follow a customer?

Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
08-25-2007 11:09
Hi all! Thanks tons for helping me earlier! I got it al working and now.. of course I want to add more. I don't kow why this isn't working. All the variables seem to be in place, and all of them return correct values accept for the avatars position. Does it not work this way? I probably am making it more complicated than it is... but no use in trying to modify one of my followers if I can't get a position with this code I've gotten working, but still can't get a position with it...

CODE

integer listPos; // Just to be sure I wasn't mising something... all main variables are now global.
vector targetPos;
integer channel = -10;
list avatarsDetected = [ ];
list keysDetected = [ ];
list posDetected = [ ];
string Gname;
string tool;
integer nextStep;
string nextAvatarName;
string nextAvatarKey;
vector nextAvatarPos;

string menuText = "Select the person to receive surprise coupon!!";

useKey(key targetKey)
{
//Just wanted to check my data, and lo and behold.. no targetPos...
llSay(0,(string)targetKey); //Returns valid key
llSay(0,(string)targetPos); //Returns <0,0,0> everytime no matter who you pick
llSay(0,(string)listPos); //Returns position in list (as far as I can tell it must be right since name and key match
llSay(0,Gname); //Returns correct name when clicked on Dialog Menu
//Since I got it working I thought it would be cool to rez a "coupon" next to a customer
//that would be of just whoever one randomly chose to be the lucky person that could get
//a full sale copy of an item in the store or something... kind of draw attention to things, etc.
//---You could even oversize your sale panel for a big effect ;) I really like this idea the more
//I thought on it....
}

default
{
state_entry(){
llListen(channel, "", llGetOwner(), "");
}

link_message(integer sender_num, integer num, string str, key id)
{
if (str == "GetCustomer"){
llSensor("", NULL_KEY, AGENT, 30, PI);
}
}

listen(integer channel, string name, key id, string message)
{
Gname = message;
listPos = llListFindList(avatarsDetected, (list)message);
targetPos = llList2Vector(posDetected, listPos);
useKey(llList2Key(keysDetected, listPos));
}

sensor(integer numDetected)
{
if (numDetected > 12) numDetected = 12;
avatarsDetected = [ ];
keysDetected = [ ];
posDetected = [ ];

for (nextStep = 0; nextStep < numDetected; nextStep++)
{
nextAvatarName = llDetectedName(nextStep);
nextAvatarKey = llDetectedKey(nextStep);
nextAvatarPos = llDetectedPos(nextStep);

if (llStringLength(nextAvatarName) > 24) nextAvatarName = llGetSubString(nextAvatarName, 0, 23);
avatarsDetected = (avatarsDetected=[]) + avatarsDetected + nextAvatarName;
keysDetected = (keysDetected=[]) + keysDetected + nextAvatarKey;
posDetected = (posDetected=[]) + posDetected + (string)nextAvatarPos;
}

llDialog(llGetOwner(), menuText, avatarsDetected, channel);
}
}


Basically, I've gone a step further now... I make little dragonflies and such and thought hey, how cool would it be if every so often one of the followers could "go" to a customer and rez the item they won, Say congratz and whatnot then die in a little poof of particles? I mean I think especially newcomers would get a HUGE kick out of that. (can you tell I am? lol) Anyway, if it's just not doable lemme know, but I figure if a follower can follow me, surely it could follow someone else if I already have their key and name?

C-ME!
-Hap
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
In case someone wants a GREAT follower script..
08-25-2007 11:17
In thanks for everyone helping out... this is the BEST follower script I have ever come accross just out of the blue and I use it in all of my little flyers... so for easy access.. here it is..

CODE


////////////////////////////////////////////////////////////////////////
// Open Shifting Float and Follow Script, by Foolish Frost. //
// From Open Basic Follower/Facing Script, by Logan Bauer. //
///////////////////////////////////////////////////////////////////////
// OFFSET is the position of your pet in relation to it's owner's position.
// For example, in the default setting below, "vector offset =<-1,0,1>;"
// I.E. (x,y,z), the -1 puts it 1m back behind owner, the 0 means don't have
// it stay left or right, and 1 means have it stay 1m above it's owner.
// So, if you wanted the script to make it follow directly in front of you,
// and to the left, then you would change it to "vector offset =<1,1,0>;"


// llFrand(float max)

vector offset =<-.5,-1,1>;
vector currentoffset =<0,0,0>;
float xshift =.2; //How far it roams forward and back.
float yshift =1.25; //How wide it roams left to right.
float bob =2; //multiplyer of the BobCycle listed below.
float shifttime =5; //average time it takes to shift to another XY position.
integer timeset=0; //Is the timer running?
float currentxshift =0; //current X shift position
float currentyshift =0; //current Y shift position
float currentyfacing =0; //currentyfacing storage
integer currentbob; //current state of the BobCycle
float bobbing =0; //bob storage
list BobCycle = [0.0, 0.08, 0.12, 0.14, 0.15, 0.14, 0.12, 0.08, 0.0, -0.08, -0.12, -0.14, -0.15, -0.14, -0.12, -0.08];


startup()
{
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z,TRUE);
llSetStatus(STATUS_PHYSICS, TRUE);
key id = llGetOwner();
llSensorRemove();
llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,.5);
}

default
{
state_entry(){
startup();
}

on_rez(integer start_param){
startup();
}

sensor(integer total_number) {
vector pos = llDetectedPos(0);
bobbing = llList2Float(BobCycle, currentbob)*bob;
llSetTimerEvent(llFrand(shifttime));
currentoffset = <currentxshift, currentyshift, bobbing>;
llMoveToTarget(pos+(offset+currentoffset)*llDetectedRot(0),.3);

if (currentyshift>=0){currentyfacing = currentyshift;}
else {currentyfacing = currentyshift*-1;}

llLookAt(pos+<0,0+(currentyfacing*.33),1+bobbing>, 1 , 2);
currentbob = currentbob +1;

if (currentbob == 16){currentbob = 0;}
if(timeset==0){
timeset = 1;
llSetTimerEvent(((llFrand(shifttime)+llFrand(shifttime)+llFrand(shifttime))/3)*2);
}
}

timer(){
timeset = 0;
currentyshift = llFrand(yshift*2)-yshift;
currentxshift = llFrand(xshift*2)-xshift;
}
}



Thanks again!
-Hap
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
08-25-2007 11:46
Note that with:
From: someone
posDetected = (posDetected=[]) + posDetected + (string)nextAvatarPos;
a string gets appended to posDetected, but with
From: someone
targetPos = llList2Vector(posDetected, listPos);
a vector is supposed to come out. Suggest trying either without the ";(string)" typecast, or changing to "targetPos = (vector)llList2String(posDetected, listPos);".
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
08-25-2007 12:08
/me feels a sense of déjà-vu :p
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
And yet again... I owe it to the forums :)
08-25-2007 12:11
Indeed it was the combination of both!

I was under the impression that I HAD to use string infromation in lists or it would balk, and regardless that if I did have it go in as string information, I should at least be able to pull it out as vector information... (I had tried to pull it out as vector before once)

Very interesting, I can use that information well for many other things... like the little tour bot I wanted to make for our land - it has my gf store and my own, along with some nice areas just to wander around in - will be much nicer with a notecard and list reader rather than editing the script every time I want to change it... very nice!!

Thanks a mint!
- Hap
Bill Schmo
Registered User
Join date: 16 Aug 2006
Posts: 53
ok great idea.. but everyone wants more, lol
12-27-2007 11:56
i tweaked the script a lil tryin to make it do what a friend requested, but it went to heck in a handbasket so i deleted all my jibberish. its sorta like your coupons he wants to be able to have it rez suprise Gift (normaly 100L$ or less) that will stay right infront of an AV for 30sec (might be to little time, I'll work that out later).. and they have to click it quick enough to get it, lol. the boxed gift prim isnt a problem, nor the timer, nor the move to pos. but the selection of what Gift to give is a problem, for me anyway.. the hud will be filled with all sorts of items and will be removed and replaced very often so it needs to use llGetInventory to make the second dialog..

basicly the hud needs to work like this:
1. click the hud button
2. select an AV
3. select a Gift
4. rez the gift infront of the AV that was selected (the gift box has the 30sec timer)

Thanx in advance everybody =)

///////////////////////////////////////////////////////////////////////////////////////////
//// Gift Giver Hud

integer listenPRIMS; // Prim comm listen on/off switch
integer PRIMCHAN = 12345; // Prim comm channel

integer listenDialog; // Dialog comm listen on/off switch
integer DialogCHAN; // Dialog comm channel

integer listPos;
vector targetPos;

list avatarsDetected = [ ];
list keysDetected = [ ];
list posDetected = [ ];
string Gname;
string tool;
integer nextStep;
string nextAvatarName;
string nextAvatarKey;
vector nextAvatarPos;

string menuText = "Select the person to receive a gift!!";

useKey(key targetKey)
{

llOwnerSay((string) targetKey); //Returns AV's key
llOwnerSay((string) targetPos); //Returns AV's Pos
llOwnerSay((string) listPos); //Returns position
llOwnerSay((string) Gname); //Returns correct name when clicked on Dialog Menu

llListenControl(listenPRIMS, TRUE); // Turns on the Prim Comm Channel

}


default
{
state_entry()
{
DialogCHAN = 10 + (integer)llFrand(100000);
listenDialog = llListen(DialogCHAN, "", llGetOwner(), "";);
listenPRIMS = llListen(PRIMCHAN, "", llGetOwner(), "";);
llListenControl(listenDialog, FALSE);
llListenControl(listenPRIMS, FALSE);

}


listen(integer DialogCHAN, string name, key id, string message)
{
Gname = message;
listPos = llListFindList(avatarsDetected, (list)message);
targetPos = (vector)llList2String(posDetected, listPos);
useKey(llList2Key(keysDetected, listPos));
}

touch_start(integer duration)
{

llSensor("", NULL_KEY, AGENT, 500, PI);
llListenControl(listenDialog, TRUE);
}

sensor(integer numDetected)
{
if (numDetected > 12) numDetected = 12;
avatarsDetected = [ ];
keysDetected = [ ];
posDetected = [ ];

for (nextStep = 0; nextStep < numDetected; nextStep++)
{
nextAvatarName = llDetectedName(nextStep);
nextAvatarKey = llDetectedKey(nextStep);
nextAvatarPos = llDetectedPos(nextStep);

if (llStringLength(nextAvatarName) > 24) nextAvatarName = llGetSubString(nextAvatarName, 0, 23);
avatarsDetected = (avatarsDetected=[]) + avatarsDetected + nextAvatarName;
keysDetected = (keysDetected=[]) + keysDetected + nextAvatarKey;
posDetected = (posDetected=[]) + posDetected + (string)nextAvatarPos;
}

llDialog(llGetOwner(), menuText, avatarsDetected, DialogCHAN);
}
}

///////////////////////////////////////////////////////////////////////////////////////

edit: it also needs to give a notecard or landmark to the AV it places the gift box infront of, that shouldnt be a big deal either, just would use llGiveInventory for that