Jump to content
Sign in to follow this  
Lucka Bamaisin

Compass Needle animation

Recommended Posts

Hey all,

I am making a Compass HUD to set wind direction and speed on a boat. I have placed 8 prims (N, NE, E, etc) on a compass background and clicking those (so the sent command is in any of the 8 prims) sends the approriate wind heading to the boat, so far so good.

Now, I'd like a compass needle to show which heading has been selected. Created a texture with only the needle showing and want the needle texture to rotate according to the heading selected (counting from N, for example).

1. Does anyone know how to make a prim (not the clicked one!) rotate, after another has been touched?

2. Do I need to script this in the main prim (Compass face), the setting prim(s) (N, NE, E, etc)? Scripting it in the needle prim doesn't make any sense as that is not touched, imho....

3. How do I make sure that the needle always points in the right heading after consequetive heading changes? Reset to N every time it sets to the new heading?

New to scripting, already proud I got the 1st bit working, lol, so any advice help is very welcome!

Lucka

PS: I've added a pic to show how this looks.. the red areas are the "hotspots" to click to run the actual "change heading" script.

PS2: If someone should think: Totally wrong way to go about it, please let me know! Willing to learn :-)

question.png

Share this post


Link to post
Share on other sites

1. use SLPPF

http://wiki.secondlife.com/wiki/LlSetLinkPrimitiveParamsFast#llSetLinkPrimitiveParamsFast

use something like this to rotate texture ..

        integer needle = 3; // or what ever link number your needle is
        string texture = "e29fd1b5-d311-fcd3-f560-58beff17e84f"; // your needle texture's uuid
        float amt = -45.0; // make a list for each direction ... -45.0 is ne
        
        llSetLinkPrimitiveParamsFast(needle,
       [ PRIM_TEXTURE, ALL_SIDES,  texture, <1,1,0>, <1,1,0>, amt * DEG_TO_RAD]);

 

or PRIM_ROT_LOCAL to rotate the prim itself?

Share this post


Link to post
Share on other sites


Lucka Bamaisin wrote:

 the red areas are the "hotspots" to click to run the actual "change heading" script.

That's fine for getting this up and running, but it's not absolutely necessary that there be discrete hotspots. (Or, even if you want those hotspots, they don't have to be in the object as distinct faces, but can rather be only script-internal constructs.) llDetectedTouchST or similar may be useful here.

Share this post


Link to post
Share on other sites


Lucka Bamaisin wrote:

Hi Qie,

I'm afraid that is above my current level of expertise.... But I will look into it further.

Thank you for your reply :-)

 

Okay then, let's raise your current level of expertise...

 


If my level of expertise is high enough, you can drop that into a prim and it'll detect a touch on any face and return a cardinal direction string appropriate for the octant of the face that you touch. Drop your compass rose on the face and you should have what you want.

You can change the code to accept touches only on the desired face by changing "face != TOUCH_INVALID_FACE" to "face == face#".

;-).

Share this post


Link to post
Share on other sites

I have been playing with your script and although I consider myself a beginner, I fairly understand the math how it works because of the extensive explanation, thank you for that.

My problem is this. I want to use it to instruct a Bandit boat to change wind direction. If done by hand one simply types in N_S_W_E etc. in chat and the boat responds. But if I wear a prim with your script then the boat does not respond, My gut feeling is that the boat only accepts these commands from the owner of the boat and not from some prim.

I changed the llOwnerSay into llSay on channel 0.

So, is there a way to solve this by somehow making the boat accept it comes from me rather than a prim?

 

Thank you

Share this post


Link to post
Share on other sites

You can't change this script to make the boat think that it is listening to you.  You'll have to change the boat's script.  That's the script that's doing the listening. You'll have to teach it to recognize a command from you or something that you own.  Assuming that you can get into that script, you'll want to look for the filter in its listen event that is currently testing

if (id == llGetOwner() )

or something like that.  If you change that to

if ( llGetOwnerKey(id) == llGetOwner() )

it should accept a command that comes either from you or a scripted object that you own.  Of course, if you can't get into the boat's script, you are out of luck.

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.

Sign in to follow this  

×
×
  • Create New...