Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Looking for a *very* simplified HUD for offering to hug

Clintok Meyer
Registered User
Join date: 28 Apr 2006
Posts: 17
01-30-2007 11:47
I received a very nice and very complicated open source one but it has too many scripts to follow what's going on.

All I want to do is this ;)

1) /hug "name" if that's the easiest way to do it.
2) Have the script send an IM/message of some kind, saying I'm offering a hug and giving them the option of accepting or not.
3) If they say yes (who doesn't want a hug?) it would trigger one animation for my Avatar and one (but different) for them. The key is my animation can't be the exact same as their animation since I'm initiating the hug.

I will cheerfully offer my finished product (complete with animations and for free of course) to anyone or everyone who can assist me with a very simple working script and who'd like like yet another Hug HUD.

Thank you
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-01-2007 02:42
From: Clintok Meyer
I received a very nice and very complicated open source one but it has too many scripts to follow what's going on.

All I want to do is this ;)

1) /hug "name" if that's the easiest way to do it.
2) Have the script send an IM/message of some kind, saying I'm offering a hug and giving them the option of accepting or not.
3) If they say yes (who doesn't want a hug?) it would trigger one animation for my Avatar and one (but different) for them. The key is my animation can't be the exact same as their animation since I'm initiating the hug.

I will cheerfully offer my finished product (complete with animations and for free of course) to anyone or everyone who can assist me with a very simple working script and who'd like like yet another Hug HUD.

Thank you



As stated in this thread HUD's are nothing more than prims stuck to an attachment point thats specified as HUD attachment point.

Grab hold of one of the freebie HUG's that are open source, there are a few running around SL, try YadNi's. that will give you the scripts, all you will need to do is replace the animations.

not sure why you want it to be HUD though as you are specify /hug xxx ....
Clintok Meyer
Registered User
Join date: 28 Apr 2006
Posts: 17
02-01-2007 06:10
From: Newgate Ludd
As stated in this thread HUD's are nothing more than prims stuck to an attachment point thats specified as HUD attachment point.

Grab hold of one of the freebie HUG's that are open source, there are a few running around SL, try YadNi's. that will give you the scripts, all you will need to do is replace the animations.

not sure why you want it to be HUD though as you are specify /hug xxx ....


Thanks for the response however, it wasn't helpful. I have, as I stated above, a free source HUD and I understand how they work conceptually and also understand a lot of the script in it.

What I asked for and perhaps I confused you, was a "simpler example". I want to see the code that does this:

Ask a person a question and get their response. If they say 'yes' animate them and then animate me.


Telling me to go look at a thread or grab another person's hug doesn't answer my question, but maybe someone else will read this and kindly (as has been done in other threads) cut out and paste the X lines of code that will do what I want.

Hopefully someone, maybe not here, will post a simpler example from which I can expand.

The problem with free hug huds is they want to use the SAME hug for both people and do about 20 things I am not looking to do.

My typing /hug works with the hud I bought, I want to do it with a hud I *make*.

Again thanks for trying to help.

Pretty please if anyone here is actually a programmer, could you possibly cut and past the few lines of code that do what I am asking?

In the meantime /prays for better examples on lsl wiki.

All I need is a decent example......


Thanks very much :)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-01-2007 09:32
From: Clintok Meyer
Thanks for the response however, it wasn't helpful. I have, as I stated above, a free source HUD and I understand how they work conceptually and also understand a lot of the script in it.

What I asked for and perhaps I confused you, was a "simpler example". I want to see the code that does this:

Ask a person a question and get their response. If they say 'yes' animate them and then animate me.


Telling me to go look at a thread or grab another person's hug doesn't answer my question, but maybe someone else will read this and kindly (as has been done in other threads) cut out and paste the X lines of code that will do what I want.

Hopefully someone, maybe not here, will post a simpler example from which I can expand.

The problem with free hug huds is they want to use the SAME hug for both people and do about 20 things I am not looking to do.

My typing /hug works with the hud I bought, I want to do it with a hud I *make*.

Again thanks for trying to help.

Pretty please if anyone here is actually a programmer, could you possibly cut and past the few lines of code that do what I am asking?

In the meantime /prays for better examples on lsl wiki.

All I need is a decent example......


Thanks very much :)


The idea was to point you in the right direction by examining a working system. And also not to insult your knowledge by reiterating stuff you alredy know.

