Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
|
08-18-2004 01:53
I was wondering if anyone out there had any tips on the most efficient way for scanning for an object to scan for another specific object while moving a long distance using llSetPos.
Essentially, I'd like to scan after every 10m move I make, but if I do the movement in a simple while() loop, I'll just be racking up sensor or no_sensor events, right? Those'll all queue one after another -after- the while loop is done?
I'm thinking something alone the lines of:
if(llGetPos() != destination) { llSetPos(destination); llSensor(ObjectInfoHere); }
at the end of both sensor() and no_sensor(). Is that efficient? It's 4AM. I'm a bit non-cognitive.
_____________________
</sarcasm>
|
Cadroe Murphy
Assistant to Mr. Shatner
Join date: 31 Jul 2003
Posts: 689
|
08-18-2004 06:03
I don't know much about this stuff, but here's my idea.
Set a timer at the interval it takes you to travel about 10 meters. Inside the timer event make the llSetPos() call. Use llSensorRepeat() with the same interval as the timer. Theoretically you'd get one sensor or no_sensor call for every 10 meters you move, and the timer and sensor events would not block each other. And of course cancel the timer and sensor repeat when you get where you're going.
EDITED TO ADD: You know, that's probably no better than putting llSetPos in the sensor events. Sorry, still having my coffee and sometimes I suffer from premature articulation.
_____________________
ShapeGen 1.12 and Cadroe Lathe 1.32 now available through SLExchange.
|
Zak Escher
Builder and Scripter
Join date: 3 Aug 2003
Posts: 181
|
08-18-2004 06:51
I haven't tried this myself, but I would think that it would be better to put the llSetPos in the sensor or no_sensor event because if it is in a timer event, there could be a delay in the execution of the timer event due to lag. Although now that I think about it, the same conditions would probably produce lag in the handling of the sensor events.
|
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
|
08-18-2004 07:06
I wouldn't use llSensorRepeat(). As others suggested, put the movement in the sensor() and/or no_sensor() events. Call the llSensor() function in a function or something... // funcs my_sensor() { llSensor(....); }
default { state_entry() { my_sensor(); }
no_sensor() { llSetPos(...); }
sensor() { // found object/avatar // do whatever, move again, call my_sensor() etc.. } }
Could use a timer, but I don't think it's needed, assuming you're stopping the movement once the object/avatar is found -- even then you can keep on going if you want. Boso Edit ...forgot a ";".
|