Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

selecting an object - how ?

ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
01-22-2007 23:40
I have an object running a script, the script runs and prompts the owner to select an object, the owner clicks on another object. The ID of the selected object is returned to the script. Preferably I would like the object that has been clicked to be highlighted in yellow the same as when it is selected for editing.

Seems like it should be straightforward, but this has me stumped. I have searched the forum and wiki but to no avail. I am sure that I am missing something fairly obvious.


Thanks
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-23-2007 00:49
From: ab Vanmoer
I have an object running a script, the script runs and prompts the owner to select an object, the owner clicks on another object. The ID of the selected object is returned to the script. Preferably I would like the object that has been clicked to be highlighted in yellow the same as when it is selected for editing.

Seems like it should be straightforward, but this has me stumped. I have searched the forum and wiki but to no avail. I am sure that I am missing something fairly obvious.


Thanks



Which bit has you stumped?
You cannot (as far as I know) highlight the object in the manner you describe, thats an edit only function.
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
01-23-2007 09:30
Thanks Newgate,
The highlighting of the selected object is desirable but not necessary.

What has me stumped is how can a script direct the avatar to touch an object and then receive the ID of the touched object. eg

1. Object containing script is touched
2. Script : llSay(0,"please select the object on which you wish to operate.";)
3. Avatar touches a different object, the key of the object is returned to the script
4. Script : llSay(0,"You touched object" + key)

I thought of maybe doing it with llTakeControls but haven't figured out how.

Thanks,
ab
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
01-23-2007 09:41
If the objects the avatar is touching are scripted to say their key (or, really, anything at all, since you get the key of the speaker as part of any chat heard) on a chat channel when touched, then it is a simple matter of listening on that chat channel for the key.

Otherwise, the only way to do that is via using llSensor, which can be a pain for selecting objects. I recently wrote a narrow-beam agent selector for a security system based on a HUD, but objects would most likely return multiples even still, and you'd have to write some kind of menu to pick one object out of the returned list.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-23-2007 11:55
Talarus seems to have covered it. This thread may also help.
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
01-23-2007 11:57
Thanks Talarus,
I did try it using a sensor and adding the objects to a menu for the avatar to pick.
There were two problems with that though, firstly a lot of objects seem to be named object :)
and secondly the sensor seems to have a limit to the number of objects it senses.

Unfortunately the objects to be selected are any objects owned by the avatar and are not necessarily scripted.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-23-2007 12:10
From: ab Vanmoer
Thanks Talarus,
I did try it using a sensor and adding the objects to a menu for the avatar to pick.
There were two problems with that though, firstly a lot of objects seem to be named object :)
and secondly the sensor seems to have a limit to the number of objects it senses.

Unfortunately the objects to be selected are any objects owned by the avatar and are not necessarily scripted.


A sensor can only return a maximum of 16 objects, so yes you're ona hiding to nothing before you start.

What are you actually trying to achieve?
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
01-23-2007 15:01
Thanks for the responses.

what I am trying to do, is write a script that will box up a house and its contents ready for rezzing somewhere else. The script would run, prompt the user to click on the house, it would then take the house followed by all the objects in the house.

Thanks
ab
Arachnid Baxter
Registered User
Join date: 8 Jan 2007
Posts: 44
01-23-2007 15:30
It _is_ possible to detect more than 16 objects, but it's tricky, and you're not guaranteed to detect everything.

Basically, scan a 360 degree radius, and act on all the objects returned. Then, as long as 16 objects were returned, halve your radius and examine both halves seperately (taking care to filter out duplicates), repeating until you get fewer than 16 objects from a given scan. I have a scanner/finder object that does this, and I'm happy to send you a copy if you want to look at the source for an example.

The problem here, however, is that because the sensor radius is defined as a 'dimple', halving the radius doesn't cover half the area, it covers less, so as you focus on smaller and smaller areas, you miss out more and more to the top and bottom of where you're looking. Distant objects that are above or below the plane of where you're looking are likely to be missed. As far as I know, there's no simple formula to figure out how to subdivide your search area taking in the entire sphere, as opposed to a single plane.
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
01-23-2007 16:54
Arachnid,
Thanks very much for the explanation. It seems more complicated than its worth in this case, but a useful idea to keep for the future.
I am new at LSL, so I would have thought that it would have been fairly simple to select an object under script control. Obviously I was wrong:(
Thanks,
ab
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-24-2007 00:17
Arachnid, I only said that an individual sensor will only return 16 items. Using sector scans is the intelligent way to do it.

Ab, You may be going about this the wrong way.
You need to give the script at least a fighting chance.
Name your objects with meaningful names that your packer can then search for.
You can make it notecard driven so it will sequentially read through the list and pack up all the objects its requires.

There are several products out there that perform this packing/unpacking function and I think there may be something similar in the script library. I wont swear to it though!