If you already have access to the source code of a hug that works then even a modicon of scripting experience should be enough for you to work out how it does its stuff. They are not that complex.

The reference to the HUD thread was because I dont think a HUD is required and I was wondering why you so wanted it to be HUD based. Especially since you then talked about typing /hug....

Anyway,

When you type /hug name the script will be starting a sensor search for AV's in nearby radius.

The sensor event will get back a list of AV's and the script will then hopefully be able to find the specific AV you are interested in. Its straight textual comparisson stuff I wont bore you with the details.

If it does it will then request to trigger animations on that av.
The code will be along the lines of

CODE

llRequestPermissions( target ,PERMISSION_TRIGGER_ANIMATION );


This will popup a blue dialog saying something like 'HUD HUG would like to animate your Avatar.", You cannot unfortunately supply a user defined message to the call, would be nice!

Instead most of systems just send a IM saying "xxxx would like give you a hug. Say [Yes] to accept.".

You can display your own Dialog using llDialog but Its actually more confusing to do this though as you would still need to request permissions which will result in a second dialog.

If it gets a yes responce (via the run_time_permissions event) then it will start a specifc animation, something like

CODE

llStartAnimation( animName );
llSleep(animTime);
llStopAnimation( animName );


All you need to do is supply a different anim name.

Oh and as for suggesting i'm not a programmer.... ROFL
Clintok Meyer
Registered User
Join date: 28 Apr 2006
Posts: 17
02-01-2007 10:19
From: Newgate Ludd

Oh and as for suggesting i'm not a programmer.... ROFL


I've offended you. That was not my intent. I never implied you weren't a programmer, I was looking for a programmer who who could paste some code. What I was asking for was what you in fact have given albeit not with the level of detail I'd have preferred.

Hopefully I'll be able to track down that part of the sample and work backward from that.

The problem isn't that I can't code, I can, RPGIII, CL, VB, VFP, VBA, and a few others. It's just that I never learned any variant of C.

I would cheerfully pay for a book that had complete working examples and would give functions with examples, look at this.

llAllowInventoryDrop( integer add );

This is from: http://wiki.secondlife.com/wiki/LSL_llAllowInventoryDrop

No example, no *hint* as to how to use this function. There is no other programming language I've ever run across that has been so poorly documented, none.

It staggers the mind. You obviously are familiar with this language and sadly you appear to assume everyone else is too, hence the pointing to an open source piece of code.

This is akin to wanting to lean how to fix cars and you pointing to parking lot and saying "look around". Not a good way to learn or teach.

Anyway, now that this system is moving toward being open source, maybe someone will document it? Don't laugh it might happen.

As to using the HUD, I'm not married to using a HUD but every other example of this kind of concept uses a HUD.

Lastly I apologize for offending you, you clearly are a programmer but like many programmers maybe not the best teacher ;) no offense.
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
Why am I jumping into the middle of this?
02-01-2007 16:16
hmmmm... sounds like lots of miscommunication. (and I know a little backstory).

1. In Newgate's complete defense, he was recently chastised on these forums for providing TOO MUCH code, thus not allowing people to 'learn' because he was doing all the work. The compromise reached is that Newgate won't provide complete code, but only snippets and direction.

2. I'm confused about your use of the word HUD. A Heads Up Display is one of those little windows that stays open on your screen all the time. Usually has a push button or two on it, or maybe always shows the current status of something.
-XCITE makes a popular HUD to operate their body part attachments.
-There's another HUD that provides a TOUR of SL. It shows several little tiny pictures of places. you click on a picture and get Teleported. When you arrive, the Little HUD window is still open and you can click on another little picture and get teleported again, etc.

The confusing part is, 'If you're going to use a HUD, why do you need to type "/hug Avitar"?' The HUD seems to provide no value. Perhaps you want the HUD to display all the Avitars around you, thus allowing you to click on their name and initiate the hug sequence...no typing required?

3. The freebie HUG devices do NOT provide a HUD, you just WEAR them, and then type '/hug Avitar' when you're feeling loving. Looking at their code will show you how they do the person to person negotiation and then call the ANIMATION. A HUD would just replace the upfront code that detects the typing of "/hug Avitar", with code that detects the presence of Avitars around you and puts their names into buttons on the HUD.

