Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSay, only sending to owner object?

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-13-2007 14:18
i was told a wile back there is a way to use llSay to send a message to a object and it would generate a random channel every message or something so lets say you made a object that lissens to any command on channel 1, you put it for sale it becomes popular, how can you make it only listen to the owner or find a way to comunicate from object to object without email or keys, i have no idea how that woukld be created
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
11-13-2007 14:36
From: Mrc Homewood
i was told a wile back there is a way to use llSay to send a message to a object and it would generate a random channel every message or something so lets say you made a object that lissens to any command on channel 1, you put it for sale it becomes popular, how can you make it only listen to the owner or find a way to comunicate from object to object without email or keys, i have no idea how that woukld be created


You can generate a new random channel each time the script is restarted (the utility of that is limited unless you're telling the user what the random channel is via llOwnerSay each time). It is also useful for rezing a temporary prim that you have to have your script communicate with. Look up llListen. You can limit what the object is listening to, such as owner, objects, etc.
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
11-13-2007 14:46
To make an object only listen to the owner, check the key of the speaker. You can do this in the Listen Event:

listen( integer channel, string name, key id, string message )

Check the key 'id' against the key of the object's owner (you can get this from llGetOwner()).

If the keys don't match, ignore the text.
_____________________
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-13-2007 15:03
not quite what i ment, it kinda hard to explane, im making a rc chopper and the one thing i need is to have it so, the person has a controler, it comunicates with the chopper using llSay, how would i get it to not interfear with another pearson with same chopper.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
11-13-2007 15:10
If you want to check that the controller has the same owner as the chopper, one useful check is

listen(integer c, string name, key id, string msg)
{
if (llGetOwnerKey(id) == llGetOwner()) {
// process message here
}
}

llGetOwnerKey returns either the key of the owner (if it is an object speaking) or the avatar key (if it is an avatar speaking). Therefore if this is in the chopper, this will filter out any commands sent by anyone not its owner.
_____________________
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
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
11-13-2007 15:34
From: Mrc Homewood
i was told a wile back there is a way to use llSay to send a message to a object and it would generate a random channel every message or something

One way you can do that is to store the helicopter in the controller's inventory and rez if from there. This gives you a couple of possibilities.

You could use llRezObject(x) to send a random channel number to the helicopter's on_rez handler. Or, the controller could capture the helicopter's key with an object_rez handler, and prefix that to any commands it sends so that the helicopter can know it's being spoken to.
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-13-2007 15:37
here is what i have so far for the remote, didnt try the on_rez stuff yet, but i got alittle problem, you click the controler and it will send the message to the chopper to turn on and then clikc it again, if it already is on the control will realease control but it wont release

CODE

integer takecontrol;

default
{
state_entry()
{
llSay(0, "spawn chopper if havent already");
takecontrol = TRUE;
}

touch_start(integer t)
{
if(takecontrol == TRUE)
{
llSay(-500,"stop");
llReleaseControls();
takecontrol = FALSE;
}
else if(takecontrol == FALSE)
{
llRequestPermissions(llDetectedKey(0),PERMISSION_TAKE_CONTROLS);
}
}
run_time_permissions(integer perms)
{
if(perms & (PERMISSION_TAKE_CONTROLS))
{
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
llSay(-500,"start");
}
else
{
llReleaseControls();
llSay(-50,"stop");
takecontrol = FALSE;
}
}
control(key id, integer level, integer edge)
{
if (level & CONTROL_FWD)
{
llSay(-500,"front");
}

if (level & CONTROL_BACK)
{
llSay(-500,"back");
}

if (level & CONTROL_UP)
{
llSay(-500,"up");
}

if (level & CONTROL_DOWN)
{
llSay(-500,"down");
}

if ((level & CONTROL_ROT_RIGHT) || (level & CONTROL_RIGHT))
{
llSay(-500,"right");
}

if ((level & CONTROL_ROT_LEFT) || (level & CONTROL_LEFT))
{
llSay(-500,"left");
}

}

on_rez(integer start_param)
{
llResetScript();
}
}


EDIT:
NVM about it, i missed a integer command, owell you peaple can see what i have sofar, so if i make a listen command for the owner to say

if(owner = TRUE)
{
if(message="[something]
{
//rez chopper

how would i acculy get the chopper to only listen to what the owner or controler would say?
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-13-2007 17:04
i cant figure out how to tie the object_rez with being able to listen to it

what it gave on wiki

CODE

//gives inventory to object when it rezzes.
string inventory;
string object;

default
{
touch_start(integer count)
{
object=llGetInventoryName(INVENTORY_OBJECT,0);
llRezObject(object, llGetPos() + <0.0, 0.0, 0.5>, ZERO_VECTOR, ZERO_ROTATION, 0);
}
object_rez(key id)
{
llGiveInventory(id,inventory);
}
}
Teddy Qinan
Registered User
Join date: 10 Mar 2007
Posts: 34
11-13-2007 20:24
When the controller sends a message to the chopper to turn on (on chan -500), the chopper sends a message back (on -500) stating a new randomly chosen channel (-xxxx). Then the controller talks to the chopper on the new channel.

To remove the small chance of two people turning on their choppers at the same time, you could put the channel in a notecard in each object, but that's a but messier for the user.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
11-13-2007 23:40
The best way to approach RC vehicles is to have them ask for keyboard control which allows them to intercept keypressed and then do the appropriate thing.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-13-2007 23:45
assuming the controller will only be used by the owner, there's no need to test which person it's hearing, just tell it to only listen to owner like
llListen( command_channel, "", llGetOwner(), "" );

if it's a public use item, you can store the users key and use that to start the listen, probably via touch
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
11-14-2007 05:49
An easier approach to this might be checking out one of the freebie remote control script. There should be several out there. I did notice one in the new citizens incorporated vender.
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-14-2007 14:05
here it what i have so far, the chopper wont respond to anything the controlers says

CODE

default
{
state_entry()
{
llListen(-500,"","","");
}
listen(integer channel,string name,key id,string message)
{
if(message ="front")
{
speed = 2.3;
move = TRUE;
}
else if(message ="back")
{
speed = -1.5;
move = TRUE;
}
else if(message ="down")
{
lift = -.9;
move = TRUE;
}

else if(message ="right")
{
turn = 4;
turning = TRUE;
}

else if(message ="left")
{
turn = -4;
turning = TRUE;
}
if(move)
{
// my stuff defind
}
if(turning)
{
// more defined
}
}
on_rez(integer start_param)
{
llResetScript();
}
}


and the remote is this

CODE

integer takecontrol;

default
{
state_entry()
{
llSay(0, "spawn chopper if havent already");
llSay(-500,"stop");
takecontrol = TRUE;
}

touch_start(integer t)
{
if(takecontrol == TRUE)
{
llSay(-500,"stop");
llReleaseControls();
takecontrol = FALSE;
}
else if(takecontrol == FALSE)
{
llRequestPermissions(llDetectedKey(0),PERMISSION_TAKE_CONTROLS);
takecontrol = TRUE;
}
}
run_time_permissions(integer perms)
{
if(perms & (PERMISSION_TAKE_CONTROLS))
{
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
llSay(-500,"start");
}
else
{
llReleaseControls();
llSay(-500,"stop");
takecontrol = FALSE;
}
}
control(key id, integer level, integer edge)
{
if (level & CONTROL_FWD)
{
llSay(-500,"front");
}

if (level & CONTROL_BACK)
{
llSay(-500,"back");
}

if (level & CONTROL_UP)
{
llSay(-500,"up");
}

if (level & CONTROL_DOWN)
{
llSay(-500,"down");
}

if ((level & CONTROL_ROT_RIGHT) || (level & CONTROL_RIGHT))
{
llSay(-500,"right");
}

if ((level & CONTROL_ROT_LEFT) || (level & CONTROL_LEFT))
{
llSay(-500,"left");
}

}

on_rez(integer start_param)
{
llResetScript();
}
}


it wont respond to eather llListen(-500,"",llGetowner,"";); or "","",""
anyone have any idea what might be wrong
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-14-2007 14:46
Did you get this to compile? You don't have your variables declared in the first script and your if tests are using = instead of ==.

I would suggest downloading LSLEditor and also install lslint into it as a plugin. Or you can use the w-hat lslint website to test your scripts. Using either you get output like this:

"1 `speed' is undeclared. Script.lsl 11 4 temp2
2 `move' is undeclared. Script.lsl 12 4 temp2
3 `speed' is undeclared. Script.lsl 16 4 temp2
4 `move' is undeclared. Script.lsl 17 4 temp2
5 `lift' is undeclared. Script.lsl 21 4 temp2
6 `move' is undeclared. Script.lsl 22 4 temp2
7 `turn' is undeclared. Script.lsl 27 4 temp2
8 `turning' is undeclared. Script.lsl 28 4 temp2
9 `turn' is undeclared. Script.lsl 33 4 temp2
10 `turning' is undeclared. Script.lsl 34 4 temp2
11 `move' is undeclared. Script.lsl 36 6 temp2
12 `turning' is undeclared. Script.lsl 40 6 temp2
13 Suggest parentheses around assignment used as truth value. Script.lsl 9 6 temp2
14 Suggest parentheses around assignment used as truth value. Script.lsl 14 11 temp2
15 Suggest parentheses around assignment used as truth value. Script.lsl 19 11 temp2
16 Suggest parentheses around assignment used as truth value. Script.lsl 25 11 temp2
17 Suggest parentheses around assignment used as truth value. Script.lsl 31 11 temp2
18 Empty if statement. Script.lsl 36 6 temp2
19 Empty if statement. Script.lsl 40 6 temp2
"
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-14-2007 16:04
yes i declared them in my script it compiles fine, just dont realy wont to post that part of the script, i have a object in my hand that takes controls if i click right arrow, the controler object in my hand sends a message on channel -500 the chopper lissens for the command so it be

controler sends message
chopper listens on channel -500
chopper gets command
*saposed to turn right*

the chopper dosent respond at all that is the problem i have
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-14-2007 16:52
If I use these two scripts:
CODE

integer takecontrol;

default
{
state_entry()
{
llSay(0, "spawn chopper if havent already");
llSay(-500,"stop");
takecontrol = TRUE;
}

touch_start(integer t)
{
if(takecontrol == TRUE)
{
llSay(-500,"stop");
llReleaseControls();
takecontrol = FALSE;
}
else if(takecontrol == FALSE)
{
llRequestPermissions(llDetectedKey(0),PERMISSION_TAKE_CONTROLS);
takecontrol = TRUE;
}
}
run_time_permissions(integer perms)
{
if(perms & (PERMISSION_TAKE_CONTROLS))
{
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
llSay(-500,"start");
}
else
{
llReleaseControls();
llSay(-500,"stop");
takecontrol = FALSE;
}
}
control(key id, integer level, integer edge)
{
if (level & CONTROL_FWD)
{
llSay(-500,"front");
}

if (level & CONTROL_BACK)
{
llSay(-500,"back");
}

if (level & CONTROL_UP)
{
llSay(-500,"up");
}

if (level & CONTROL_DOWN)
{
llSay(-500,"down");
}

if ((level & CONTROL_ROT_RIGHT) || (level & CONTROL_RIGHT))
{
llSay(-500,"right");
}

if ((level & CONTROL_ROT_LEFT) || (level & CONTROL_LEFT))
{
llSay(-500,"left");
}

}

on_rez(integer start_param)
{
llResetScript();
}
}

CODE

float speed;
integer move;
float lift;
integer turn;
integer turning;


default
{
state_entry()
{
llListen(-500,"",NULL_KEY,"");
}
listen(integer channel,string name,key id,string message)
{
if(message == "front")
{
speed = 2.3;
move = TRUE;
llOwnerSay(message);
}
else if(message == "back")
{
speed = -1.5;
move = TRUE;
llOwnerSay(message);
}
else if(message == "down")
{
lift = -.9;
move = TRUE;
llOwnerSay(message);
}

else if(message == "right")
{
turn = 4;
turning = TRUE;
llOwnerSay(message);
}

else if(message == "left")
{
turn = -4;
turning = TRUE;
llOwnerSay(message);
}
// if(move)
// {
// // my stuff defind
// }
// if(turning)
// {
// // more defined
// }
}
on_rez(integer start_param)
{
llResetScript();
}
}

Then I get this output which shows it is recieving the control messages:
"[16:50] Object: right
[16:50] Object: right
[16:50] Object: right
[16:50] Object: right
[16:50] Object: right
[16:50] Object: right
[16:50] Object: right
[16:50] Object: back
[16:50] Object: back
[16:50] Object: back
[16:50] Object: back
[16:50] Object: back
[16:50] Object: back
[16:50] Object: back
[16:50] Object: left
[16:50] Object: left
[16:50] Object: left
[16:50] Object: left
[16:50] Object: left
[16:50] Object: left
[16:50] Object: left
[16:50] Object: left
[16:50] Object: left
[16:50] Object: front
[16:50] Object: front
[16:50] Object: front
[16:50] Object: front
[16:50] Object: front
[16:50] Object: front
[16:50] Object: front
[16:50] Object: front"
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-14-2007 18:04
omfg, srry about all this, made the dumbest mistake in the world, forogt to add all the flags and vehical physics controls to the script >.< anyway i got it to work unknown if it acculy will listen to only me yet tho
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-14-2007 18:11
Woot!!!!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-14-2007 18:40
problem now is that since it is a say command they are exstremly laggy if it gose over 20m even with regian say the commands take like 1/2 a second per command to reach it over that 20m so it dosent respond that well, if i can find a place that has that freebie RC and romote i might be able to fix the script to make it work right