Jump to content
LeonissiaLoc

Turret Targeting Issue

Recommended Posts

Posted (edited)
1 hour ago, Rolig Loon said:

You already did that.  That's why you wrote

 

and the following test in the listen event.  Remember?  Put an llOwnerSay test right after 

 

to see whether you're looking at the right one.  If not, then you know where you better start looking for the mistake.

All this code does is list my avatar first followed by the rest in the list at the same time when I select one from the list:

  integer index = llListFindList(uuid,[]); 
       key kTarget = llList2Key(uuid,index);
vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
vector vPos=llGetPos();
 llLookAt(vPos + (vTargetPos + <0.0, 0.0, 0.0> - vPos) / llGetRootRotation(), 1.0, 0);

It does the same thing even before even before the timer starts in the listen event in this bit of code with the llOwnerSay() Test: 

   listen(integer channel, string obj, key id, string message)
    {
        list uuid = llList2ListStrided(Names, 0, -1, 2);
        integer index = llListFindList(Names, [message]);
        if (index != -1)
        {
             llSetTimerEvent(0.05);
        }
    } 

I think the problem is somewhere in the listen event or it could be in the sensor event because I have the same issue throughout the entire script. It doesn't zero in on the avatar I select It just keeps going at the avatar sensed first and ignores the one I select. Do I need to rewrite the script again or is there something that I failed to study properly? Could it be something simple that I forgot to include? At this point, I'm not really sure what to do.

Edited by LeonissiaLoc

Share this post


Link to post
Share on other sites
Posted (edited)

OK... look carefully at the listen event and the timer event and then scroll back up to where I explained about  using llListFindList.

   listen(integer channel, string obj, key id, string message)
    {
        list uuid = llList2ListStrided(Names, 0, -1, 2);
        integer index = llListFindList(Names, [message]);  // Here's the position of the name you want in the Names list
        if (index != -1)
        {
             llSetTimerEvent(0.05);  /// So you start the timer .....
        }
    }    
    timer()
    {
        
         integer index = llListFindList(uuid,[]); // Now the timer has triggered and it's looking for index again, but ...
       // how is it going to find it?  There's nothing in the matching list to search with!  It's empty [].
       key kTarget = llList2Key(uuid,index);   // So this means key Target = llList2Key(uuid,-1) -- not what you want.
vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
vector vPos=llGetPos();
 llLookAt(vPos + (vTargetPos + <0.0, 0.0, 0.0> - vPos) / llGetRootRotation(), 1.0, 0);


    } 

You want to use the value of index that you determined in the listen event.  So save it there as a global integer and don't try and find it again in the timer.

Edited by Rolig Loon
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

I defined integer index; in the global variable and now it looks at the right avatar when I select it. I had to study LSL Variables to figure out how to do it. I was just stressing out over it because it seemed impossible to define index as a global variable and then change it later in the script. Thank you for your help, I couldn't have figured that out without it. It was a lesson to go back to basics. I will do further testing to make sure everything works right.

 

Edited by LeonissiaLoc

Share this post


Link to post
Share on other sites

This morning at 7:30.  And then I lost it over breakfast.

In fact, it never "clicks".  If it did, it would be terribly boring.  As I said earlier (or maybe in a different thread) scripting is an exercise in logic.  It's about creating and solving puzzles.  When the puzzles stop being slightly beyond my ability, I figure I have probably set my sights too low, so it's time to find harder puzzles.   Fortunately, there's no lack there.

Share this post


Link to post
Share on other sites
1 minute ago, Rolig Loon said:

This morning at 7:30.  And then I lost it over breakfast.

In fact, it never "clicks".  If it did, it would be terribly boring.  As I said earlier (or maybe in a different thread) scripting is an exercise in logic.  It's about creating and solving puzzles.  When the puzzles stop being slightly beyond my ability, I figure I have probably set my sights too low, so it's time to find harder puzzles.   Fortunately, there's no lack there.

We can be glad there is an endless amount of puzzles to solve with this. That's interesting.

Share this post


Link to post
Share on other sites
Posted (edited)

Is there a way to have two timers in a script like this:

integer index;
default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }

    touch_start(integer total_number)
    {
        llSay(0, "Touched.");
    }
    timer()
    {
    }
    timer(index)
    {
    }
}

 

Edited by LeonissiaLoc

Share this post


Link to post
Share on other sites

No.  However, there are several ways to have the same effect.  Near the top of the sticky thread on Best Scripter Tips in this forum you will find a lengthy post about common ways to deal with exactly that problem.

Share this post


Link to post
Share on other sites
2 minutes ago, Rolig Loon said:

No.  However, there are several ways to have the same effect.  Near the top of the sticky thread on Best Scripter Tips in this forum you will find a lengthy post about common ways to deal with exactly that problem.

This threads problems have not been sorted out by the OP. Another problem on top is Titanic time.

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, steph Arnott said:

This threads problems have not been sorted out by the OP. Another problem on top is Titanic time.

There's always something.  I don't see "Titanic time," but there are other things to think about.  She's persistent.  

Share this post


Link to post
Share on other sites
Posted (edited)

What can I use to get the turret to not shoot the owner or the house, but only the target? Something that will make the turret stop shooting on the timer and then continue shooting after the obstacle is no longer in the way.

Edited by LeonissiaLoc

Share this post


Link to post
Share on other sites

Aha... now you have come to a more difficult challenge.  You are trying to avoid collateral damage.  To avoid shooting at a specific obstacle like the owner or her house, you will need a completely different technology.  Take a very long look at the wiki discussion of llCastRay.  You can think of it as a way of creating a virtual gunsight.  You use the function to "shoot" an imaginary beam of light in a straight line between two points and then tell you what is between them. The function can tell you the UUID of what the cast ray sees, where it is, and several other things.  It's a very nice tool to have.  You will need to do some little experiments off to the side to understand how it works and then face the challenge of building it into your script.

Share this post


Link to post
Share on other sites
Posted (edited)

Can llSetLinkPrimitiveParamsFast(); be used inside a timer function to make the base of the turret track the avatar selected in the dialogue? Note: the base is a separate prim in the link set and the barrel isn't the root prim. They are both connected to a separate block.

Edited by LeonissiaLoc

Share this post


Link to post
Share on other sites

That's impossible to answer without knowing what you have in mind. Can it be?  Sure. SLPPF doesn't track anything.  All it does is set parameters for prim properties.  If you have some method for locating a target each time the timer event is triggered (using llGetObjectDetails(uuid,[OBJECT_POS]), for example ), then you can use that tracking information to tell SLPPF which parameters to change.

Share this post


Link to post
Share on other sites

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.


×
×
  • Create New...