4. Finally, These forums are a great place to learn LSL. For more traditional documentation, check here:
http://wiki.secondlife.com/wiki/LSL_Tutorial
http://rpgstats.com/wiki/index.php?title=LSLTutorials

(the latter has a 'crash course' you might find useful, since its for folks like you with an existing background. I find Linden Scripting quite different from anything else--the 'EVENT Based' triggers were a real shift in thinking. Therefore, I found the basic tutorials very helpful, and taking apart existing code was the best way to learn how the scripts really work.)
Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
02-01-2007 16:58
From: someone
1. In Newgate's complete defense, he was recently chastised on these forums for providing TOO MUCH code, thus not allowing people to 'learn' because he was doing all the work. The compromise reached is that Newgate won't provide complete code, but only snippets and direction.


OH PLEASE, NOOOO!!!!!!!! [collapses into uncontrollably wailing heap].

Er .... I'm also sorry for jumping in. I happened on this thread while looking for a thread to refer someone to (ain't that sweet? People ask me for help now! Gosh!!) :o

*** Some of us learn by copying, doing & deconstructing ***

Really, the geek community - of which I count myself a proud, if junior member - isn't exactly renowned for its ability to explain things in plain language. If it weren't for the gurus of SL, who historically provide a few terse lines of text and an example script to play with, I wouldn't have learned anything. And, since noobs now do ask me for help, I must have learned something ;)

When did self-punishment become an entry requirement for learning LL??!

Regards, and please don't stop dishing out the answers!
Cherry
_____________________
=================
My stuff on XSt:-
http://tinyurl.com/383mgh
Kitty Barnett
Registered User
Join date: 10 May 2006
Posts: 5,586
02-01-2007 18:02
From: Sterling Whitcroft
The confusing part is, 'If you're going to use a HUD, why do you need to type "/hug Avitar"?' The HUD seems to provide no value. Perhaps you want the HUD to display all the Avitars around you, thus allowing you to click on their name and initiate the hug sequence...no typing required?
The benefit of putting it in a HUD (or the main reason I did it) is that it won't constantly be detached when you put other prim attachments on. No matter where I'd attach my multitool, it would always become silently deattached (sooner rather than later) when putting on jewelry or a different outfit. I was also generally wearing two or three additional variations with different animations, making it even more of a pain.

Now, I just have one additional generic script (well, two) in my ZHAO (which is attached all the time anyway) and I don't have to worry about it getting detached, and I contribute less to lag since adding new animations/actions is just a matter of dropping in the anims and adding a few notecard lines :).
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-02-2007 05:33
Firstly no I wasnt offended, I dont take it personally when people get frustrated, life's way to short.

The LSL Wikki's are generally very good, although I do agree that sometimes they seem a little terse in the descriptions and examples.

From your posting I did assume you had a reasonable working knowledge of LSL.

I was more saying, this is where to books on car mechanic's are, thats a working car there, oh and heres a spanner set. :)

