HUD to object communication
|
|
Coal Porter
Owner CP Motors
Join date: 26 Mar 2008
Posts: 37
|
05-11-2008 19:33
Im trying to make a hud that gives my vehicle the commands I use through chat. listen(integer channel, string name, key id, string message) { //stuff else if(message == RollCommand) { llSetPos(llGetPos() + <0,0,0.5>  ; vector rot = llRot2Euler(llGetRot()); llSetRot(llEuler2Rot(<0,0,rot.z>  ); } // other stuff } When i issue the Roll command the vehicle repositions itself so what command do i use on a touch_start hud button to have it send a command to my vehicle?
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
05-11-2008 20:13
default { touch_start(integer x) { llWhisper(channel,"(command)"); // llSay or llShout also is good } }
|
|
Coal Porter
Owner CP Motors
Join date: 26 Mar 2008
Posts: 37
|
05-12-2008 14:26
but how do i get the vehicle to recognize that the owner of the Hud is the one to listen to. otherwise wouldn't multiple people with the same vehicle and HUD cross communicate?
I'm guessing it may have to do with //GetOwnerKey or something. but i cant have multiple huds interfering
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-12-2008 15:16
From: Coal Porter but how do i get the vehicle to recognize that the owner of the Hud is the one to listen to. otherwise wouldn't multiple people with the same vehicle and HUD cross communicate?
I'm guessing it may have to do with //GetOwnerKey or something. but i cant have multiple huds interfering You can use that or pick a negative number in the range say -1000000000 to -1000 for the channel number. Of course there is no guaranty the number is not used by others but the chances are small if you pick by random
_____________________
From Studio Dora
|
|
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
|
05-12-2008 15:33
The way I do it in my products is to append the owner's key to each message. then the receiving object can compare that key to the owner of the object. If they don't match, the message is ignored.
|
|
Coal Porter
Owner CP Motors
Join date: 26 Mar 2008
Posts: 37
|
05-12-2008 15:50
Darien,
thats what im looking for. but how do you script it?
can you give me a small example on the llsay() and listen()
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
05-12-2008 16:10
If you want to check that the owner of the sender is the same as the owner of the receiver, all you need to do is put at the start of the listen()
if (llGetOwnerKey(id) != llGetOwner()) return;
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
05-12-2008 16:52
um don't you mean... llListen(CHANNEL, "", llGetOwner(), ""  ; ...and save all that additional event propogation.
_____________________
http://slurl.com/secondlife/Together
|
|
Coal Porter
Owner CP Motors
Join date: 26 Mar 2008
Posts: 37
|
05-12-2008 17:04
im obviously an idiot at coding. this isnt working for me.
Can someone write up two code snippets that will make one box tell another to say 'hello' but only if owned by the same person.
Big thanks
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-13-2008 02:00
From: Coal Porter Can someone write up two code snippets that will make one box tell another to say 'hello' but only if owned by the same person.
// Master default { state_entry() { llSay( -159753, "Say it now" ) ; } }
and // Slave default { state_entry() { llListen( -159753, "", NULL_KEY, "Say it now"); }
listen(integer channel, string name, key id, string message) { if ( llGetOwner() == llList2Key( llGetObjectDetails( id, [OBJECT_OWNER])) ) llWhisper(PUBLIC_CHANNEL, "Hello"); } }
Alternatively: // Slave default { state_entry() { llListen( -159753, "", NULL_KEY, "Say it now"); }
listen(integer channel, string name, key id, string message) { if ( llGetOwner() == llGetOwnerKey( id )) llWhisper(PUBLIC_CHANNEL, "Hello"); } }
I hope you can use this. The code is not compiled but you can do that?
_____________________
From Studio Dora
|
|
Coal Porter
Owner CP Motors
Join date: 26 Mar 2008
Posts: 37
|
05-13-2008 14:58
I got a compile error on the first one. the second one gave me just what i needed. thank you
|