Jump to content
Sign in to follow this  
Robin Mapp

Another scanner, but acting in reverse

You are about to reply to a thread that has been inactive for 3073 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Sorry to keep bugging you guys, but hit a snag with another project.

 

I am attempting to build a scanner that will look to see if an object is present, if so, it simply keeps scanning, but if the object is not present I would like it to IM and email the owner that the object is no longer present. The caveat is, the Named Object will have an appended number to the name, rather than just: Object, it will have the name of Object1, Object2, and so forth.

Here is the script I have been attempting to do this with:

integer type = 2;
integer on = TRUE;
string objectname = "Named Object";
list gNamedObjects;
integer object = 1;


default
{

touch_start(integer total_number)
{
on = llAbs(on - 1); // Or, better, on = !on;
if (on)
{
llSetTimerEvent(2.5);
llOwnerSay("Scanning");
llSetText("Scanning for \Available Objects",<0,1,0>, 1);


}
else
{
llSetTimerEvent(0.0);
type = 2;
llOwnerSay("Script Reset");
llOwnerSay("Scanner is Off");
llSetText("Resetting Script",<1,1,0>, 1);
llSetText("3",<1,1,0>, 1);
llSleep(1);
llSetText("2",<1,1,0>, 1);
llSleep(1);
llSetText("1",<1,1,0>, 1);
llSleep(1);

llSetText("Scanner is Off\nTouch to Turn On",<1,0,0>, 1);


}
}

timer()
{
llSensor(objectname, "", type, 10.0, PI);
type = type * 2;
if (type > 8) type = 2;
}

sensor(integer total_number)
{
integer i;
for (i = 0; i <total_number; i++)
{
if (object = 1)
{
llSay(0,"object is Present");
}
else if (object <= 0)

{

llInstantMessage(llGetOwner(),"Object not Present at "+ (string)llDetectedPos(i));
llEmail(llGetObjectDesc(), "Object not present at "+ (string)llDetectedPos(i)); //this llDectectedPos fails (Function call Mismatch)

}
}
}
}

Share this post


Link to post
Share on other sites

There is a number of things that are not all right

  1. if (object = 1) assigns the value 1 to object and will always be true
    You probably want: if (object==1)?
  2. The Object variable is never assigned anything but 1 so how can it become smaller than 0?
  3. Sensor will never present an object not sensed
    To see if the sensor failed you need: No_sensor
  4. The llDetectedPos() is not valid unless the object is sensed
  5. Use the Insert Code icon to make your code readable, Please

Share this post


Link to post
Share on other sites

I noticed several problems here at first glance:

You'll want a no_sensor() event handler, to complement the sensor() handler you already have.

I'm not sure what the "if (object = 1)" conditional is intended to do, but you have it written as an assignment, not a test (so it will always evaluate to true, and "object" will always get assigned the value of 1 when that line executes).

The llSensor() call won't be able to specify objectname as an argument because the name of the to-be-sensed object changes.  (I'm assuming that there are too many different appended numbers to be able to scan for each possibility every time.)  That means you'll just have to scan for objects of any name (specifying "" as the name parameter to llSensor) and then wade through the results looking for ones with names that start with your pattern (see llGetSubString).

(But be aware that you only get 16 values returned from a sensor scan, so if there's a lot of chaff in the environment, you'll need to use a very narrow sensor beam to make sure the sought object gets returned if it's there.)

Share this post


Link to post
Share on other sites

Replying to the OP, seems the reply button at the bottom left is acting like it is on the right

 

Reminds me of a early James bond film, where they all have names like number one and number two, does this scanner come on warning all it coming on so James bond can hide from it, anyway joking apart, it is not clear how object gets set, and you should have a no_sensor so you can tell when it is not there, sensor tells you its there by the event being triggered, no_sensor is triggered if it is not there, but I think James bond will be happy knowing that he will always have a chance to hide from the sensor and when to pop his head up again, still you could use them to launch a thunderbird or two.

Share this post


Link to post
Share on other sites

llInstantMessage(llGetOwner(),"Object not Present at "+ (string)llDetectedPos(i));

This line was the one that stood out the most to me and made me think twice about the logic. I had only just woken up and it really did mess with me for a bit lol.
Send an instant message to the owner saying "Object is not Present at the detected position it was not detected at".

You really need a no_sensor and if you intend to remember the position of the objects then the pos should be remembered from the last time it was detected. Once it's gone it's a lil too late to look at where it was.

Also I didn't want to repeat other peoples comments hence I havent mentioned anything someone else had already said.

Share this post


Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 3073 days.

Please take a moment to consider if this thread is worth bumping.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...