As Sterling also pointed out your use of the word HUD was confusing and that was why I suggested the link in the orginal thread. I do agree with Kitty it does stop them getting bumped if you have lots of attachments. (I have 5 and doubt I'll get any more!)

My understanding of LSL has been gained mainly by playing with scripts, reading the wikki and this forum. My knowledge is patchy is several area's, especially HTTP/XML, but I can generally find a way to do what I need. I do have a slight advantage in that my RL background is real time event driven systems.

AS Sterling pointed out, I no longer post complete scripts anymore unless specifically asked. But since you asked....

This is a Newgy-ised version of a freebie hug script I found someplace in SL, probably YadNi's but I wont swear to it. The orginal author is not listed, but the Francis reference probably implies Franis Cheung?

I have extensively modified the orginal, simplified it to make it easier to read and to remove as much intelligence out of the huggee script as I could.

The way it is written now it could easily be extended to cope with more than just hugs or different types/lengths of hug.

Replace HuggerAnimName and HuggeeAnimName withe the named of the animations you want to use and drop them and both scripts into a prim. It should work , but my usual Caveat, I've not been in SL to test it.

Hugger Script
CODE

// Multi time Hugger script.
// Newgy-ised version of Freebie Hug script.
// original reference as "Francis was here" - Francis Cheung?

// Constants
integer Channel = 1;
integer sensorDistance = 10;
string HuggerAnimName = "hug them";
string HuggeeAnimName = "be hugged";
integer animTime = 30;

// Constants (used by linked messages to control actions)
integer HUG_REQUEST = 1;
integer HUG_START = 2;
integer HUG_RESET = 3;
integer HUG_DECLINED = 4;
integer HUG_ANIM = 100;


// Not Constants
string ownerName = "";
key ownerKey = NULL_KEY;
string avTarget = "";
key avKey = NULL_KEY;
integer avFindName = TRUE;
vector avPos;
rotation avRot;

string GetName(key id)
{
// Get a name from a key
string name = llKey2Name( id );
// Reduces it to just their first name
name = llList2String( llParseString2List( name, [ " " ], [] ), 0 );
}

usageMessage()
{
llInstantMessage( llGetOwner(), "Usage: Face your target and Say '/" + (string)Channel + "hug [person's name]'" );
}

MoveCloser()
{
// Move us towards the target in 3 stages.
vector posOffset1 = <0.3, 0, 0>;
vector posOffset2 = <0, 0, 0>;
vector pos = avPos + posOffset1 * avRot;
llMoveToTarget( pos, .5 );
llSleep(.6);
pos = avPos + posOffset2 * avRot;
llMoveToTarget( pos, .5 );
llSleep(.6);
llMoveToTarget( pos, 1 );
llSleep(1);
llStopMoveToTarget();
}

SaySomethingNice()
{
// Switch the objects name to our name
string origName = llGetObjectName();
llSetObjectName( ownerName );
llSay( 0, "/me gives " + avTarget + " a hug." );
// Switch the objects name back
llSetObjectName( origName );
}

Animate()
{
llStartAnimation( HuggerAnimName );
llSleep( animTime );
llStopAnimation( HuggerAnimName );
}

default
{
state_entry()
{
ownerKey = llGetOwner();
ownerName = GetName(ownerKey);

if ( llGetAttached() )
llRequestPermissions(ownerKey,PERMISSION_TRIGGER_ANIMATION);
usageMessage();
llMessageLinked( LINK_SET, HUG_RESET, "", NULL_KEY );
}

on_rez( integer startcode )
{
llResetScript();
}

attach( key id )
{
if ( id != NULL_KEY )
llResetScript();
}

run_time_permissions(integer parm)
{
if( parm & PERMISSION_TRIGGER_ANIMATION )
{
llListen( Channel, "", ownerKey, "" );
}
}

sensor(integer total_number)
{
if ( avFindName )
{
integer i;
for ( i = 0; i < total_number; i++ )
{
// Ignore the owner
if ( llDetectedKey(i) != ownerKey )
{
// Check the names against the supplied text
if ( llSubStringIndex(llToLower(llDetectedName(i)), avTarget) >= 0 )
{
avKey = llDetectedKey(i);
avTarget = GetName(avKey);

llInstantMessage( llGetOwner(), "You have offered to hug " + avTarget + "." );
llMessageLinked( LINK_SET, HUG_REQUEST, ownerName + " would like give you a hug. Say [Yes] to accept.", avKey );
return;
}
}
}
}
else
{
avPos = llDetectedPos(0);
avRot = llDetectedRot(0);

// Move close to the target
MoveCloser();

// Say a nice message
SaySomethingNice();

// And then, do the anim - a bit of a hack to pass over time period
llMessageLinked( LINK_SET, HUG_ANIM + animTime, HuggeeAnimName, NULL_KEY );
Animate();
}
}

no_sensor()
{
llInstantMessage( ownerKey, "Sorry but I Couldn't find '" + avTarget + "'" );
llMessageLinked( LINK_SET, HUG_RESET, "", NULL_KEY );
}

link_message( integer sender, integer number, string s, key id )
{
if ( number == HUG_START )
{
// Refind the target incase they moved away
avFindName = FALSE;
llSensor( "", avKey, AGENT, sensorDistance, PI );
}
else if ( number == HUG_DECLINED )
{
llInstantMessage( llGetOwner(), avTarget + " has declined your hug." );
}
}

listen(integer channel,string name,key id,string message)
{
// Look for the hug request
list ldata = llParseString2List(llToLower(message), [ " " ], [ "" ]);
string command = llList2String(ldata,0);
if( "hug" == command )
{
avFindName = TRUE;
avTarget = llList2String(ldata,1);
llSensor( "", NULL_KEY, AGENT, sensorDistance, PI );
}
}
}


Huggee Script
CODE

// Huggee script.
// Newgy-ised version of Freebie Hug script.
// original reference as "Francis was here" - Francis Cheung?


// Constants (used by linked messages to control actions)
integer HUG_REQUEST = 1;
integer HUG_START = 2;
integer HUG_ANIM = 3;
integer HUG_RESET = 4;
integer HUG_DECLINED = 5;

// Variables
key avKey = NULL_KEY; // Key of Huggee

Reset()
{
llSetTimerEvent(0); // Stop any running timers
avKey = NULL_KEY; // Nullify current target
}

default
{
state_entry()
{
Reset();
}

link_message( integer sender, integer number, string message, key id )
{
if( number == HUG_REQUEST )
{
// Ask the target if they want to be hugged
llRequestPermissions( id ,PERMISSION_TRIGGER_ANIMATION );
llInstantMessage( id, message );
llSetTimerEvent( 60 );
avKey = id;
}
else if( number == HUG_RESET )
{
Reset();
}
else if( number > HUG_ANIM )
{
llStartAnimation( message );
llSleep( number - HUG_ANIM );
llStopAnimation( message );
Reset();
}
}

run_time_permissions(integer parm)
{
if( parm == PERMISSION_TRIGGER_ANIMATION )
{
// The target has said yes to being hugged so start it off
llMessageLinked( LINK_SET, HUG_START, " " , NULL_KEY );
}
else
{
// They said no
llMessageLinked( LINK_SET, HUG_DECLINED, " " , NULL_KEY );
}
}

timer()
{
// No responce so act as if they said no
llMessageLinked( LINK_SET, HUG_DECLINED, " " , NULL_KEY );
Reset();
}

on_rez( integer startcode )
{
Reset();
}

attach( key k )
{
Reset();
}

}


Hopefully it is commented enough that you can follow it all.
Enjoy.
White Hyacinth
Registered User
Join date: 15 Nov 2006
Posts: 353
02-02-2007 07:04
From: Kitty Barnett
The benefit of putting it in a HUD (or the main reason I did it) is that it won't constantly be detached when you put other prim attachments on. No matter where I'd attach my multitool, it would always become silently deattached (sooner rather than later) when putting on jewelry or a different outfit. I was also generally wearing two or three additional variations with different animations, making it even more of a pain.


I think you do not have to attach the standard hug attachments to your BODY. That is the most common thing to do, but there are other places to attach to on your SCREEN. If you do not just "wear" the freebie but use Attach to-->Top right it will not be blocking any attachment points for juwelry, but appear at the top right of your screen (where you would normally find HUDs).
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
these FORUMS are Invaluable
02-02-2007 11:39
...it never occured to me to attach stuff as a HUD, that normally I'd just stick on my head.
I suppose because of its NAME, I'd always thought of the HUD more as a VISUAL thing, rather than a CONVENIENCE thing... I've got to try this HUD thing in world, but it sounds like a great way to avoid the conflict of too many attachments, and not enough attachment points.

/me is glad he reads these things ;)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-02-2007 14:47
From: White Hyacinth
I think you do not have to attach the standard hug attachments to your BODY. That is the most common thing to do, but there are other places to attach to on your SCREEN. If you do not just "wear" the freebie but use Attach to-->Top right it will not be blocking any attachment points for juwelry, but appear at the top right of your screen (where you would normally find HUDs).



I think you've missed the point White, thats part of what we are talking about!
Clintok Meyer
Registered User
Join date: 28 Apr 2006
Posts: 17
02-03-2007 08:26
From: Newgate Ludd


Newgate's generously typed code here

snipped because it's just above in the thread....




/bow deeply.....


I will devote today to trying to make this work for me. After reading what others have said about why you said what you did earlier I completely understand.

But seriously, assuming you were trying to LEARN LSL.....look at the wiki, pick any function you like. They don't generally even give an example with meaningfully filled out parameters!

Here's let another example:

string llGetAnimation( key id );
162 Function ID
0.0 Delay
10.0 Energy

Returns a string .
• key id


Get the currently playing locomotion animation for avatar id

Examples
none
___________________________________________________

Name *one* language on the planet that has its functions so poorly documented...
*Chuckles thens sobs*

As was stated above, the HUD's usage simplifies life for a person who might otherwise have a lot of attachments. Plus like a few HUDs, I could possible give them choices before they issued a verbal command like /hug Mary

The only expertise I've achieved so far was derived from reading simple commented code inside publicly offered scripts in here and on the examples part of the wiki and I'm very grateful for those examples.

But I think a lot of people could do a lot on their own if the functions as listed in the wiki *each* had a very simple example of their utilization with meaningfully supplied parameters.

But enough whining :)

Until the Linden's either decide to properly document their own language or a few masochists do it for us, I will limp along and learn as quickly as my little brain allows ;)

Thanks again for all you *genuinely* clever people who are willing to share, absent you, I'd be truly screwed.


/group hug

Clintok

/attempts to bring joy to a sometimes joyless world
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-03-2007 08:39
I agree the 'new' official wikki is rather poor when compared to the old one as hosted Cathrine. But there is some question of copyright which prevents a verbatum copying of that content to the new wikki.

I suggest you look here and down load the offline copy made available by Osgeld.

There is at least one user run initiative to repopulate the wikki as quickly as possible but again a lot of the really useful stuff will forever remain have copyright issues and will therefore need to be rewritten from scratch.

While your downloading stuff go get Scite-Ez or another LSL compatiable editor and lslint. The combination of Scite-Ez and lslint is excellent and the wikki mirror can also be integrated.
Clintok Meyer
Registered User
Join date: 28 Apr 2006
Posts: 17
02-03-2007 09:57
From: Newgate Ludd

CODE

string GetName(key id)
{
// Get a name from a key
string name = llKey2Name( id );
// Reduces it to just their first name
name = llList2String( llParseString2List( name, [ " " ], [] ), 0 );
}




Sadly this returns the following error:

Not all code paths return a value.

That sounds like sage advice from the compiler but I can't see what I can do to fix it.


Can anyone see what's wrong? The full script from which I've cut the part in error is above in this thread.

/begs for assistance

Clintok
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
damm!
02-03-2007 14:29
It is indeed good advice from the compiler, the function is defined as returning a string and it isnt. Some how in the pasting to the forum I managed to delete the return statement. My apologies

CODE

string GetName(key id)
{
// Get a name from a key
string name = llKey2Name( id );
// Reduces it to just their first name
name = llList2String( llParseString2List( name, [ " " ], [] ), 0 );
return name;
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Newgy strikes again.
02-04-2007 05:32
Found another mistake, I managed to delete the call to set up the listen in the hugger script

Replace state_entry with the following

CODE

state_entry()
{
ownerKey = llGetOwner();
ownerName = GetName(ownerKey);

if ( llGetAttached() )
llRequestPermissions(ownerKey,PERMISSION_TRIGGER_ANIMATION);
usageMessage();
llMessageLinked( LINK_SET, HUG_RESET, "", NULL_KEY );
llListen(Channel,"",ownerKey,"");
}


Enjoy
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
oops
02-20-2007 06:13
CODE

string GetName(key id)
{
// Get a name from a key
string name = llKey2Name( id );
// Reduces it to just their first name
name = llList2String( llParseString2List( name, [ " " ], [] ), 0 );
return name;
}
Cherry Hotaling
Registered User
Join date: 25 Feb 2007
Posts: 86
03-20-2007 07:32
Hey there are you able to update your original post with the changes you made?

Also How does it know what the name of the huggee script is? When you type hug targetname where in the hugger script does it look for the name of the huggee script?

Im wondering because if I put multiple scripts into one prim do I have to name the scripts a certain way for them to be found?

Thanks for all your time and help!

-Lady Cherry
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-20-2007 08:54
From: Cherry Hotaling
Hey there are you able to update your original post with the changes you made?

Also How does it know what the name of the huggee script is? When you type hug targetname where in the hugger script does it look for the name of the huggee script?

Im wondering because if I put multiple scripts into one prim do I have to name the scripts a certain way for them to be found?

Thanks for all your time and help!

-Lady Cherry



It doesnt need to know the name of the other script at all. Communication is via linked messages of the form:
CODE
llMessageLinked( LINK_SET, HUG_RESET, "", NULL_KEY ); 


In this case its sent to all prims (LINK_SET) and sends an integer (HUG_RESET), an empty string and a NULL_KEY. The Huggee script has alinked_message event handler which will be triggered when the message is received.
Cherry Hotaling
Registered User
Join date: 25 Feb 2007
Posts: 86
03-21-2007 07:39
ok one more question. I use looped animations and My animation stops in the time I specify but the other persons doesnt stop for a long while after. Is there a way to set it so thier also stops in the time specified?

Such as this in the hugger script?:
integer animTime = 30;

Also If I wanted to put a second script in the item for like kiss what would I need to set the return line to say?

Thank you so much for your help.

I appreciate it greatly!

-Lady Cherry
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-21-2007 09:37
From: Cherry Hotaling
ok one more question. I use looped animations and My animation stops in the time I specify but the other persons doesnt stop for a long while after. Is there a way to set it so thier also stops in the time specified?

Such as this in the hugger script?:
integer animTime = 30;

Also If I wanted to put a second script in the item for like kiss what would I need to set the return line to say?

Thank you so much for your help.

I appreciate it greatly!

-Lady Cherry


You are correct, the animTime variable is used to hold how long the animation is to be played for. Adjust that to match your required length of time.

To add additional animations doesnt require additional scripts. The base hugger script could easily be reworked for multiple animations and lengths. Infact I produce a free hug n kiss based on this script that supports 3 different length kisses and 3 different length hugs. It could easily be enhanced to hold more variations. I just havent found any free animations that i thouight worth incorporating.
Cherry Hotaling
Registered User
Join date: 25 Feb 2007
Posts: 86
03-21-2007 10:52
hehe thank you but..

The problem im having is its playing the other persons Animations for like another 30 seconds after mine is done. So the Huggee is still being animatied even with the timer set to 30.

How can I fix this?

Hugger Script:
CODE

// Multi time Hugger script.
// Newgy-ised version of Freebie Hug script.
// original reference as "Francis was here" - Francis Cheung?

// Constants
integer Channel = 1;
integer sensorDistance = 10;
string HuggerAnimName = "combmain";
string HuggeeAnimName = "combsecondary";
integer animTime = 30;

// Constants (used by linked messages to control actions)
integer HUG_REQUEST = 1;
integer HUG_START = 2;
integer HUG_RESET = 3;
integer HUG_DECLINED = 4;
integer HUG_ANIM = 100;


// Not Constants
string ownerName = "";
key ownerKey = NULL_KEY;
string avTarget = "";
key avKey = NULL_KEY;
integer avFindName = TRUE;
vector avPos;
rotation avRot;

string GetName(key id)
{
// Get a name from a key
string name = llKey2Name( id );
// Reduces it to just their first name
name = llList2String( llParseString2List( name, [ " " ], [] ), 0 );
return name;
}

usageMessage()
{
llInstantMessage( llGetOwner(), "Usage: Face your target and Say '/" + (string)Channel + "hug [person's name]'" );
}

MoveCloser()
{
// Move us towards the target in 3 stages.
vector posOffset1 = <0.3, 0, 0>;
vector posOffset2 = <0, 0, 0>;
vector pos = avPos + posOffset1 * avRot;
llMoveToTarget( pos, .5 );
llSleep(.6);
pos = avPos + posOffset2 * avRot;
llMoveToTarget( pos, .5 );
llSleep(.6);
llMoveToTarget( pos, 1 );
llSleep(1);
llStopMoveToTarget();
}

SaySomethingNice()
{
// Switch the objects name to our name
string origName = llGetObjectName();
llSetObjectName( ownerName );
llSay( 0, "/me gives " + avTarget + " a hug." );
// Switch the objects name back
llSetObjectName( origName );
}

Animate()
{
llStartAnimation( HuggerAnimName );
llSleep( animTime );
llStopAnimation( HuggerAnimName );
}

default
{
state_entry()
{
ownerKey = llGetOwner();
ownerName = GetName(ownerKey);

if ( llGetAttached() )
llRequestPermissions(ownerKey,PERMISSION_TRIGGER_ANIMATION);
usageMessage();
llMessageLinked( LINK_SET, HUG_RESET, "", NULL_KEY );
llListen(Channel,"",ownerKey,"");
}

on_rez( integer startcode )
{
llResetScript();
}

attach( key id )
{
if ( id != NULL_KEY )
llResetScript();
}

run_time_permissions(integer parm)
{
if( parm & PERMISSION_TRIGGER_ANIMATION )
{
llListen( Channel, "", ownerKey, "" );
}
}

sensor(integer total_number)
{
if ( avFindName )
{
integer i;
for ( i = 0; i < total_number; i++ )
{
// Ignore the owner
if ( llDetectedKey(i) != ownerKey )
{
// Check the names against the supplied text
if ( llSubStringIndex(llToLower(llDetectedName(i)), avTarget) >= 0 )
{
avKey = llDetectedKey(i);
avTarget = GetName(avKey);

llInstantMessage( llGetOwner(), "You have offered to hug " + avTarget + "." );
llMessageLinked( LINK_SET, HUG_REQUEST, ownerName + " would like give you a hug. Say [Yes] to accept.", avKey );
return;
}
}
}
}
else
{
avPos = llDetectedPos(0);
avRot = llDetectedRot(0);

// Move close to the target
MoveCloser();

// Say a nice message
SaySomethingNice();

// And then, do the anim - a bit of a hack to pass over time period
llMessageLinked( LINK_SET, HUG_ANIM + animTime, HuggeeAnimName, NULL_KEY );
Animate();
}
}

no_sensor()
{
llInstantMessage( ownerKey, "Sorry but I Couldn't find '" + avTarget + "'" );
llMessageLinked( LINK_SET, HUG_RESET, "", NULL_KEY );
}

link_message( integer sender, integer number, string s, key id )
{
if ( number == HUG_START )
{
// Refind the target incase they moved away
avFindName = FALSE;
llSensor( "", avKey, AGENT, sensorDistance, PI );
}
else if ( number == HUG_DECLINED )
{
llInstantMessage( llGetOwner(), avTarget + " has declined your hug." );
}
}

listen(integer channel,string name,key id,string message)
{
// Look for the hug request
list ldata = llParseString2List(llToLower(message), [ " " ], [ "" ]);
string command = llList2String(ldata,0);
if( "hug" == command )
{
avFindName = TRUE;
avTarget = llList2String(ldata,1);
llSensor( "", NULL_KEY, AGENT, sensorDistance, PI );
}
}
}


Huggee script:
CODE

// Huggee script.
// Newgy-ised version of Freebie Hug script.
// original reference as "Francis was here" - Francis Cheung?


// Constants (used by linked messages to control actions)
integer HUG_REQUEST = 1;
integer HUG_START = 2;
integer HUG_ANIM = 3;
integer HUG_RESET = 4;
integer HUG_DECLINED = 5;

// Variables
key avKey = NULL_KEY; // Key of Huggee

Reset()
{
llSetTimerEvent(0); // Stop any running timers
avKey = NULL_KEY; // Nullify current target
}

default
{
state_entry()
{
Reset();
}

link_message( integer sender, integer number, string message, key id )
{
if( number == HUG_REQUEST )
{
// Ask the target if they want to be hugged
llRequestPermissions( id ,PERMISSION_TRIGGER_ANIMATION );
llInstantMessage( id, message );
llSetTimerEvent( 60 );
avKey = id;
}
else if( number == HUG_RESET )
{
Reset();
}
else if( number > HUG_ANIM )
{
llStartAnimation( message );
llSleep( number - HUG_ANIM );
llStopAnimation( message );
Reset();
}
}

run_time_permissions(integer parm)
{
if( parm == PERMISSION_TRIGGER_ANIMATION )
{
// The target has said yes to being hugged so start it off
llMessageLinked( LINK_SET, HUG_START, " " , NULL_KEY );
}
else
{
// They said no
llMessageLinked( LINK_SET, HUG_DECLINED, " " , NULL_KEY );
}
}

timer()
{
// No responce so act as if they said no
llMessageLinked( LINK_SET, HUG_DECLINED, " " , NULL_KEY );
Reset();
}

on_rez( integer startcode )
{
Reset();
}

attach( key k )
{
Reset();
}

}


Thanks for your time.

-Lady Cherry
Cherry Hotaling
Registered User
Join date: 25 Feb 2007
Posts: 86
03-23-2007 19:36
anyone have any ideas?

Thanks

-Cherry
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-24-2007 00:21
From: Cherry Hotaling
anyone have any ideas?

Thanks

-Cherry


None what so ever or we would have replied by now. :)
drop a copy of your object and animations on me in world and I'll try and debug it for you.
1 2